rename KMeans

This commit is contained in:
Антон Скалкин 2024-08-07 11:19:01 +04:00
parent fac2aa5ca8
commit 619c6ecd15
5 changed files with 9 additions and 9 deletions

View File

@ -104,7 +104,7 @@ pyFTS/models/seasonal/common.py
pyFTS/models/seasonal/msfts.py pyFTS/models/seasonal/msfts.py
pyFTS/models/seasonal/partitioner.py pyFTS/models/seasonal/partitioner.py
pyFTS/models/seasonal/sfts.py pyFTS/models/seasonal/sfts.py
pyFTS/partitioners/CMeans.py pyFTS/partitioners/KMeans.py
pyFTS/partitioners/Entropy.py pyFTS/partitioners/Entropy.py
pyFTS/partitioners/FCM.py pyFTS/partitioners/FCM.py
pyFTS/partitioners/Grid.py pyFTS/partitioners/Grid.py

View File

@ -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: 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 - the number of intervals
- which fuzzy membership function (on [pyFTS.common.Membership](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/common/Membership.py)) - 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. Check out the jupyter notebook on [notebooks/Partitioners.ipynb](https://github.com/PYFTS/notebooks/blob/master/Partitioners.ipynb) for sample codes.

View File

@ -28,10 +28,10 @@ pyFTS.partitioners.Class module
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
pyFTS.partitioners.CMeans module pyFTS.partitioners.KMeans module
-------------------------------- --------------------------------
.. automodule:: pyFTS.partitioners.CMeans .. automodule:: pyFTS.partitioners.KMeans
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:

View File

@ -14,7 +14,7 @@ def distance(x, y):
return math.sqrt(tmp) 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)] 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 return centroides
class CMeansPartitioner(partitioner.Partitioner): class KMeansPartitioner(partitioner.Partitioner):
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(CMeansPartitioner, self).__init__(name="CMeans", **kwargs) super(KMeansPartitioner, self).__init__(name="KMeans", **kwargs)
def build(self, data): def build(self, data):
sets = {} sets = {}
kwargs = {'type': self.type, 'variable': self.variable} 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 = [v[0] for v in centroides]
centroides.append(self.max) centroides.append(self.max)
centroides.append(self.min) centroides.append(self.min)

View File

@ -11,7 +11,7 @@ from mpl_toolkits.mplot3d import Axes3D
import datetime import datetime
import pandas as pd 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.common import FLR, FuzzySet, Membership, Transformations, Util, fts
from pyFTS import sfts from pyFTS import sfts
from pyFTS.models import msfts from pyFTS.models import msfts