Merge branch 'master' into release1.7

This commit is contained in:
Petrônio Cândido 2022-04-10 12:58:47 -03:00
commit 06d1bf6e6a
5 changed files with 30 additions and 18 deletions

View File

@ -1,4 +1,5 @@
from pyFTS.common.transformations.transformation import Transformation from pyFTS.common.transformations.transformation import Transformation
import numpy as np
class ROI(Transformation): class ROI(Transformation):

View File

@ -6,14 +6,14 @@ import pandas as pd
from typing import Tuple from typing import Tuple
from typing import List from typing import List
from pyFTS.common.transformations.transformation import Transformation from pyFTS.common.transformations.transformation import Transformation
import SimpSOM as sps
class SOMTransformation(Transformation): class SOMTransformation(Transformation):
def __init__(self, def __init__(self,
grid_dimension: Tuple, grid_dimension: Tuple,
**kwargs): **kwargs):
import SimpSOM as sps
# SOM attributes # SOM attributes
self.load_file = kwargs.get('loadFile') self.load_file = kwargs.get('loadFile')

View File

@ -1,4 +1,8 @@
from pyFTS.common.transformations.transformation import Transformation from pyFTS.common.transformations.transformation import Transformation
from pandas import datetime
from sklearn.linear_model import LinearRegression
import numpy as np
import pandas as pd
class LinearTrend(Transformation): class LinearTrend(Transformation):
@ -24,8 +28,6 @@ class LinearTrend(Transformation):
'''Regression model''' '''Regression model'''
def train(self, data, **kwargs): def train(self, data, **kwargs):
from pandas import datetime
from sklearn.linear_model import LinearRegression
x = data[self.index_field].values x = data[self.index_field].values

View File

@ -47,11 +47,11 @@ class Variable:
:param kwargs: :param kwargs:
:return: :return:
""" """
fs = kwargs.get('partitioner', Grid.GridPartitioner) fs = kwargs.pop('partitioner', Grid.GridPartitioner)
mf = kwargs.get('func', Membership.trimf) mf = kwargs.pop('func', Membership.trimf)
np = kwargs.get('npart', 10) np = kwargs.pop('npart', 10)
data = kwargs.get('data', None) data = kwargs.get('data', None)
kw = kwargs.get('partitioner_specific', {}) kw = kwargs.pop('partitioner_specific', {})
self.partitioner = fs(data=data[self.data_label].values, npart=np, func=mf, self.partitioner = fs(data=data[self.data_label].values, npart=np, func=mf,
transformation=self.transformation, prefix=self.alias, transformation=self.transformation, prefix=self.alias,
variable=self.name, **kw) variable=self.name, **kw)

View File

@ -661,16 +661,13 @@ class ProbabilisticWeightedFTS(ifts.IntervalFTS):
return tmp return tmp
def visualize_distributions(model, **kwargs): def highorder_fuzzy_markov_chain(model):
import matplotlib.pyplot as plt
from matplotlib import gridspec
import seaborn as sns
ordered_sets = model.partitioner.ordered_sets ordered_sets = model.partitioner.ordered_sets
ftpg_keys = sorted(model.flrgs.keys(), key=lambda x: model.flrgs[x].get_midpoint(model.sets)) ftpg_keys = sorted(model.flrgs.keys(), key=lambda x: model.flrgs[x].get_midpoint(model.sets))
lhs_probs = [model.flrg_lhs_unconditional_probability(model.flrgs[k]) lhs_probs = np.array([model.flrg_lhs_unconditional_probability(model.flrgs[k])
for k in ftpg_keys] for k in ftpg_keys])
mat = np.zeros((len(ftpg_keys), len(ordered_sets))) mat = np.zeros((len(ftpg_keys), len(ordered_sets)))
for row, w in enumerate(ftpg_keys): for row, w in enumerate(ftpg_keys):
@ -678,6 +675,16 @@ def visualize_distributions(model, **kwargs):
if k in model.flrgs[w].RHS: if k in model.flrgs[w].RHS:
mat[row, col] = model.flrgs[w].rhs_unconditional_probability(k) mat[row, col] = model.flrgs[w].rhs_unconditional_probability(k)
return ftpg_keys, ordered_sets, lhs_probs, mat
def visualize_distributions(model, **kwargs):
import matplotlib.pyplot as plt
from matplotlib import gridspec
import seaborn as sns
ftpg_keys, ordered_sets, lhs_probs, mat = highorder_fuzzy_markov_chain(model)
size = kwargs.get('size', (5,10)) size = kwargs.get('size', (5,10))
fig = plt.figure(figsize=size) fig = plt.figure(figsize=size)
@ -695,3 +702,5 @@ def visualize_distributions(model, **kwargs):
ax.set_xticklabels(ordered_sets) ax.set_xticklabels(ordered_sets)
ax.grid(True) ax.grid(True)
ax.xaxis.set_tick_params(rotation=90) ax.xaxis.set_tick_params(rotation=90)