Compare commits

..

No commits in common. "e9d5f7629fdac279b08dd811526fa128fe91e99d" and "c24ebe6b81f8ef9f37a35834faf06e4674ec3969" have entirely different histories.

2 changed files with 8 additions and 8 deletions

View File

@ -15,14 +15,14 @@ def distance(x, y):
def c_means(k, dados, tam):
# Инициализирует центроиды, выбирая случайные элементы из множества
# Inicializa as centróides escolhendo elementos aleatórios dos conjuntos
centroides = [dados[rnd.randint(0, len(dados)-1)] for kk in range(0, k)]
grupos = [-1 for x in range(0, len(dados))]
it_semmodificacao = 0
# для каждого экземпляра
# para cada instância
iteracoes = 0
while iteracoes < 1000 and it_semmodificacao < 10:
inst_count = 0
@ -31,7 +31,7 @@ def c_means(k, dados, tam):
for instancia in dados:
# проверяет расстояние до каждого центроида
# verifica a distância para cada centroide
grupo_count = 0
dist = 10000
@ -41,7 +41,7 @@ def c_means(k, dados, tam):
tmp = distance(instancia, grupo)
if tmp < dist:
dist = tmp
# ассоциирует центроид с наименьшим расстоянием до экземпляра
# associa a a centroide de menor distância à instância
grupos[inst_count] = grupo_count
grupo_count = grupo_count + 1
@ -55,7 +55,7 @@ def c_means(k, dados, tam):
else:
it_semmodificacao = 0
# обновляет каждый центроид на основе средних значений всех связанных с ним экземпляров
# atualiza cada centroide com base nos valores médios de todas as instâncias à ela associadas
grupo_count = 0
for grupo in centroides:
total_inst = functools.reduce(operator.add, [1 for xx in grupos if xx == grupo_count], 0)

View File

@ -18,7 +18,7 @@ all_methods = [Grid.GridPartitioner, Entropy.EntropyPartitioner, FCM.FCMPartitio
mfs = [Membership.trimf, Membership.gaussmf, Membership.trapmf]
def plot_sets(sets: dict, titles : list, size=[12, 10], save=False, file=None, axis=None):
def plot_sets(data, sets: dict, titles : list, size=[12, 10], save=False, file=None, axis=None):
"""
Plot all fuzzy sets in a Partitioner
@ -26,7 +26,7 @@ def plot_sets(sets: dict, titles : list, size=[12, 10], save=False, file=None, a
num = len(sets)
if axis is None:
fig, axes = plt.subplots(nrows=num, ncols=1, figsize=size)
fig, axes = plt.subplots(nrows=num, ncols=1,figsize=size)
for k in np.arange(0,num):
ticks = []
x = []
@ -54,7 +54,7 @@ def plot_sets(sets: dict, titles : list, size=[12, 10], save=False, file=None, a
Util.show_and_save_image(fig, file, save)
def plot_partitioners(objs, tam=[12, 10], save=False, file=None, axis=None):
def plot_partitioners(data, objs, tam=[12, 10], save=False, file=None, axis=None):
sets = [k.sets for k in objs]
titles = [k.name for k in objs]
plot_sets(sets, titles, tam, save, file, axis)