迴歸模型coef問題
2020/04/10 01:07 下午
機器學習共學討論版
江柏勳
觀看數:11
回答數:3
收藏數:0
plt.figure()
wine=datasets.load_wine()
x_train, x_test, y_train, y_test = train_test_split(wine.data, wine.target, test_size=0.2, random_state=4)
for i,j in zip([0.0001,0.001,0.01,0.1],[1,2,3,4]):
model=linear_model.Ridge(alpha=i)
model.fit(x_train,y_train)
y_pred=model.predict(x_test)
print("Mean Square Error:{}".format( mean_squared_error(y_test, y_pred)))
print("cofficient:",np.reshape(model.coef_,(-1,1)))
plt.subplot(2,2,j)
plt.scatter(x_test,x_test)
plt.plot(x_test,y_pred)
想問一下就是請問coef_這邊是只回歸之後每個變數的係數?
然後想問一下這是這張圖有什麼意涵可以解讀嗎?
(程式碼寫得不夠精簡請見諒)