# Main project file for stock price prediction from fetchdata import fetch from partitiondata import partition_split import numpy as np import matplotlib.pyplot as plt from scipy.interpolate import spline from sklearn.linear_model.ridge import Ridge from sklearn.linear_model import RidgeCV from sklearn.feature_selection import RFE from sklearn.feature_selection import RFECV # Load CSV file alldata = fetch('../data/stock_returns_base150.csv') alldata.pop(0); # Remove the header print(len(alldata)); # Partition data into separate objects for training, testing and forecasting. Also generate the features matrix X and output y lag = 3; print("Lag is ", lag); testpercent = 25; n_modeldata = 50; X,Xtest,y,ytest,Xfcast,features = partition_split(alldata,n_modeldata,testpercent,lag); print(' X is ', X.shape , '\t Xtest is ', Xtest.shape, '\t Xfcast is ', Xfcast.shape, '\n y is ',y.shape , '\t \t ytest is ', ytest.shape, '\n features is ', features.shape); n_features = features.shape[0]; # Features Ranking # Univariate Feature Scoring with Cross validation def plotscores(scores,rf,n = n_features):
def dataReceived(self, data): data = data.decode("utf-8") if data == "refresh": self.write(fetchdata.fetch())