0
我使用蟒蛇与Python 3.在Spyder的我运行下面的代码无模块名为 'sklearn.leanear_model' 的错误,Spyder的
import pandas as pd
import quandl
import math
import numpy as np
from sklearn import preprocessing, cross_validation, svm
from sklearn.leanear_model import LearnRegression
df = quandl.get('WIKI/GOOGL')
df = df[['Adj. Open','Adj. High','Adj. Low','Adj. Close','Adj. Volume',]]
df['HL_PCT'] = (df['Adj. High'] - df['Adj. Close'])/df['Adj. Close']*100.0
df['PCT_change'] = (df['Adj. Close'] - df['Adj. Open'])/df['Adj. Open']*100.0
df = df[['Adj. Close','HL_PCT','PCT_change','Adj. Volume']]
forecast_col='Adj. Close'
df.fillna(-99999, inplace=True)
forecast_out=int(math.ceil(0.01*len(df)))
df['label'] = df[forecast_col].shift(-forecast_out)
df.dropna(inplace=True)
X = np.array(df.drop(['label'],1))
y=np.array(df['label'])
X = preprocessing.scale(X)
X=X[:-forecast_out+1]
df.drona(inplace=True)
y = np.array(df['label'])
print(len(X),len(y))
但它显示了以下错误
runfile('C:/Users/jayram/.spyder-py3/temp.py', wdir='C:/Users/jayram/.spyder-py3')
C:\Users\jayram\Anaconda3\lib\site-packages\sklearn\cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
Traceback (most recent call last):
File "<ipython-input-1-f93a3ccc2710>", line 1, in <module>
runfile('C:/Users/jayram/.spyder-py3/temp.py', wdir='C:/Users/jayram/.spyder-py3')
File "C:\Users\jayram\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\Users\jayram\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/jayram/.spyder-py3/temp.py", line 6, in <module>
from sklearn.leanear_model import LearnRegression
ModuleNotFoundError: No module named 'sklearn.leanear_model'
anaconda已安装所有软件包?那为什么上面的错误显示?或者我们必须在安装anaconda之后安装软件包?
是工作的,也是drona代替dropna –