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
import numpy as np
class ROI(Transformation):

View File

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

View File

@ -1,4 +1,8 @@
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):
@ -24,8 +28,6 @@ class LinearTrend(Transformation):
'''Regression model'''
def train(self, data, **kwargs):
from pandas import datetime
from sklearn.linear_model import LinearRegression
x = data[self.index_field].values

View File

@ -47,11 +47,11 @@ class Variable:
:param kwargs:
:return:
"""
fs = kwargs.get('partitioner', Grid.GridPartitioner)
mf = kwargs.get('func', Membership.trimf)
np = kwargs.get('npart', 10)
fs = kwargs.pop('partitioner', Grid.GridPartitioner)
mf = kwargs.pop('func', Membership.trimf)
np = kwargs.pop('npart', 10)
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,
transformation=self.transformation, prefix=self.alias,
variable=self.name, **kw)

View File

@ -661,16 +661,13 @@ class ProbabilisticWeightedFTS(ifts.IntervalFTS):
return tmp
def visualize_distributions(model, **kwargs):
import matplotlib.pyplot as plt
from matplotlib import gridspec
import seaborn as sns
def highorder_fuzzy_markov_chain(model):
ordered_sets = model.partitioner.ordered_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])
for k in ftpg_keys]
lhs_probs = np.array([model.flrg_lhs_unconditional_probability(model.flrgs[k])
for k in ftpg_keys])
mat = np.zeros((len(ftpg_keys), len(ordered_sets)))
for row, w in enumerate(ftpg_keys):
@ -678,6 +675,16 @@ def visualize_distributions(model, **kwargs):
if k in model.flrgs[w].RHS:
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))
fig = plt.figure(figsize=size)
@ -695,3 +702,5 @@ def visualize_distributions(model, **kwargs):
ax.set_xticklabels(ordered_sets)
ax.grid(True)
ax.xaxis.set_tick_params(rotation=90)