为什么没有定义X_train_std
我可以知道为什么我收到错误消息-
NameError:未定义名称'X_TRAIN_STD'
选择 | 换行 | 行号
- from sklearn.linear_model import LogisticRegression
- lr = LogisticRegression(C=1000.0, random_state=0)
- lr.fit(X_train_std, y_train)
- plot_decision_regions(X_combined_std,
- y_combined, classifier=lr,
- test_idx=range(105,150))
- plt.xlabel('petal length [standardized]')
- plt.ylabel('petal width [standardized]')
- plt.legend(loc='upper left')
- plt.tight_layout()
- plt.show()
- lr.predict_proba(X_test_std[0,:])
- weights, params = [], []
- for c in np.arange(-5, 5):
- lr = LogisticRegression(C=10**c, random_state=0)
- lr.fit(X_train_std, y_train)
- weights.append(lr.coef_[1])
- params.append(10**c)
- weights = np.array(weights)
- plt.plot(params, weights[:, 0],
- label='petal length')
- plt.plot(params, weights[:, 1], linestyle='--',
- label='petal width')
- plt.ylabel('weight coefficient')
- plt.xlabel('C')
- plt.legend(loc='upper left')
- plt.xscale('log')
- plt.show()
附加图像
Logistic Regression.jpg
(57.8KB,119次浏览)
附加的文件
逻辑回归.pdf
(291.6 KB,82次浏览)