2017-01-14 03:42:00 +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
|
|
|
|
from mpl_toolkits.mplot3d import Axes3D
|
|
|
|
|
|
|
|
import pandas as pd
|
|
|
|
from pyFTS.partitioners import Grid
|
2017-01-30 03:59:50 +04:00
|
|
|
from pyFTS.common import FLR,FuzzySet,Membership,Transformations
|
2017-01-24 16:40:48 +04:00
|
|
|
from pyFTS import fts,hofts,ifts,pfts,tree, chen
|
2017-01-14 03:42:00 +04:00
|
|
|
from pyFTS.benchmarks import benchmarks as bchmk
|
2017-02-01 20:54:37 +04:00
|
|
|
from pyFTS.benchmarks import Measures
|
|
|
|
from numpy import random
|
|
|
|
|
|
|
|
gauss_treino = random.normal(0,1.0,1600)
|
|
|
|
gauss_teste = random.normal(0,1.0,400)
|
2017-01-14 03:42:00 +04:00
|
|
|
|
|
|
|
|
|
|
|
os.chdir("/home/petronio/dados/Dropbox/Doutorado/Disciplinas/AdvancedFuzzyTimeSeriesModels/")
|
|
|
|
|
2017-02-01 20:54:37 +04:00
|
|
|
#enrollments = pd.read_csv("DataSets/Enrollments.csv", sep=";")
|
|
|
|
#enrollments = np.array(enrollments["Enrollments"])
|
|
|
|
|
|
|
|
#taiex = pd.read_csv("DataSets/TAIEX.csv", sep=",")
|
|
|
|
#taiex_treino = np.array(taiex["avg"][2500:3900])
|
|
|
|
#taiex_teste = np.array(taiex["avg"][3901:4500])
|
2017-01-14 03:42:00 +04:00
|
|
|
|
2017-02-01 20:54:37 +04:00
|
|
|
#nasdaq = pd.read_csv("DataSets/NASDAQ_IXIC.csv", sep=",")
|
|
|
|
#nasdaq_treino = np.array(nasdaq["avg"][0:1600])
|
|
|
|
#nasdaq_teste = np.array(nasdaq["avg"][1601:2000])
|
2017-01-30 03:59:50 +04:00
|
|
|
|
2017-02-01 20:54:37 +04:00
|
|
|
diff = Transformations.Differential(1)
|
|
|
|
|
2017-02-15 05:01:44 +04:00
|
|
|
fs = Grid.GridPartitionerTrimf(gauss_treino,10)
|
2017-01-24 16:40:48 +04:00
|
|
|
|
|
|
|
#tmp = chen.ConventionalFTS("")
|
2017-01-14 03:42:00 +04:00
|
|
|
|
2017-01-30 03:59:50 +04:00
|
|
|
pfts1 = pfts.ProbabilisticFTS("1")
|
|
|
|
#pfts1.appendTransformation(diff)
|
2017-02-15 05:01:44 +04:00
|
|
|
pfts1.train(gauss_treino,fs,2)
|
|
|
|
#pfts2 = pfts.ProbabilisticFTS("n = 2")
|
2017-02-01 20:54:37 +04:00
|
|
|
#pfts2.appendTransformation(diff)
|
2017-02-15 05:01:44 +04:00
|
|
|
#pfts2.train(gauss_treino,fs,2)
|
2017-02-01 20:54:37 +04:00
|
|
|
|
2017-02-15 05:01:44 +04:00
|
|
|
#pfts3 = pfts.ProbabilisticFTS("n = 3")
|
2017-02-01 20:54:37 +04:00
|
|
|
#pfts3.appendTransformation(diff)
|
2017-02-15 05:01:44 +04:00
|
|
|
#pfts3.train(gauss_treino,fs,3)
|
2017-02-01 20:54:37 +04:00
|
|
|
|
2017-02-15 05:01:44 +04:00
|
|
|
#densities1 = pfts1.forecastAheadDistribution(gauss_teste[:50],2,1.50, parameters=2)
|
2017-02-01 20:54:37 +04:00
|
|
|
|
|
|
|
#print(bchmk.getDistributionStatistics(gauss_teste[:50], [pfts1,pfts2,pfts3], 20, 1.50))
|
|
|
|
|
2017-02-15 05:01:44 +04:00
|
|
|
sim_fs, sim_uod =pfts1.generate_data(bins=10)
|
|
|
|
|
|
|
|
#print(pdf_fs)
|
|
|
|
|
|
|
|
#print(sim_fs)
|
|
|
|
|
|
|
|
print(sim_uod)
|
|
|
|
|
|
|
|
print(np.ravel(sim_uod))
|
|
|
|
|
|
|
|
#print(sim_uod)
|
|
|
|
|
|
|
|
#print (Measures.pdf(gauss_treino,bins=10))
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-14 03:42:00 +04:00
|
|
|
|
|
|
|
|