def train(self, data, **kwargs): if self.method == 'unconditional': window_size = kwargs.get('parameters', 1) tmpdata = common.fuzzySeries(data, self.sets, self.partitioner.ordered_sets, window_size, method='fuzzy') else: tmpdata = common.fuzzySeries(data, self.sets, self.partitioner.ordered_sets, method='fuzzy', const_t=0) flrs = FLR.generate_non_recurrent_flrs(tmpdata) self.generate_flrg(flrs) if self.method == 'conditional': self.forecasts = self.forecast(data, no_update=True) self.residuals = np.array(data[1:]) - np.array(self.forecasts[:-1]) self.variance_residual = np.var( self.residuals) # np.max(self.residuals self.mean_residual = np.mean(self.residuals) self.residuals = self.residuals[-self.memory_window:].tolist() self.forecasts = self.forecasts[-self.memory_window:] self.inputs = np.array(data[-self.memory_window:]).tolist()
def train(self, data, **kwargs): if kwargs.get('sets', None) is not None: self.sets = kwargs.get('sets', None) if kwargs.get('parameters', None) is not None: self.seasonality = kwargs.get('parameters', None) flrs = FLR.generate_indexed_flrs(self.sets, self.indexer, data) self.generate_flrg(flrs)
def train(self, ndata, **kwargs): tmpdata = FuzzySet.fuzzyfy(ndata, partitioner=self.partitioner, method='maximum', mode='sets') flrs = FLR.generate_recurrent_flrs(tmpdata) self.generate_FLRG(flrs)
def train(self, data, **kwargs): if kwargs.get('sets', None) is not None: self.sets = kwargs.get('sets', None) if kwargs.get('parameters', None) is not None: self.seasonality = kwargs.get('parameters', None) #ndata = self.indexer.set_data(data,self.doTransformations(self.indexer.get_data(data))) flrs = FLR.generate_indexed_flrs(self.sets, self.indexer, data) self.generate_flrg(flrs)
def train(self, data, **kwargs): tmpdata = FuzzySet.fuzzyfy(data, partitioner=self.partitioner, method='maximum', mode='sets') flrs = FLR.generate_non_recurrent_flrs(tmpdata) self.operation_matrix(flrs)
def train(self, data, **kwargs): parameters = kwargs.get('parameters', 'fuzzy') if parameters == 'monotonic': tmpdata = FuzzySet.fuzzyfy_series_old(data, self.sets) flrs = FLR.generate_recurrent_flrs(tmpdata) self.generateFLRG(flrs) else: self.generate_flrg(data)
def train(self, data, **kwargs): window_size = kwargs.get('parameters', 1) tmpdata = common.fuzzySeries(data, self.sets, self.partitioner.ordered_sets, window_size, method='fuzzy') flrs = FLR.generate_recurrent_flrs(tmpdata) self.generate_flrg(flrs)
def train(self, ndata, **kwargs): self.min_tx = min(ndata) self.max_tx = max(ndata) tmpdata = common.fuzzySeries(ndata, self.sets, self.partitioner.ordered_sets, method='fuzzy', const_t=0) flrs = FLR.generate_non_recurrent_flrs(tmpdata) self.generate_flrg(flrs)
def train(self, data, **kwargs): self.configure_lags(**kwargs) parameters = kwargs.get('parameters','fuzzy') if parameters == 'monotonic': tmpdata = self.partitioner.fuzzyfy(data, mode='sets', method='maximum') flrs = FLR.generate_recurrent_flrs(tmpdata) self.generate_flrg(flrs) else: self.generate_flrg(data)
def train(self, data, **kwargs): if kwargs.get('sets', None) is not None: self.sets = kwargs.get('sets', None) if kwargs.get('parameters', None) is not None: self.seasonality = kwargs.get('parameters', None) flrs = FLR.generate_indexed_flrs( self.sets, self.indexer, data, transformation=self.partitioner.transformation, alpha_cut=self.alpha_cut) self.generate_flrg(flrs)
def __init__(self, trainData, parts, fuzzyMethod, fuzzyMode, order=1): self.order = order self.trainData = trainData self.fs = Grid.GridPartitioner(data=self.trainData, npart=parts) self.fuzzyfied = self.fs.fuzzyfy(self.trainData, method=fuzzyMethod, mode=fuzzyMode) self.patterns = FLR.generate_non_recurrent_flrs(self.fuzzyfied) if self.order > 1: self.modelHO = pyFTS.models.hofts.HighOrderFTS(order=self.order, partitioner=self.fs) self.modelHO.fit(self.trainData) else: self.model = chen.ConventionalFTS(partitioner=self.fs) self.model.fit(self.trainData)
def train(self, ndata, **kwargs): tmpdata = common.fuzzySeries(ndata, self.sets, self.partitioner.ordered_sets, method='fuzzy', const_t=0) flrs = FLR.generate_non_recurrent_flrs(tmpdata) self.generate_flrg(flrs) self.forecasts = self.forecast(ndata, no_update=True) self.residuals = np.array(ndata[1:]) - np.array(self.forecasts[:-1]) self.variance_residual = np.var( self.residuals) # np.max(self.residuals self.mean_residual = np.mean(self.residuals) self.residuals = self.residuals[-self.memory_window:].tolist() self.forecasts = self.forecasts[-self.memory_window:] self.inputs = np.array(ndata[-self.memory_window:]).tolist()
def train(self, data, **kwargs): if kwargs.get('sets', None) is not None: self.sets = kwargs.get('sets', None) tmpdata = FuzzySet.fuzzyfy_series_old(data, self.sets) flrs = FLR.generate_non_recurrent_flrs(tmpdata) self.generate_flrg(flrs)
def train(self, data, **kwargs): tmpdata = self.partitioner.fuzzyfy(data, method='maximum', mode='sets') flrs = FLR.generate_recurrent_flrs(tmpdata) self.generate_flrg(flrs, self.c)
def train(self, ndata, **kwargs): tmpdata = FuzzySet.fuzzyfy_series(ndata, self.sets, method='maximum') flrs = FLR.generate_recurrent_flrs(tmpdata) self.generate_flrg(flrs)
data_max = max(train_data) data_min = min(train_data) norm_train_data = (train_data - data_min) / (data_max - data_min) from pyFTS.partitioners import Grid fs = Grid.GridPartitioner(data=norm_train_data, npart=fzz) fig, ax = plt.subplots(nrows=1, ncols=1, figsize=[15, 5]) fs.plot(ax) #Cria os conjuntos fuzzy fuzzyfied = fs.fuzzyfy(norm_train_data, method='fuzzy', mode='sets') print(fuzzyfied) #Ordena os conjuntos fuzzy from pyFTS.common import FLR patterns = FLR.generate_non_recurrent_flrs(fuzzyfied) print([str(k) for k in patterns]) #Treina o modelo com o conjunto fuzzy from pyFTS.models import chen model = chen.ConventionalFTS(partitioner=fs) model.fit(norm_train_data) print(model) #carregamento do conjunto de teste df = pd.read_csv(teste) data_test = df['Adj Close'].values new_data = [] for i in range(len(data_test)): if data_test[i] == data_test[i]: new_data.append(data_test[i])
def train(self, data, **kwargs): tmpdata = FuzzySet.fuzzyfy_series(data, self.sets, method='maximum') flrs = FLR.generate_non_recurrent_flrs(tmpdata) self.operation_matrix(flrs)
def train(self, data, **kwargs): tmpdata = self.partitioner.fuzzyfy(data, method='maximum', mode='sets') flrs = FLR.generate_non_recurrent_flrs(tmpdata, steps=self.standard_horizon) self.generate_flrg(flrs)