diff --git a/docs/build/html/_modules/pyFTS/models/multivariate/granular.html b/docs/build/html/_modules/pyFTS/models/multivariate/granular.html new file mode 100644 index 0000000..13d874f --- /dev/null +++ b/docs/build/html/_modules/pyFTS/models/multivariate/granular.html @@ -0,0 +1,127 @@ + + + + + + + + + pyFTS.models.multivariate.granular — pyFTS 1.4 documentation + + + + + + + + + + + + + + + + +
+
+
+
+ +

Source code for pyFTS.models.multivariate.granular

+from pyFTS.models.multivariate import cmvfts, grid
+from pyFTS.models import hofts
+
+
+
[docs]class GranularWMVFTS(cmvfts.ClusteredMVFTS): + """ + Granular multivariate weighted high order FTS + """ + + def __init__(self, **kwargs): + super(GranularWMVFTS, self).__init__(**kwargs) + + self.fts_method = hofts.WeightedHighOrderFTS + self.model = None + """The most recent trained model""" + self.knn = kwargs.get('knn', 2) + self.order = kwargs.get("order", 2) + self.shortname = "GranularWMVFTS" + self.name = "Granular Weighted Multivariate FTS" + +
[docs] def train(self, data, **kwargs): + self.partitioner = grid.IncrementalGridCluster( + explanatory_variables=self.explanatory_variables, + target_variable=self.target_variable, + neighbors=self.knn) + super(GranularWMVFTS, self).train(data,**kwargs)
+ +
+ +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/build/html/_modules/pyFTS/models/multivariate/grid.html b/docs/build/html/_modules/pyFTS/models/multivariate/grid.html new file mode 100644 index 0000000..d086d5d --- /dev/null +++ b/docs/build/html/_modules/pyFTS/models/multivariate/grid.html @@ -0,0 +1,199 @@ + + + + + + + + + pyFTS.models.multivariate.grid — pyFTS 1.4 documentation + + + + + + + + + + + + + + + + +
+
+
+
+ +

Source code for pyFTS.models.multivariate.grid

+from pyFTS.models.multivariate import partitioner
+from pyFTS.models.multivariate.common import MultivariateFuzzySet, fuzzyfy_instance_clustered
+from itertools import product
+from scipy.spatial import KDTree
+import numpy as np
+import pandas as pd
+
+
+
[docs]class GridCluster(partitioner.MultivariatePartitioner): + """ + A cartesian product of all fuzzy sets of all variables + """ + + def __init__(self, **kwargs): + super(GridCluster, self).__init__(**kwargs) + self.name="GridCluster" + self.build(None) + +
[docs] def build(self, data): + + fsets = [[x for x in k.partitioner.sets.values()] + for k in self.explanatory_variables] + c = 0 + for k in product(*fsets): + mvfset = MultivariateFuzzySet(target_variable=self.target_variable) + for fset in k: + mvfset.append_set(fset.variable, fset) + + self.sets[mvfset.name] = mvfset + c += 1 + + self.build_index()
+ + +
[docs]class IncrementalGridCluster(partitioner.MultivariatePartitioner): + """ + Create combinations of fuzzy sets of the variables on demand, incrementally increasing the + multivariate fuzzy set base. + """ + def __init__(self, **kwargs): + super(IncrementalGridCluster, self).__init__(**kwargs) + self.name="IncrementalGridCluster" + self.build(None) + +
[docs] def fuzzyfy(self, data, **kwargs): + + if isinstance(data, pd.DataFrame): + ret = [] + for index, inst in data.iterrows(): + mv = self.fuzzyfy(inst, **kwargs) + ret.append(mv) + return ret + + if self.kdtree is not None: + fsets = self.search(data, type='name') + else: + fsets = self.incremental_search(data, type='name') + + mode = kwargs.get('mode', 'sets') + if mode == 'sets': + return fsets + elif mode == 'vector': + raise NotImplementedError() + elif mode == 'both': + ret = [] + for key in fsets: + mvfset = self.sets[key] + ret.append((key, mvfset.membership(data))) + return ret
+ + + +
[docs] def prune(self): + self.build_index()
+ +
+ +
+
+
+
+
+ + + + \ No newline at end of file