2017-02-24 20:29:55 +04:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf8 -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
import numpy as np
|
|
|
|
import pandas as pd
|
|
|
|
import matplotlib as plt
|
|
|
|
import matplotlib.pyplot as plt
|
2017-05-24 07:31:05 +04:00
|
|
|
#from mpl_toolkits.mplot3d import Axes3D
|
2017-02-24 20:29:55 +04:00
|
|
|
|
|
|
|
import pandas as pd
|
2017-02-27 22:53:29 +04:00
|
|
|
from pyFTS.partitioners import Grid, Entropy, FCM, Huarng
|
2017-07-02 02:42:45 +04:00
|
|
|
from pyFTS.common import FLR,FuzzySet,Membership,Transformations, Util as cUtil
|
2017-03-03 15:53:55 +04:00
|
|
|
from pyFTS import fts,hofts,ifts,pwfts,tree, chen
|
2017-05-03 00:16:49 +04:00
|
|
|
#from pyFTS.benchmarks import benchmarks as bchmk
|
2017-03-03 15:53:55 +04:00
|
|
|
from pyFTS.benchmarks import naive, arima
|
2017-02-24 20:29:55 +04:00
|
|
|
from pyFTS.benchmarks import Measures
|
|
|
|
from numpy import random
|
2017-05-22 07:44:07 +04:00
|
|
|
from pyFTS.models.seasonal import SeasonalIndexer
|
2017-02-24 20:29:55 +04:00
|
|
|
|
2017-05-07 00:04:37 +04:00
|
|
|
os.chdir("/home/petronio/dados/Dropbox/Doutorado/Codigos/")
|
|
|
|
|
2017-07-04 23:30:53 +04:00
|
|
|
diff = Transformations.Differential(1)
|
2017-07-02 02:42:45 +04:00
|
|
|
#ix = SeasonalIndexer.LinearSeasonalIndexer([12, 24], [720, 1],[False, False])
|
2017-05-14 15:54:41 +04:00
|
|
|
|
2017-05-14 04:03:49 +04:00
|
|
|
"""
|
|
|
|
DATASETS
|
|
|
|
"""
|
2017-02-24 20:29:55 +04:00
|
|
|
|
2017-05-22 01:04:10 +04:00
|
|
|
#enrollments = pd.read_csv("DataSets/Enrollments.csv", sep=";")
|
|
|
|
#enrollments = np.array(enrollments["Enrollments"])
|
|
|
|
|
2017-05-20 20:43:39 +04:00
|
|
|
#passengers = pd.read_csv("DataSets/AirPassengers.csv", sep=",")
|
|
|
|
#passengers = np.array(passengers["Passengers"])
|
2017-05-17 17:45:10 +04:00
|
|
|
|
|
|
|
#sunspots = pd.read_csv("DataSets/sunspots.csv", sep=",")
|
|
|
|
#sunspots = np.array(sunspots["SUNACTIVITY"])
|
|
|
|
|
2017-05-08 20:12:08 +04:00
|
|
|
#gauss = random.normal(0,1.0,5000)
|
2017-02-24 20:29:55 +04:00
|
|
|
#gauss_teste = random.normal(0,1.0,400)
|
|
|
|
|
2017-05-22 01:04:10 +04:00
|
|
|
#taiexpd = pd.read_csv("DataSets/TAIEX.csv", sep=",")
|
|
|
|
#taiex = np.array(taiexpd["avg"][:5000])
|
2017-05-24 07:31:05 +04:00
|
|
|
#del(taiexpd)
|
2017-05-08 20:12:08 +04:00
|
|
|
|
2017-05-17 17:45:10 +04:00
|
|
|
#nasdaqpd = pd.read_csv("DataSets/NASDAQ_IXIC.csv", sep=",")
|
|
|
|
#nasdaq = np.array(nasdaqpd["avg"][0:5000])
|
2017-05-24 07:31:05 +04:00
|
|
|
#del(nasdaqpd)
|
2017-02-27 22:53:29 +04:00
|
|
|
|
2017-05-14 04:03:49 +04:00
|
|
|
#sp500pd = pd.read_csv("DataSets/S&P500.csv", sep=",")
|
|
|
|
#sp500 = np.array(sp500pd["Avg"][11000:])
|
|
|
|
#del(sp500pd)
|
2017-04-13 19:36:22 +04:00
|
|
|
|
2017-05-24 07:31:05 +04:00
|
|
|
#sondapd = pd.read_csv("DataSets/SONDA_BSB_HOURLY_AVG.csv", sep=";")
|
|
|
|
#sondapd = sondapd.dropna(axis=0, how='any')
|
|
|
|
#sonda = np.array(sondapd["glo_avg"])
|
|
|
|
#del(sondapd)
|
2017-04-13 19:36:22 +04:00
|
|
|
|
2017-06-18 00:30:24 +04:00
|
|
|
#bestpd = pd.read_csv("DataSets/BEST_TAVG.csv", sep=";")
|
|
|
|
#best = np.array(bestpd["Anomaly"])
|
|
|
|
#del(bestpd)
|
2017-04-13 19:36:22 +04:00
|
|
|
|
2017-05-03 00:16:49 +04:00
|
|
|
#print(lag)
|
|
|
|
#print(a)
|
2017-07-05 22:35:22 +04:00
|
|
|
#'''
|
|
|
|
sonda = pd.read_csv("DataSets/SONDA_BSB_15MIN_AVG.csv", sep=";")
|
2017-07-02 02:42:45 +04:00
|
|
|
|
|
|
|
sonda['data'] = pd.to_datetime(sonda['data'])
|
|
|
|
|
2017-07-05 22:35:22 +04:00
|
|
|
#sonda = sonda[:][527041:].dropna()
|
2017-07-02 02:42:45 +04:00
|
|
|
|
|
|
|
sonda.index = np.arange(0,len(sonda.index))
|
|
|
|
|
2017-07-05 22:35:22 +04:00
|
|
|
sonda_treino = sonda[:105313].dropna()
|
|
|
|
sonda_teste = sonda[105314:].dropna()
|
|
|
|
|
|
|
|
#ix_m15 = SeasonalIndexer.DateTimeSeasonalIndexer('data',[SeasonalIndexer.DateTime.minute],[15],'glo_avg', name='m15')
|
|
|
|
|
|
|
|
#fs1 = Grid.GridPartitioner(sonda_treino, 50, transformation=diff, indexer=ix_m15)
|
|
|
|
|
|
|
|
#ix = cUtil.load_obj("models/sonda_ix_Mhm15.pkl")
|
|
|
|
|
|
|
|
#fs = cUtil.load_obj("models/sonda_fs_Entropy40_diff.pkl")
|
|
|
|
|
|
|
|
#from pyFTS.models import msfts
|
|
|
|
|
|
|
|
#obj = msfts.MultiSeasonalFTS("sonda_msfts_Entropy40_Mhm15", indexer=ix)
|
|
|
|
|
|
|
|
#obj.appendTransformation(diff)
|
2017-07-04 23:30:53 +04:00
|
|
|
|
2017-07-05 22:35:22 +04:00
|
|
|
#obj.train(sonda_treino, fs.sets)
|
2017-07-04 23:30:53 +04:00
|
|
|
|
2017-07-05 22:35:22 +04:00
|
|
|
#cUtil.persist_obj(obj, "models/sonda_msfts_Entropy40_Mhm15.pkl")
|
2017-07-04 23:30:53 +04:00
|
|
|
|
2017-07-05 22:35:22 +04:00
|
|
|
ftse = cUtil.load_obj("models/sonda_ensemble_msfts.pkl")
|
|
|
|
|
|
|
|
tmp = ftse.forecastDistribution(sonda_teste[850:860], h=0.5, method="gaussian")
|
|
|
|
|
|
|
|
print(tmp[0])
|
|
|
|
|
|
|
|
#'''
|
2017-07-02 02:42:45 +04:00
|
|
|
|
2017-07-04 19:18:07 +04:00
|
|
|
'''
|
2017-07-02 02:42:45 +04:00
|
|
|
from pyFTS.models.seasonal import SeasonalIndexer
|
|
|
|
|
2017-07-04 01:39:10 +04:00
|
|
|
indexers = []
|
2017-07-02 02:42:45 +04:00
|
|
|
|
2017-07-04 23:30:53 +04:00
|
|
|
for i in ["models/sonda_ix_Mhm15.pkl"]: #, "models/sonda_ix_m15.pkl", "models/sonda_ix_Mh.pkl", ]:
|
2017-07-04 01:39:10 +04:00
|
|
|
obj = cUtil.load_obj(i)
|
|
|
|
indexers.append( obj )
|
|
|
|
print(obj)
|
2017-07-02 02:42:45 +04:00
|
|
|
|
2017-07-04 01:39:10 +04:00
|
|
|
partitioners = []
|
2017-07-02 02:42:45 +04:00
|
|
|
|
2017-07-04 23:30:53 +04:00
|
|
|
transformations = [""] #, "_diff"]
|
|
|
|
for max_part in [30, 40, 50, 60, 70, 80, 90]:
|
2017-07-04 01:39:10 +04:00
|
|
|
for t in transformations:
|
|
|
|
obj = cUtil.load_obj("models/sonda_fs_grid_" + str(max_part) + t + ".pkl")
|
|
|
|
partitioners.append( obj )
|
|
|
|
print(obj)
|
2017-07-02 02:42:45 +04:00
|
|
|
|
|
|
|
|
2017-07-04 19:18:07 +04:00
|
|
|
from pyFTS.ensemble import ensemble, multiseasonal
|
2017-07-02 02:42:45 +04:00
|
|
|
|
2017-07-04 23:30:53 +04:00
|
|
|
fts = multiseasonal.SeasonalEnsembleFTS("sonda_msfts_Mhm15")
|
2017-07-02 02:42:45 +04:00
|
|
|
|
2017-07-04 01:39:10 +04:00
|
|
|
fts.indexers = indexers
|
|
|
|
fts.partitioners = partitioners
|
2017-07-02 02:42:45 +04:00
|
|
|
|
2017-07-04 23:30:53 +04:00
|
|
|
fts.indexer = indexers[0]
|
|
|
|
|
2017-07-04 01:39:10 +04:00
|
|
|
fts.train(sonda_treino, sets=None)
|
2017-07-04 19:18:07 +04:00
|
|
|
'''
|
2017-07-04 23:30:53 +04:00
|
|
|
#'''
|
|
|
|
|
|
|
|
#ix = cUtil.load_obj("models/sonda_ix_m15.pkl")
|
|
|
|
|
|
|
|
#ftse = cUtil.load_obj("models/msfts_Grid40_diff_Mhm15.pkl")
|
2017-07-02 02:42:45 +04:00
|
|
|
|
2017-07-04 23:30:53 +04:00
|
|
|
#ftse.indexer = ix
|
2017-07-02 02:42:45 +04:00
|
|
|
|
2017-07-04 23:30:53 +04:00
|
|
|
#ftse.update_uod(sonda_treino)
|
|
|
|
|
|
|
|
#tmp = ftse.forecastDistribution(sonda_teste,h=1)
|
|
|
|
|
|
|
|
#tmp = ftse.forecast(sonda_teste,h=1)
|
|
|
|
|
|
|
|
#tmp[5].plot()
|
|
|
|
#'''
|
|
|
|
|
|
|
|
'''
|
2017-05-24 07:31:05 +04:00
|
|
|
from pyFTS.benchmarks import benchmarks as bchmk
|
|
|
|
#from pyFTS.benchmarks import distributed_benchmarks as bchmk
|
2017-04-06 06:45:11 +04:00
|
|
|
#from pyFTS.benchmarks import parallel_benchmarks as bchmk
|
2017-05-08 20:12:08 +04:00
|
|
|
from pyFTS.benchmarks import Util
|
2017-05-14 08:19:49 +04:00
|
|
|
from pyFTS.benchmarks import arima, quantreg, Measures
|
2017-04-13 19:36:22 +04:00
|
|
|
|
2017-05-10 02:04:51 +04:00
|
|
|
#Util.cast_dataframe_to_synthetic_point("experiments/taiex_point_analitic.csv","experiments/taiex_point_sintetic.csv",11)
|
2017-05-08 20:12:08 +04:00
|
|
|
|
2017-05-08 21:49:45 +04:00
|
|
|
#Util.plot_dataframe_point("experiments/taiex_point_sintetic.csv","experiments/taiex_point_analitic.csv",11)
|
2017-05-20 20:43:39 +04:00
|
|
|
"""
|
2017-05-17 23:58:51 +04:00
|
|
|
arima100 = arima.ARIMA("", alpha=0.25)
|
2017-05-14 15:54:41 +04:00
|
|
|
#tmp.appendTransformation(diff)
|
2017-05-17 23:58:51 +04:00
|
|
|
arima100.train(passengers, None, order=(1,0,0))
|
|
|
|
|
|
|
|
arima101 = arima.ARIMA("", alpha=0.25)
|
|
|
|
#tmp.appendTransformation(diff)
|
|
|
|
arima101.train(passengers, None, order=(1,0,1))
|
|
|
|
|
|
|
|
arima200 = arima.ARIMA("", alpha=0.25)
|
|
|
|
#tmp.appendTransformation(diff)
|
|
|
|
arima200.train(passengers, None, order=(2,0,0))
|
|
|
|
|
|
|
|
arima201 = arima.ARIMA("", alpha=0.25)
|
|
|
|
#tmp.appendTransformation(diff)
|
|
|
|
arima201.train(passengers, None, order=(2,0,1))
|
2017-04-13 19:36:22 +04:00
|
|
|
|
2017-05-09 00:50:35 +04:00
|
|
|
|
2017-05-17 17:45:10 +04:00
|
|
|
#tmp = quantreg.QuantileRegression("", alpha=0.25, dist=True)
|
2017-05-15 21:06:26 +04:00
|
|
|
#tmp.appendTransformation(diff)
|
2017-05-17 17:45:10 +04:00
|
|
|
#tmp.train(sunspots[:150], None, order=1)
|
|
|
|
#teste = tmp.forecastAheadInterval(sunspots[150:155], 5)
|
2017-05-15 21:06:26 +04:00
|
|
|
#teste = tmp.forecastAheadDistribution(nasdaq[1600:1604], steps=5, resolution=50)
|
2017-04-01 03:34:12 +04:00
|
|
|
|
2017-05-17 17:45:10 +04:00
|
|
|
bchmk.plot_compared_series(enrollments,[tmp], ['blue','red'], points=False, intervals=True)
|
|
|
|
|
|
|
|
#print(sunspots[150:155])
|
|
|
|
#print(teste)
|
2017-05-14 15:54:41 +04:00
|
|
|
|
2017-05-15 21:06:26 +04:00
|
|
|
#kk = Measures.get_interval_statistics(nasdaq[1600:1605], tmp)
|
2017-04-06 06:45:11 +04:00
|
|
|
|
2017-05-15 21:06:26 +04:00
|
|
|
#print(kk)
|
2017-05-24 07:31:05 +04:00
|
|
|
"""
|
2017-05-14 15:54:41 +04:00
|
|
|
|
2017-05-10 02:04:51 +04:00
|
|
|
|
2017-05-14 04:37:10 +04:00
|
|
|
"""
|
2017-05-14 04:03:49 +04:00
|
|
|
bchmk.point_sliding_window(sonda, 9000, train=0.8, inc=0.4,#models=[yu.WeightedFTS], # #
|
2017-05-08 21:49:45 +04:00
|
|
|
partitioners=[Grid.GridPartitioner], #Entropy.EntropyPartitioner], # FCM.FCMPartitioner, ],
|
2017-05-14 04:03:49 +04:00
|
|
|
partitions= np.arange(10,200,step=10), #transformation=diff,
|
|
|
|
dump=True, save=True, file="experiments/sondaws_point_analytic.csv",
|
|
|
|
nodes=['192.168.0.103', '192.168.0.106', '192.168.0.108', '192.168.0.109']) #, depends=[hofts, ifts])
|
2017-04-06 06:45:11 +04:00
|
|
|
|
2017-05-14 05:32:40 +04:00
|
|
|
|
2017-05-09 17:27:47 +04:00
|
|
|
|
2017-05-14 04:03:49 +04:00
|
|
|
bchmk.point_sliding_window(sonda, 9000, train=0.8, inc=0.4, #models=[yu.WeightedFTS], # #
|
2017-05-09 17:27:47 +04:00
|
|
|
partitioners=[Grid.GridPartitioner], #Entropy.EntropyPartitioner], # FCM.FCMPartitioner, ],
|
2017-05-14 04:03:49 +04:00
|
|
|
partitions= np.arange(3,20,step=2), #transformation=diff,
|
|
|
|
dump=True, save=True, file="experiments/sondaws_point_analytic_diff.csv",
|
|
|
|
nodes=['192.168.0.103', '192.168.0.106', '192.168.0.108', '192.168.0.109']) #, depends=[hofts, ifts])
|
2017-05-15 21:06:26 +04:00
|
|
|
|
|
|
|
|
2017-05-24 07:31:05 +04:00
|
|
|
|
|
|
|
|
2017-03-03 15:53:55 +04:00
|
|
|
|
2017-05-15 21:06:26 +04:00
|
|
|
bchmk.interval_sliding_window(best, 5000, train=0.8, inc=0.8,#models=[yu.WeightedFTS], # #
|
2017-05-14 05:32:40 +04:00
|
|
|
partitioners=[Grid.GridPartitioner], #Entropy.EntropyPartitioner], # FCM.FCMPartitioner, ],
|
2017-05-15 21:06:26 +04:00
|
|
|
partitions= np.arange(10,200,step=10),
|
|
|
|
dump=True, save=True, file="experiments/best"
|
|
|
|
"_interval_analytic.csv",
|
2017-05-14 05:32:40 +04:00
|
|
|
nodes=['192.168.0.103', '192.168.0.106', '192.168.0.108', '192.168.0.109']) #, depends=[hofts, ifts])
|
|
|
|
|
2017-05-24 07:31:05 +04:00
|
|
|
|
|
|
|
|
|
|
|
bchmk.interval_sliding_window(taiex, 2000, train=0.8, inc=0.1, #models=[yu.WeightedFTS], # #
|
2017-05-14 05:32:40 +04:00
|
|
|
partitioners=[Grid.GridPartitioner], #Entropy.EntropyPartitioner], # FCM.FCMPartitioner, ],
|
2017-05-14 15:54:41 +04:00
|
|
|
partitions= np.arange(3,20,step=2), transformation=diff,
|
2017-05-24 07:31:05 +04:00
|
|
|
dump=True, save=True, file="experiments/taiex_interval_analytic_diff.csv",
|
2017-05-14 05:32:40 +04:00
|
|
|
nodes=['192.168.0.103', '192.168.0.106', '192.168.0.108', '192.168.0.109']) #, depends=[hofts, ifts])
|
|
|
|
|
2017-05-14 08:19:49 +04:00
|
|
|
|
2017-05-22 01:04:10 +04:00
|
|
|
|
2017-05-24 07:31:05 +04:00
|
|
|
|
|
|
|
|
|
|
|
bchmk.ahead_sliding_window(sonda, 10000, steps=10, resolution=10, train=0.2, inc=0.2,
|
2017-05-20 20:43:39 +04:00
|
|
|
partitioners=[Grid.GridPartitioner],
|
2017-05-22 07:44:07 +04:00
|
|
|
partitions= np.arange(10,200,step=10), indexer=ix,
|
2017-05-24 07:31:05 +04:00
|
|
|
dump=True, save=True, file="experiments/sondawind_ahead_analytic.csv",
|
2017-05-22 01:04:10 +04:00
|
|
|
nodes=['192.168.0.106', '192.168.0.108', '192.168.0.109']) #, depends=[hofts, ifts])
|
|
|
|
|
2017-05-20 20:43:39 +04:00
|
|
|
|
2017-05-24 07:31:05 +04:00
|
|
|
bchmk.ahead_sliding_window(sonda, 10000, steps=10, resolution=10, train=0.2, inc=0.2,
|
2017-05-20 20:43:39 +04:00
|
|
|
partitioners=[Grid.GridPartitioner],
|
2017-05-22 07:44:07 +04:00
|
|
|
partitions= np.arange(3,20,step=2), transformation=diff, indexer=ix,
|
2017-05-24 07:31:05 +04:00
|
|
|
dump=True, save=True, file="experiments/sondawind_ahead_analytic_diff.csv",
|
2017-05-22 01:04:10 +04:00
|
|
|
nodes=['192.168.0.106', '192.168.0.108', '192.168.0.109']) #, depends=[hofts, ifts])
|
2017-05-20 20:43:39 +04:00
|
|
|
|
2017-07-05 22:35:22 +04:00
|
|
|
|
2017-05-24 07:31:05 +04:00
|
|
|
|
|
|
|
from pyFTS import pwfts
|
|
|
|
from pyFTS.common import Transformations
|
|
|
|
from pyFTS.partitioners import Grid
|
|
|
|
|
2017-06-18 00:30:24 +04:00
|
|
|
#diff = Transformations.Differential(1)
|
|
|
|
#fs = Grid.GridPartitioner(best, 190) #, transformation=diff)
|
2017-05-24 07:31:05 +04:00
|
|
|
|
|
|
|
|
2017-06-18 00:30:24 +04:00
|
|
|
#model = pwfts.ProbabilisticWeightedFTS("FTS 1")
|
2017-05-24 07:31:05 +04:00
|
|
|
#model.appendTransformation(diff)
|
2017-06-18 00:30:24 +04:00
|
|
|
#model.train(best[0:1600],fs.sets, order=3)
|
|
|
|
|
|
|
|
#bchmk.plot_compared_intervals_ahead(best[1600:1700],[model], ['blue','red'],
|
|
|
|
# distributions=[True], save=True, file="pictures/best_ahead_forecasts",
|
|
|
|
# time_from=40, time_to=60, resolution=100)
|
2017-07-05 22:35:22 +04:00
|
|
|
|
2017-06-18 00:30:24 +04:00
|
|
|
experiments = [
|
|
|
|
["experiments/taiex_point_synthetic_diff.csv","experiments/taiex_point_analytic_diff.csv",16],
|
|
|
|
["experiments/nasdaq_point_synthetic_diff.csv","experiments/nasdaq_point_analytic_diff.csv", 11],
|
|
|
|
["experiments/sp500_point_synthetic_diff.csv","experiments/sp500_point_analytic_diff.csv", 21],
|
|
|
|
["experiments/best_point_synthetic_diff.csv","experiments/best_point_analytic_diff.csv", 13],
|
|
|
|
["experiments/sondasun_point_synthetic_diff.csv","experiments/sondasun_point_analytic_diff.csv", 15],
|
|
|
|
["experiments/sondawind_point_synthetic_diff.csv","experiments/sondawind_point_analytic_diff.csv", 8],
|
|
|
|
["experiments/gauss_point_synthetic_diff.csv","experiments/gauss_point_analytic_diff.csv", 16]
|
|
|
|
]
|
|
|
|
|
|
|
|
Util.unified_scaled_point(experiments,tam=[15,8],save=True,file="pictures/unified_experiments_point.png",
|
|
|
|
ignore=['ARIMA(1,0,0)','ARIMA(2,0,0)','ARIMA(2,0,1)','ARIMA(2,0,2)','QAR(2)'],
|
|
|
|
replace=[['ARIMA','ARIMA'],['QAR','QAR']])
|
|
|
|
'''
|
|
|
|
|
|
|
|
'''
|
|
|
|
experiments = [
|
|
|
|
["experiments/taiex_interval_synthetic.csv","experiments/taiex_interval_analytic.csv",16],
|
|
|
|
["experiments/nasdaq_interval_synthetic_diff.csv","experiments/nasdaq_interval_analytic_diff.csv",11],
|
|
|
|
["experiments/sp500_interval_synthetic_diff.csv","experiments/sp500_interval_analytic_diff.csv", 11],
|
|
|
|
["experiments/best_interval_synthetic_diff.csv","experiments/best_interval_analytic_diff.csv",13],
|
|
|
|
["experiments/sondasun_interval_synthetic_diff.csv","experiments/sondasun_interval_analytic_diff.csv",8],
|
|
|
|
["experiments/sondawind_interval_synthetic_diff.csv","experiments/sondawind_interval_analytic_diff.csv",8],
|
|
|
|
["experiments/gauss_interval_synthetic_diff.csv","experiments/gauss_interval_analytic_diff.csv", 8]
|
|
|
|
]
|
|
|
|
|
|
|
|
Util.unified_scaled_interval(experiments,tam=[15,8],save=True,file="pictures/unified_experiments_interval.png",
|
|
|
|
ignore=['ARIMA(1,0,0)', 'ARIMA(2,0,0)', 'ARIMA(2,0,1)', 'ARIMA(2,0,2)', 'QAR(2)'],
|
|
|
|
replace=[['ARIMA(1,0,1) - 0.05', 'ARIMA 0.05'], ['ARIMA(1,0,1) - 0.25', 'ARIMA 0.25'],
|
|
|
|
['QAR(1) - 0.05', 'QAR 0.05'], ['QAR(1) - 0.25', 'QAR 0.25']])
|
|
|
|
|
|
|
|
Util.unified_scaled_interval_pinball(experiments,tam=[15,8],save=True,file="pictures/unified_experiments_interval_pinball.png",
|
|
|
|
ignore=['ARIMA(1,0,0)', 'ARIMA(2,0,0)', 'ARIMA(2,0,1)', 'ARIMA(2,0,2)', 'QAR(2)'],
|
|
|
|
replace=[['ARIMA(1,0,1) - 0.05', 'ARIMA 0.05'], ['ARIMA(1,0,1) - 0.25', 'ARIMA 0.25'],
|
|
|
|
['QAR(1) - 0.05', 'QAR 0.05'], ['QAR(1) - 0.25', 'QAR 0.25']])
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
2017-07-02 02:42:45 +04:00
|
|
|
'''
|
2017-06-18 00:30:24 +04:00
|
|
|
experiments = [
|
2017-07-02 02:42:45 +04:00
|
|
|
["experiments/taiex_ahead_synthetic_diff.csv","experiments/taiex_ahead_analytic_diff.csv",16],
|
|
|
|
["experiments/nasdaq_ahead_synthetic_diff.csv","experiments/nasdaq_ahead_analytic_diff.csv",11],
|
|
|
|
["experiments/sp500_ahead_synthetic_diff.csv","experiments/sp500_ahead_analytic_diff.csv", 21],
|
|
|
|
["experiments/best_ahead_synthetic_diff.csv","experiments/best_ahead_analytic_diff.csv", 24],
|
|
|
|
["experiments/sondasun_ahead_synthetic_diff.csv","experiments/sondasun_ahead_analytic_diff.csv",13],
|
|
|
|
["experiments/sondawind_ahead_synthetic_diff.csv","experiments/sondawind_ahead_analytic_diff.csv", 13],
|
2017-06-18 00:30:24 +04:00
|
|
|
["experiments/gauss_ahead_synthetic_diff.csv","experiments/gauss_ahead_analytic_diff.csv",16]
|
|
|
|
]
|
|
|
|
|
|
|
|
Util.unified_scaled_ahead(experiments,tam=[15,8],save=True,file="pictures/unified_experiments_ahead.png",
|
|
|
|
ignore=['ARIMA(1,0,0)', 'ARIMA(0,0,1)', 'ARIMA(2,0,0)', 'ARIMA(2,0,1)',
|
|
|
|
'ARIMA(2,0,2)', 'QAR(2)', 'ARIMA0.05'],
|
|
|
|
replace=[['ARIMA(1,0,1) - 0.05', 'ARIMA 0.05'], ['ARIMA(1,0,1) - 0.25', 'ARIMA 0.25'],
|
|
|
|
['QAR(1) - 0.05', 'QAR 0.05'], ['QAR(1) - 0.25', 'QAR 0.25']])
|
|
|
|
|
2017-05-24 07:31:05 +04:00
|
|
|
|
|
|
|
|
2017-07-02 02:42:45 +04:00
|
|
|
'''
|
|
|
|
|
|
|
|
'''
|
2017-05-14 04:37:10 +04:00
|
|
|
from pyFTS.partitioners import Grid
|
2017-05-22 07:44:07 +04:00
|
|
|
|
2017-05-22 01:04:10 +04:00
|
|
|
from pyFTS import sfts
|
2017-03-03 15:53:55 +04:00
|
|
|
|
2017-05-22 07:44:07 +04:00
|
|
|
|
2017-05-22 01:04:10 +04:00
|
|
|
|
|
|
|
#print(ix.get_season_of_data(best[:2000]))
|
2017-02-27 22:53:29 +04:00
|
|
|
|
2017-05-22 01:04:10 +04:00
|
|
|
#print(ix.get_season_by_index(45))
|
|
|
|
|
2017-05-22 07:44:07 +04:00
|
|
|
#ix = SeasonalIndexer.LinearSeasonalIndexer([720,24],[False,True,False])
|
|
|
|
|
|
|
|
#print(ix.get_season_of_data(sonda[6500:9000])[-20:])
|
|
|
|
|
2017-05-22 01:04:10 +04:00
|
|
|
diff = Transformations.Differential(1)
|
2017-02-27 22:53:29 +04:00
|
|
|
|
2017-05-22 07:44:07 +04:00
|
|
|
fs = Grid.GridPartitioner(sonda[:9000], 10, transformation=diff)
|
|
|
|
|
|
|
|
|
2017-05-22 01:04:10 +04:00
|
|
|
tmp = sfts.SeasonalFTS("")
|
|
|
|
tmp.indexer = ix
|
2017-05-14 04:37:10 +04:00
|
|
|
tmp.appendTransformation(diff)
|
2017-02-27 22:53:29 +04:00
|
|
|
|
2017-05-22 01:04:10 +04:00
|
|
|
#tmp = pwfts.ProbabilisticWeightedFTS("")
|
|
|
|
|
|
|
|
#tmp.appendTransformation(diff)
|
|
|
|
|
2017-05-22 07:44:07 +04:00
|
|
|
tmp.train(sonda[:9000], fs.sets, order=1)
|
2017-02-24 20:29:55 +04:00
|
|
|
|
2017-05-22 07:44:07 +04:00
|
|
|
x = tmp.forecast(sonda[:1610])
|
2017-02-24 20:29:55 +04:00
|
|
|
|
2017-05-22 01:04:10 +04:00
|
|
|
#print(taiex[1600:1610])
|
2017-05-14 04:37:10 +04:00
|
|
|
print(x)
|
2017-07-02 02:42:45 +04:00
|
|
|
'''
|