今天老師講了一些數學的東西,傳統演算法與機器學習的演算法差異,機器學習演算法有哪些方式去回測參數,但目前提到覺得不錯的就是梯度下降法,可以不斷修正讓AUC最高,也練習利用LinearRegression預測股價
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
data = pd.read_csv('2330.csv')
data.head()
print(data.columns)
X = data[['x1', 'x2', 'x3', 'x4', 'x5']].values.reshape(-1,5)
Y = data['y'].values.reshape(-1,1)
from sklearn.linear_model import LinearRegression as LR
model = LR()
model.fit(X,Y)
preY = model.predict(X)
data['preY'] = preY
print(data.tail(1))
testX = data.iloc[-1,1:6].values.reshape(-1,5)
print(testX)
ans = model.predict(testX)
print(ans)