Compare commits
4 Commits
619c6ecd15
...
a8fb849bc8
Author | SHA1 | Date | |
---|---|---|---|
a8fb849bc8 | |||
8be936e383 | |||
e1f72797ea | |||
e55ef29351 |
@ -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)]
|
||||
|
||||
# Membership table
|
||||
membership_table = np.zeros((k, data_length)) #[[0 for kk in range(0, k)] for xx in range(0, data_length)]
|
||||
membership_table = np.zeros((data_length, k))
|
||||
|
||||
mean_change = 1000
|
||||
|
||||
@ -50,12 +50,12 @@ def fuzzy_cmeans(k, data, size, m, deltadist=0.001):
|
||||
inst_count = 0
|
||||
for instance in data:
|
||||
|
||||
dist_groups = np.zeros(k) #[0 for xx in range(0, k)]
|
||||
dist_groups = np.zeros(k)
|
||||
|
||||
for group_count, group in enumerate(centroids):
|
||||
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):
|
||||
if dist_groups[grp] == 0:
|
||||
|
@ -87,9 +87,9 @@ class KMeansPartitioner(partitioner.Partitioner):
|
||||
kwargs = {'type': self.type, 'variable': self.variable}
|
||||
|
||||
centroides = k_means(self.partitions, data, 1)
|
||||
centroides = [v[0] for v in centroides]
|
||||
centroides.append(self.max)
|
||||
centroides.append(self.min)
|
||||
centroides = list(set(centroides))
|
||||
centroides.sort()
|
||||
for c in range(1, len(centroides) - 1):
|
||||
_name = self.get_name(c)
|
||||
|
@ -24,13 +24,14 @@ def plot_sets(sets: dict, titles : list, size=[12, 10], save=False, file=None, a
|
||||
|
||||
"""
|
||||
num = len(sets)
|
||||
num_cols_plot = 1
|
||||
|
||||
if axis is None:
|
||||
fig, axes = plt.subplots(nrows=num, ncols=1, figsize=size)
|
||||
for k in np.arange(0,num):
|
||||
fig, axes = plt.subplots(nrows=num, ncols=num_cols_plot, figsize=size, squeeze=False)
|
||||
for k in range(num):
|
||||
ticks = []
|
||||
x = []
|
||||
ax = axes[k] if axis is None else axis
|
||||
ax = axes[k, num_cols_plot-1] if axis is None else axis
|
||||
ax.set_title(titles[k])
|
||||
ax.set_ylim([0, 1.1])
|
||||
for key in sets[k].keys():
|
||||
|
@ -1,6 +1,7 @@
|
||||
from pyFTS.common import FuzzySet, Membership
|
||||
import numpy as np
|
||||
from scipy.spatial import KDTree
|
||||
import warnings
|
||||
|
||||
|
||||
class Partitioner(object):
|
||||
@ -45,6 +46,9 @@ class Partitioner(object):
|
||||
if kwargs.get('preprocess',True):
|
||||
|
||||
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:
|
||||
ndata = self.indexer.get_data(data)
|
||||
|
Loading…
Reference in New Issue
Block a user