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 –