pyFTS/partitioners/Grid.py
Petrônio Cândido de Lima e Silva 5c8c80cd8d - new sliding window benchmarks
- statsmodels ARIMA wrapper for benchmarks
 - method refactoring at PWFTS
 - auto_update at PWFTS
 - method refactoring at ResidualAnalysis
2017-03-03 08:53:55 -03:00

31 lines
1.0 KiB
Python

import numpy as np
import math
import random as rnd
import functools, operator
from pyFTS.common import FuzzySet, Membership
from pyFTS.partitioners import partitioner
class GridPartitioner(partitioner.Partitioner):
def __init__(self, data, npart, func = Membership.trimf, transformation=None):
super(GridPartitioner, self).__init__("Grid", data, npart, func=func, transformation=transformation)
def build(self, data):
sets = []
dlen = self.max - self.min
partlen = dlen / self.partitions
count = 0
for c in np.arange(self.min, self.max, partlen):
if self.membership_function == Membership.trimf:
sets.append(
FuzzySet.FuzzySet(self.prefix + str(count), Membership.trimf, [c - partlen, c, c + partlen],c))
elif self.membership_function == Membership.gaussmf:
sets.append(
FuzzySet.FuzzySet(self.prefix + str(count), Membership.gaussmf, [c, partlen / 3], c))
count += 1
return sets