저는 Google을 검색해 왔으며 잘못하고있는 것을 파악할 수 없습니다. 저는 파이썬에 매우 익숙하며 주식에 scikit을 사용하려하지만 예측하려고 할 때 "ValueError : 행렬이 정렬되지 않았습니다."라는 오류가 나타납니다.LinearRegression Predict- ValueError : 행렬이 맞춰지지 않았습니다.
import datetime
import numpy as np
import pylab as pl
from matplotlib import finance
from matplotlib.collections import LineCollection
from sklearn import cluster, covariance, manifold, linear_model
from sklearn import datasets, linear_model
###############################################################################
# Retrieve the data from Internet
# Choose a time period reasonnably calm (not too long ago so that we get
# high-tech firms, and before the 2008 crash)
d1 = datetime.datetime(2003, 01, 01)
d2 = datetime.datetime(2008, 01, 01)
# kraft symbol has now changed from KFT to MDLZ in yahoo
symbol_dict = {
'AMZN': 'Amazon'}
symbols, names = np.array(symbol_dict.items()).T
quotes = [finance.quotes_historical_yahoo(symbol, d1, d2, asobject=True)
for symbol in symbols]
open = np.array([q.open for q in quotes]).astype(np.float)
close = np.array([q.close for q in quotes]).astype(np.float)
# The daily variations of the quotes are what carry most information
variation = close - open
#########
pl.plot(range(0, len(close[0])-20), close[0][:-20], color='black')
model = linear_model.LinearRegression(normalize=True)
model.fit([close[0][:-1]], [close[0][1:]])
print(close[0][-20:])
model.predict(close[0][-20:])
#pl.plot(range(0, 20), model.predict(close[0][-20:]), color='red')
pl.show()
오류 라인은 내가 목록에 둥지를 시도했습니다
model.predict(close[0][-20:])
입니다. 그것 numpy와 배열 만들기. 내가 Google에서 찾을 수있는 모든 것은 있지만 여기에 내가 무엇을하고 있는지 전혀 알지 못합니다.
이 오류는 무엇을 의미하며 왜 그런 일이 발생합니까?
X.add_constant (len (X)) –