我不明白什麼時候我必須使用scikit學習的擬合方法。我什麼時候必須使用scikit的fit方法學習?
在這個網頁:http://machinelearningmastery.com/automate-machine-learning-workflows-pipelines-python-scikit-learn/ 有一個管道+ StandardScaler的例子。不使用擬合方法。
但在這另一個:http://scikit-learn.org/stable/auto_examples/svm/plot_rbf_parameters.html 還有一個StandardScaler,並有一個適合的方法。
這是我的代碼:管道+ Robustscaler:
result_list = []
for name in ["AWA","Rem","S1","S2","SWS","SX", "ALL"]:
x=sio.loadmat('/home/{}_E.mat'.format(name))['x']
s_y=sio.loadmat('/home/{}_E.mat'.format(name))['y']
y=np.ravel(s_y)
print(name, x.shape, y.shape)
print("")
#Create a pipeline
clf = make_pipeline(preprocessing.RobustScaler(), SVC(cache_size=1000, kernel='rbf'))
###################10x20 SSS##################################
print("10x20")
xSSSmean20 = []
for i in range(10):
sss= StratifiedShuffleSplit(y, 20, test_size=0.1, random_state=i)
scoresSSS=cross_validation.cross_val_score(clf, x, y, cv=sss)
xSSSmean20.append(scoresSSS.mean())
result_list.append(xSSSmean20)
print("")
爲什麼這是一個糟糕的問題? – Aizzaac
因爲'沒有使用合適的方法.'是錯誤的陳述。它用在'cross_val_score'中。 – MMF
好的。謝謝。我不知道。 – Aizzaac