I'm having problems converting my forecast_out from daily to a minute forecast

Viewed 27

Hi I'm working on a learning model and I seem to have been stuck with the forecast_out function of Scikit-learn.

I need help in creating forecasts not just for daily, but hourly, and even by the minute as well.

Thanks!

import pandas as pd
import datetime as dt
import pandas_datareader as reader 
import fbprophet
import numpy as np

from sklearn.linear_model import LinearRegression
from sklearn.svm import SVR
from sklearn.model_selection import train_test_split
end = dt.datetime.now()
start = dt.datetime(end.year-1,end.month,end.day,end.hour,end.minute)
start
df = reader.get_data_yahoo('BTC-USD',start,end)
print(df.head())
df = df[['Adj Close']]
print(df.head())
forecast_out =30 #(I want to be able to predict hourly and even by the minute as well)
df['Prediction'] = df[['Adj Close']].shift(-forecast_out)
print(df.tail())
X = np.array (df.drop(['Prediction'],1))
X = X[:-forecast_out]
print (X)
y = np.array (df['Prediction'])
y = y[:-forecast_out]
print(y)
x_train, x_test, y_train, y_test = train_test_split (X,y, test_size=0.2)
svr_rbf = SVR(kernel='rbf' , C=1e3, gamma=0.1)
svr_rbf.fit(x_train, y_train)
svm_confidence = svr_rbf.score(x_test, y_test)
print ("svm confidence: ", svm_confidence)
lr = LinearRegression()
lr.fit(x_train, y_train)
lr_confidence = lr.score(x_test, y_test)
print ("lr confidence: ", lr_confidence)
x_forecast = np.array(df.drop(['Prediction'],1))[-forecast_out:]
print(x_forecast)
lr_prediction = lr.predict (x_forecast)
print(lr_prediction)
svm_prediction = svr_rbf.predict (x_forecast)
print(svm_prediction)
0 Answers
Related