Bugfixes in MVFTS and DEHO
This commit is contained in:
parent
876de2721d
commit
5b7e4edcd7
@ -75,9 +75,14 @@ def random_genotype(**kwargs):
|
|||||||
explanatory_params = []
|
explanatory_params = []
|
||||||
|
|
||||||
for v in explanatory_variables:
|
for v in explanatory_variables:
|
||||||
|
var = vars[v]
|
||||||
|
if var['type'] == 'common':
|
||||||
|
npart = random.randint(7, 50)
|
||||||
|
else:
|
||||||
|
npart = var['npart']
|
||||||
param = {
|
param = {
|
||||||
'mf': random.randint(1, 4),
|
'mf': random.randint(1, 4),
|
||||||
'npart': random.randint(10, 50),
|
'npart': npart,
|
||||||
'partitioner': 1, #random.randint(1, 2),
|
'partitioner': 1, #random.randint(1, 2),
|
||||||
'alpha': random.uniform(0, .5)
|
'alpha': random.uniform(0, .5)
|
||||||
}
|
}
|
||||||
@ -85,7 +90,7 @@ def random_genotype(**kwargs):
|
|||||||
|
|
||||||
target_params = {
|
target_params = {
|
||||||
'mf': random.randint(1, 4),
|
'mf': random.randint(1, 4),
|
||||||
'npart': random.randint(10, 50),
|
'npart': random.randint(7, 50),
|
||||||
'partitioner': 1, #random.randint(1, 2),
|
'partitioner': 1, #random.randint(1, 2),
|
||||||
'alpha': random.uniform(0, .5)
|
'alpha': random.uniform(0, .5)
|
||||||
}
|
}
|
||||||
@ -133,6 +138,8 @@ def phenotype(individual, train, fts_method, parameters={}, **kwargs):
|
|||||||
partitioner_specific={'mf': mf}, npart=tparams['npart'], alpha_cut=tparams['alpha'],
|
partitioner_specific={'mf': mf}, npart=tparams['npart'], alpha_cut=tparams['alpha'],
|
||||||
data=train)
|
data=train)
|
||||||
|
|
||||||
|
explanatory_vars.append(target_var)
|
||||||
|
|
||||||
model = fts_method(explanatory_variables=explanatory_vars, target_variable=target_var, **parameters)
|
model = fts_method(explanatory_variables=explanatory_vars, target_variable=target_var, **parameters)
|
||||||
model.fit(train, **parameters)
|
model.fit(train, **parameters)
|
||||||
|
|
||||||
@ -171,6 +178,7 @@ def evaluate(dataset, individual, **kwargs):
|
|||||||
:param parameters: dict with model specific arguments for fit method.
|
:param parameters: dict with model specific arguments for fit method.
|
||||||
:return: a tuple (len_lags, rmse) with the parsimony fitness value and the accuracy fitness value
|
:return: a tuple (len_lags, rmse) with the parsimony fitness value and the accuracy fitness value
|
||||||
"""
|
"""
|
||||||
|
import logging
|
||||||
from pyFTS.models import hofts, ifts, pwfts
|
from pyFTS.models import hofts, ifts, pwfts
|
||||||
from pyFTS.common import Util
|
from pyFTS.common import Util
|
||||||
from pyFTS.benchmarks import Measures
|
from pyFTS.benchmarks import Measures
|
||||||
|
@ -2,7 +2,7 @@ from pyFTS.common import FuzzySet, Membership
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from scipy.spatial import KDTree
|
from scipy.spatial import KDTree
|
||||||
import matplotlib.pylab as plt
|
import matplotlib.pylab as plt
|
||||||
|
import logging
|
||||||
|
|
||||||
class Partitioner(object):
|
class Partitioner(object):
|
||||||
"""
|
"""
|
||||||
@ -154,7 +154,6 @@ class Partitioner(object):
|
|||||||
method = kwargs.get('method', 'fuzzy')
|
method = kwargs.get('method', 'fuzzy')
|
||||||
|
|
||||||
nearest = self.search(data, type='index')
|
nearest = self.search(data, type='index')
|
||||||
|
|
||||||
mv = np.zeros(self.partitions)
|
mv = np.zeros(self.partitions)
|
||||||
|
|
||||||
for ix in nearest:
|
for ix in nearest:
|
||||||
@ -317,16 +316,20 @@ class Partitioner(object):
|
|||||||
it represents the fuzzy set name.
|
it represents the fuzzy set name.
|
||||||
:return: the fuzzy set
|
:return: the fuzzy set
|
||||||
"""
|
"""
|
||||||
if isinstance(item, (int, np.int, np.int8, np.int16, np.int32, np.int64)):
|
try:
|
||||||
if item < 0 or item >= self.partitions:
|
if isinstance(item, (int, np.int, np.int8, np.int16, np.int32, np.int64)):
|
||||||
raise ValueError("The fuzzy set index must be between 0 and {}.".format(self.partitions))
|
if item < 0 or item >= self.partitions:
|
||||||
return self.sets[self.ordered_sets[item]]
|
raise ValueError("The fuzzy set index must be between 0 and {}.".format(self.partitions))
|
||||||
elif isinstance(item, str):
|
return self.sets[self.ordered_sets[item]]
|
||||||
if item not in self.sets:
|
elif isinstance(item, str):
|
||||||
raise ValueError("The fuzzy set with name {} does not exist.".format(item))
|
if item not in self.sets:
|
||||||
return self.sets[item]
|
raise ValueError("The fuzzy set with name {} does not exist.".format(item))
|
||||||
else:
|
return self.sets[item]
|
||||||
raise ValueError("The parameter 'item' must be an integer or a string and the value informed was {} of type {}!".format(item, type(item)))
|
else:
|
||||||
|
raise ValueError("The parameter 'item' must be an integer or a string and the value informed was {} of type {}!".format(item, type(item)))
|
||||||
|
except Exception as ex:
|
||||||
|
logging.exception("Error")
|
||||||
|
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
"""
|
"""
|
||||||
|
@ -17,7 +17,7 @@ def get_dataset():
|
|||||||
data['time'] = pd.to_datetime(data["time"], format='%m/%d/%y %I:%M %p')
|
data['time'] = pd.to_datetime(data["time"], format='%m/%d/%y %I:%M %p')
|
||||||
|
|
||||||
#return 'SONDA.ws_10m', data
|
#return 'SONDA.ws_10m', data
|
||||||
return 'Malaysia', data.iloc[:5000] #train, test
|
return 'Malaysia', data.iloc[:2000] #train, test
|
||||||
#return 'Malaysia.temperature', data # train, test
|
#return 'Malaysia.temperature', data # train, test
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -47,7 +47,6 @@ datsetname, dataset = get_dataset()
|
|||||||
# window_size=10000, train_rate=.9, increment_rate=1,)
|
# window_size=10000, train_rate=.9, increment_rate=1,)
|
||||||
|
|
||||||
explanatory_variables =[
|
explanatory_variables =[
|
||||||
{'name': 'Load', 'data_label': 'load', 'type': 'common'},
|
|
||||||
{'name': 'Temperature', 'data_label': 'temperature', 'type': 'common'},
|
{'name': 'Temperature', 'data_label': 'temperature', 'type': 'common'},
|
||||||
{'name': 'Daily', 'data_label': 'time', 'type': 'seasonal', 'seasonality': DateTime.minute_of_day, 'npart': 24 },
|
{'name': 'Daily', 'data_label': 'time', 'type': 'seasonal', 'seasonality': DateTime.minute_of_day, 'npart': 24 },
|
||||||
{'name': 'Weekly', 'data_label': 'time', 'type': 'seasonal', 'seasonality': DateTime.day_of_week, 'npart': 7 },
|
{'name': 'Weekly', 'data_label': 'time', 'type': 'seasonal', 'seasonality': DateTime.day_of_week, 'npart': 7 },
|
||||||
@ -59,13 +58,13 @@ target_variable = {'name': 'Load', 'data_label': 'load', 'type': 'common'}
|
|||||||
nodes=['192.168.28.38']
|
nodes=['192.168.28.38']
|
||||||
deho_mv.execute(datsetname, dataset,
|
deho_mv.execute(datsetname, dataset,
|
||||||
ngen=10, npop=10,psel=0.6, pcross=.5, pmut=.3,
|
ngen=10, npop=10,psel=0.6, pcross=.5, pmut=.3,
|
||||||
window_size=5000, train_rate=.9, increment_rate=1,
|
window_size=2000, train_rate=.9, increment_rate=1,
|
||||||
experiments=1,
|
experiments=1,
|
||||||
fts_method=wmvfts.WeightedMVFTS,
|
fts_method=wmvfts.WeightedMVFTS,
|
||||||
variables=explanatory_variables,
|
variables=explanatory_variables,
|
||||||
target_variable=target_variable,
|
target_variable=target_variable,
|
||||||
distributed='dispy', nodes=nodes,
|
#distributed='dispy', nodes=nodes,
|
||||||
#parameters=dict(num_batches=5)
|
parameters=dict(num_batches=5)
|
||||||
#parameters=dict(distributed='dispy', nodes=nodes, num_batches=5)
|
#parameters=dict(distributed='dispy', nodes=nodes, num_batches=5)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ from pyFTS.data import Malaysia, Enrollments
|
|||||||
df = Malaysia.get_dataframe()
|
df = Malaysia.get_dataframe()
|
||||||
df['time'] = pd.to_datetime(df["time"], format='%m/%d/%y %I:%M %p')
|
df['time'] = pd.to_datetime(df["time"], format='%m/%d/%y %I:%M %p')
|
||||||
|
|
||||||
train_mv = df.iloc[:4500]
|
train_mv = df.iloc[:1800]
|
||||||
test_mv = df.iloc[4500:5000]
|
test_mv = df.iloc[1800:2000]
|
||||||
|
|
||||||
del(df)
|
del(df)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user