Compare commits

...

2 Commits

Author SHA1 Message Date
sam
e9d5f7629f Delete an unnecessary variable "data" 2024-08-07 10:26:48 +04:00
sam
78e63aaa63 Update portugalian on russian 2024-08-07 10:26:07 +04:00
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): 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)] centroides = [dados[rnd.randint(0, len(dados)-1)] for kk in range(0, k)]
grupos = [-1 for x in range(0, len(dados))] grupos = [-1 for x in range(0, len(dados))]
it_semmodificacao = 0 it_semmodificacao = 0
# para cada instância # для каждого экземпляра
iteracoes = 0 iteracoes = 0
while iteracoes < 1000 and it_semmodificacao < 10: while iteracoes < 1000 and it_semmodificacao < 10:
inst_count = 0 inst_count = 0
@ -31,7 +31,7 @@ def c_means(k, dados, tam):
for instancia in dados: for instancia in dados:
# verifica a distância para cada centroide # проверяет расстояние до каждого центроида
grupo_count = 0 grupo_count = 0
dist = 10000 dist = 10000
@ -41,7 +41,7 @@ def c_means(k, dados, tam):
tmp = distance(instancia, grupo) tmp = distance(instancia, grupo)
if tmp < dist: if tmp < dist:
dist = tmp dist = tmp
# associa a a centroide de menor distância à instância # ассоциирует центроид с наименьшим расстоянием до экземпляра
grupos[inst_count] = grupo_count grupos[inst_count] = grupo_count
grupo_count = grupo_count + 1 grupo_count = grupo_count + 1
@ -55,7 +55,7 @@ def c_means(k, dados, tam):
else: else:
it_semmodificacao = 0 it_semmodificacao = 0
# atualiza cada centroide com base nos valores médios de todas as instâncias à ela associadas # обновляет каждый центроид на основе средних значений всех связанных с ним экземпляров
grupo_count = 0 grupo_count = 0
for grupo in centroides: for grupo in centroides:
total_inst = functools.reduce(operator.add, [1 for xx in grupos if xx == grupo_count], 0) 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] mfs = [Membership.trimf, Membership.gaussmf, Membership.trapmf]
def plot_sets(data, sets: dict, titles : list, size=[12, 10], save=False, file=None, axis=None): def plot_sets(sets: dict, titles : list, size=[12, 10], save=False, file=None, axis=None):
""" """
Plot all fuzzy sets in a Partitioner Plot all fuzzy sets in a Partitioner
@ -54,7 +54,7 @@ def plot_sets(data, sets: dict, titles : list, size=[12, 10], save=False, file=N
Util.show_and_save_image(fig, file, save) Util.show_and_save_image(fig, file, save)
def plot_partitioners(data, objs, tam=[12, 10], save=False, file=None, axis=None): def plot_partitioners(objs, tam=[12, 10], save=False, file=None, axis=None):
sets = [k.sets for k in objs] sets = [k.sets for k in objs]
titles = [k.name for k in objs] titles = [k.name for k in objs]
plot_sets(sets, titles, tam, save, file, axis) plot_sets(sets, titles, tam, save, file, axis)