Compare commits

..

No commits in common. "a8fb849bc8d2d5b7dee6c61a0c40f1634d3adc2c" and "619c6ecd15894d8e50e7b75fea38eb14826ceae9" have entirely different histories.

4 changed files with 7 additions and 12 deletions

View File

@ -36,7 +36,7 @@ def fuzzy_cmeans(k, data, size, m, deltadist=0.001):
centroids = [data[rnd.randint(0, data_length - 1)] for kk in range(0, k)] centroids = [data[rnd.randint(0, data_length - 1)] for kk in range(0, k)]
# Membership table # Membership table
membership_table = np.zeros((data_length, k)) membership_table = np.zeros((k, data_length)) #[[0 for kk in range(0, k)] for xx in range(0, data_length)]
mean_change = 1000 mean_change = 1000
@ -50,12 +50,12 @@ def fuzzy_cmeans(k, data, size, m, deltadist=0.001):
inst_count = 0 inst_count = 0
for instance in data: for instance in data:
dist_groups = np.zeros(k) dist_groups = np.zeros(k) #[0 for xx in range(0, k)]
for group_count, group in enumerate(centroids): for group_count, group in enumerate(centroids):
dist_groups[group_count] = fuzzy_distance(group, instance) dist_groups[group_count] = fuzzy_distance(group, instance)
# dist_groups_total = functools.reduce(operator.add, [xk for xk in dist_groups]) dist_groups_total = functools.reduce(operator.add, [xk for xk in dist_groups])
for grp in range(0, k): for grp in range(0, k):
if dist_groups[grp] == 0: if dist_groups[grp] == 0:

View File

@ -87,9 +87,9 @@ class KMeansPartitioner(partitioner.Partitioner):
kwargs = {'type': self.type, 'variable': self.variable} kwargs = {'type': self.type, 'variable': self.variable}
centroides = k_means(self.partitions, data, 1) centroides = k_means(self.partitions, data, 1)
centroides = [v[0] for v in centroides]
centroides.append(self.max) centroides.append(self.max)
centroides.append(self.min) centroides.append(self.min)
centroides = list(set(centroides))
centroides.sort() centroides.sort()
for c in range(1, len(centroides) - 1): for c in range(1, len(centroides) - 1):
_name = self.get_name(c) _name = self.get_name(c)

View File

@ -24,14 +24,13 @@ def plot_sets(sets: dict, titles : list, size=[12, 10], save=False, file=None, a
""" """
num = len(sets) num = len(sets)
num_cols_plot = 1
if axis is None: if axis is None:
fig, axes = plt.subplots(nrows=num, ncols=num_cols_plot, figsize=size, squeeze=False) fig, axes = plt.subplots(nrows=num, ncols=1, figsize=size)
for k in range(num): for k in np.arange(0,num):
ticks = [] ticks = []
x = [] x = []
ax = axes[k, num_cols_plot-1] if axis is None else axis ax = axes[k] if axis is None else axis
ax.set_title(titles[k]) ax.set_title(titles[k])
ax.set_ylim([0, 1.1]) ax.set_ylim([0, 1.1])
for key in sets[k].keys(): for key in sets[k].keys():

View File

@ -1,7 +1,6 @@
from pyFTS.common import FuzzySet, Membership from pyFTS.common import FuzzySet, Membership
import numpy as np import numpy as np
from scipy.spatial import KDTree from scipy.spatial import KDTree
import warnings
class Partitioner(object): class Partitioner(object):
@ -47,9 +46,6 @@ class Partitioner(object):
data = kwargs.get('data',[None]) data = kwargs.get('data',[None])
if len(data.shape) > 1:
warnings.warn(f"An ndarray of dimension greater than 1 is used. shape.len(): {len(data.shape)}")
if self.indexer is not None: if self.indexer is not None:
ndata = self.indexer.get_data(data) ndata = self.indexer.get_data(data)
else: else: