From 619c6ecd15894d8e50e7b75fea38eb14826ceae9 Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 7 Aug 2024 11:19:01 +0400 Subject: [PATCH] rename KMeans --- MANIFEST | 2 +- README.md | 2 +- docs/pyFTS.partitioners.rst | 4 ++-- pyFTS/partitioners/{CMeans.py => KMeans.py} | 8 ++++---- pyFTS/tests/cmsfts.py | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) rename pyFTS/partitioners/{CMeans.py => KMeans.py} (94%) diff --git a/MANIFEST b/MANIFEST index afc8357..ad79333 100644 --- a/MANIFEST +++ b/MANIFEST @@ -104,7 +104,7 @@ pyFTS/models/seasonal/common.py pyFTS/models/seasonal/msfts.py pyFTS/models/seasonal/partitioner.py pyFTS/models/seasonal/sfts.py -pyFTS/partitioners/CMeans.py +pyFTS/partitioners/KMeans.py pyFTS/partitioners/Entropy.py pyFTS/partitioners/FCM.py pyFTS/partitioners/Grid.py diff --git a/README.md b/README.md index 6c72c2e..1b178fb 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Fuzzy Time Series (FTS) are non parametric methods for time series forecasting b 2. **Universe of Discourse Partitioning**: This is the most important step. Here, the range of values of the numerical time series *Y(t)* will be splited in overlapped intervals and for each interval will be created a Fuzzy Set. This step is performed by pyFTS.partition module and its classes (for instance GridPartitioner, EntropyPartitioner, etc). The main parameters are: - the number of intervals - which fuzzy membership function (on [pyFTS.common.Membership](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/common/Membership.py)) - - partition scheme ([GridPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/Grid.py), [EntropyPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/Entropy.py)[3], [FCMPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/FCM.py), [CMeansPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/CMeans.py), [HuarngPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/Huarng.py)[4]) + - partition scheme ([GridPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/Grid.py), [EntropyPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/Entropy.py)[3], [FCMPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/FCM.py), [KMeansPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/KMeans.py), [HuarngPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/Huarng.py)[4]) Check out the jupyter notebook on [notebooks/Partitioners.ipynb](https://github.com/PYFTS/notebooks/blob/master/Partitioners.ipynb) for sample codes. diff --git a/docs/pyFTS.partitioners.rst b/docs/pyFTS.partitioners.rst index 29de726..dcd9f10 100644 --- a/docs/pyFTS.partitioners.rst +++ b/docs/pyFTS.partitioners.rst @@ -28,10 +28,10 @@ pyFTS.partitioners.Class module :undoc-members: :show-inheritance: -pyFTS.partitioners.CMeans module +pyFTS.partitioners.KMeans module -------------------------------- -.. automodule:: pyFTS.partitioners.CMeans +.. automodule:: pyFTS.partitioners.KMeans :members: :undoc-members: :show-inheritance: diff --git a/pyFTS/partitioners/CMeans.py b/pyFTS/partitioners/KMeans.py similarity index 94% rename from pyFTS/partitioners/CMeans.py rename to pyFTS/partitioners/KMeans.py index 70b4c0b..1017ba3 100644 --- a/pyFTS/partitioners/CMeans.py +++ b/pyFTS/partitioners/KMeans.py @@ -14,7 +14,7 @@ def distance(x, y): return math.sqrt(tmp) -def c_means(k, dados, tam): +def k_means(k, dados, tam): # Инициализирует центроиды, выбирая случайные элементы из множества centroides = [dados[rnd.randint(0, len(dados)-1)] for kk in range(0, k)] @@ -77,16 +77,16 @@ def c_means(k, dados, tam): return centroides -class CMeansPartitioner(partitioner.Partitioner): +class KMeansPartitioner(partitioner.Partitioner): def __init__(self, **kwargs): - super(CMeansPartitioner, self).__init__(name="CMeans", **kwargs) + super(KMeansPartitioner, self).__init__(name="KMeans", **kwargs) def build(self, data): sets = {} kwargs = {'type': self.type, 'variable': self.variable} - centroides = c_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.min) diff --git a/pyFTS/tests/cmsfts.py b/pyFTS/tests/cmsfts.py index 14eab97..d674f24 100644 --- a/pyFTS/tests/cmsfts.py +++ b/pyFTS/tests/cmsfts.py @@ -11,7 +11,7 @@ from mpl_toolkits.mplot3d import Axes3D import datetime import pandas as pd -from pyFTS.partitioners import Grid, CMeans, FCM, Entropy +from pyFTS.partitioners import Grid, KMeans, FCM, Entropy from pyFTS.common import FLR, FuzzySet, Membership, Transformations, Util, fts from pyFTS import sfts from pyFTS.models import msfts