Я новичок в машинном обучении Python, я практиковал программу прогнозирования акций на python, но в соответствии с руководством "из sklearn import cross_validation" используется. Но в моем компиляторе Intellij IDEA я не могу его использовать, он показывает ошибку
import quandl, math
import numpy as np
from sklearn import preprocessing, svm
from sklearn import cross_validation
from sklearn.linear_model import LinearRegression
df = quandl.get('NSE/RCOM', api_key='-pQJsBYvTAsU-cSopBvA')
df = df[['Open', 'High', 'Close', 'Low', 'Total Trade Quantity']]
df['PCT_change'] = (df['Close'] - df['Open']) / df['Open'] * 10
df = df[['Close', 'HL_pct', 'PCT_change', 'Total Trade Quantity']]
forecast_col = 'Close'
df.fillna(-99999, inplace=True)
forecast_out = int(math.ceil(0.01 * len(df)))
print (forecast_out)
df['lable'] = df[forecast_col].shift(-forecast_out)
df.dropna(inplace=True)
X = np.array(df.drop(['lable'], 1))
y = np.array(df['lable'])
X = preprocessing.scale(X)
y = np.array(df['lable'])
print(len(X),len(y))
X_train, X_test, y_train, y_test = cross_valalidation.train_test_split(X, y, test_size=0.2)
clf = LinearRegression()
clf.fit(X_train, y_train)
accuracy = clf.score(X_test, y_test)
print(accuracy)
}
OUTPUT:
C:\Users\aravind\AppData\Local\Programs\Python\Python37-32\python.exe
C:/Users/aravind/Desktop/programtopractics/untitled3/stock.py
C:\Users\aravind\AppData\Local\Programs\Python\Python37-32\lib\site-packages
\sklearn\externals\joblib\externals\cloudpickle\cloudpickle.py:47:
DeprecationWarning: the imp module is deprecated in favour of importlib;
C:/Users/aravind/Desktop/programtopractics/untitled3/stock.py
see the module's documentation for alternative uses
import imp
31
Traceback (most recent call last):
File "C:/Users/aravind/Desktop/programtopractics/untitled3/stock.py",
line 29, in <module>
X_train, X_test, y_train, y_test = cross_val_score.train_test_split(X, y, test_size=0.2)
AttributeError: 'function' object has no attribute 'train_test_split'
3019 3019