Merge branch 'master' of https://github.com/PYFTS/pyFTS
This commit is contained in:
commit
22de024b8f
@ -1,10 +1,9 @@
|
|||||||
from pyFTS.common.transformations.transformation import Transformation
|
from pyFTS.common.transformations.transformation import Transformation
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
class MovingAverage(Transformation):
|
class MovingAverage(Transformation):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(MovingAverage, self).__init__()
|
super(MovingAverage, self).__init__(**kwargs)
|
||||||
self.name = 'Moving Average Smoothing'
|
self.name = 'Moving Average Smoothing'
|
||||||
self.steps = kwargs.get('steps',2)
|
self.steps = kwargs.get('steps',2)
|
||||||
|
|
||||||
@ -20,8 +19,8 @@ class MovingAverage(Transformation):
|
|||||||
|
|
||||||
class ExponentialSmoothing(Transformation):
|
class ExponentialSmoothing(Transformation):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(MovingAverage, self).__init__()
|
super(ExponentialSmoothing,self).__init__(**kwargs)
|
||||||
self.name = 'Moving Average Smoothing'
|
self.name = 'Exponential Moving Average Smoothing'
|
||||||
self.steps = kwargs.get('steps',2)
|
self.steps = kwargs.get('steps',2)
|
||||||
self.beta = kwargs.get('beta',.5)
|
self.beta = kwargs.get('beta',.5)
|
||||||
|
|
||||||
@ -39,3 +38,53 @@ class ExponentialSmoothing(Transformation):
|
|||||||
|
|
||||||
def inverse(self, data, param=None, **kwargs):
|
def inverse(self, data, param=None, **kwargs):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
class AveragePooling(Transformation):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super(AveragePooling,self).__init__(**kwargs)
|
||||||
|
self.name = 'Exponential Average Smoothing'
|
||||||
|
self.kernel = kwargs.get('kernel',5)
|
||||||
|
self.stride = kwargs.get('stride',1)
|
||||||
|
self.padding = kwargs.get('padding','same')
|
||||||
|
|
||||||
|
def apply(self, data):
|
||||||
|
result = []
|
||||||
|
if self.padding == 'same':
|
||||||
|
for i in range(int(self.kernel/2), len(data)+int(self.kernel/2), self.stride):
|
||||||
|
result.append(np.mean(data[np.max([0,i-self.kernel]):np.min([i, len(data)])]))
|
||||||
|
|
||||||
|
elif self.padding == 'valid':
|
||||||
|
for i in range(self.kernel, len(data), self.stride):
|
||||||
|
result.append(np.mean(data[i-self.kernel:i]))
|
||||||
|
else:
|
||||||
|
raise ValueError('Invalid padding schema')
|
||||||
|
return result
|
||||||
|
|
||||||
|
def inverse(self, data, param=None, **kwargs):
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
class MaxPooling(Transformation):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super(MaxPooling,self).__init__(**kwargs)
|
||||||
|
self.name = 'Exponential Average Smoothing'
|
||||||
|
self.kernel = kwargs.get('kernel',5)
|
||||||
|
self.stride = kwargs.get('stride',1)
|
||||||
|
self.padding = kwargs.get('padding','same')
|
||||||
|
|
||||||
|
def apply(self, data):
|
||||||
|
result = []
|
||||||
|
if self.padding == 'same':
|
||||||
|
for i in range(int(self.kernel/2), len(data)+int(self.kernel/2), self.stride):
|
||||||
|
result.append(np.max(data[np.max([0,i-self.kernel]):np.min([i, len(data)])]))
|
||||||
|
|
||||||
|
elif self.padding == 'valid':
|
||||||
|
for i in range(self.kernel - 1, len(data), self.stride):
|
||||||
|
result.append(np.max(data[i-self.kernel:i]))
|
||||||
|
else:
|
||||||
|
raise ValueError('Invalid padding schema')
|
||||||
|
return result
|
||||||
|
|
||||||
|
def inverse(self, data, param=None, **kwargs):
|
||||||
|
return data
|
4
setup.py
4
setup.py
@ -5,6 +5,10 @@ import setuptools
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='pyFTS',
|
name='pyFTS',
|
||||||
|
install_requires=[
|
||||||
|
'matplotlib',
|
||||||
|
'numpy',
|
||||||
|
'pandas'],
|
||||||
packages=['pyFTS', 'pyFTS.benchmarks', 'pyFTS.common', 'pyFTS.common.transformations', 'pyFTS.data',
|
packages=['pyFTS', 'pyFTS.benchmarks', 'pyFTS.common', 'pyFTS.common.transformations', 'pyFTS.data',
|
||||||
'pyFTS.models.ensemble', 'pyFTS.models', 'pyFTS.models.seasonal', 'pyFTS.partitioners',
|
'pyFTS.models.ensemble', 'pyFTS.models', 'pyFTS.models.seasonal', 'pyFTS.partitioners',
|
||||||
'pyFTS.probabilistic', 'pyFTS.tests', 'pyFTS.models.nonstationary', 'pyFTS.models.multivariate',
|
'pyFTS.probabilistic', 'pyFTS.tests', 'pyFTS.models.nonstationary', 'pyFTS.models.multivariate',
|
||||||
|
Loading…
Reference in New Issue
Block a user