Bugfix in seasonal.partitioners for DateTime.day_of_week

This commit is contained in:
Petrônio Cândido 2019-01-28 14:01:24 -02:00
parent 85ff48f48f
commit e36ce6692e
3 changed files with 16 additions and 2 deletions

View File

@ -76,3 +76,9 @@ class FuzzySet(FuzzySet.FuzzySet):
if self.centroid is None or self.centroid < set.centroid: if self.centroid is None or self.centroid < set.centroid:
self.centroid = set.centroid self.centroid = set.centroid
def __str__(self):
tmp = str([str(k) for k in self.sets])
return "{}: {}".format(self.name, tmp)

View File

@ -50,6 +50,11 @@ class TimeGridPartitioner(partitioner.Partitioner):
if self.season == DateTime.year: if self.season == DateTime.year:
dlen = (self.max - self.min) dlen = (self.max - self.min)
partlen = dlen / self.partitions partlen = dlen / self.partitions
elif self.season == DateTime.day_of_week:
self.min = 1
self.max = 8
partlen = 1
pl2 = 1
else: else:
partlen = self.season.value / self.partitions partlen = self.season.value / self.partitions
pl2 = partlen / 2 pl2 = partlen / 2

View File

@ -103,13 +103,16 @@ dataset['date'] = pd.to_datetime(dataset["date"], format='%Y-%m-%d %H:%M:%S')
train_mv = dataset.iloc[:24505] train_mv = dataset.iloc[:24505]
test_mv = dataset.iloc[24505:] test_mv = dataset.iloc[24505:]
sp = {'seasonality': DateTime.minute_of_day, 'names': [str(k)+'hs' for k in range(0,24)]}
sp = {'seasonality': DateTime.day_of_week, 'names': ['mon','tue','wed','tur','fri','sat','sun']} sp = {'seasonality': DateTime.day_of_week, 'names': ['mon','tue','wed','tur','fri','sat','sun']}
vday = variable.Variable("DayOfWeek", data_label="date", partitioner=seasonal.TimeGridPartitioner, npart=7, vday = variable.Variable("DayOfWeek", data_label="date", partitioner=seasonal.TimeGridPartitioner, npart=7,
data=train_mv, partitioner_specific=sp) data=train_mv, partitioner_specific=sp)
print(vday.partitioner)
sp = {'seasonality': DateTime.minute_of_day, 'names': [str(k)+'hs' for k in range(0,24)]}
vhour = variable.Variable("Hour", data_label="date", partitioner=seasonal.TimeGridPartitioner, npart=24, vhour = variable.Variable("Hour", data_label="date", partitioner=seasonal.TimeGridPartitioner, npart=24,
data=train_mv, partitioner_specific=sp, data_type=pd.datetime, mask='%Y-%m-%d %H:%M:%S') data=train_mv, partitioner_specific=sp, data_type=pd.datetime, mask='%Y-%m-%d %H:%M:%S')