gpt4 book ai didi

python - 为什么我得到 X_train_std 未定义

转载 作者:太空宇宙 更新时间:2023-11-03 21:08:39 30 4
gpt4 key购买 nike

请问我为什么收到错误消息 -

名称错误:名称“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()

请查看链接 -

https://www.freecodecamp.org/forum/t/how-to-modify-my-python-logistic-regression/265795

https://bytes.com/topic/python/answers/972352-why-i-get-x_train_std-not-defined#post3821849

https://www.researchgate.net/post/Why_I_get_the_X_train_std_is_not_defined

.

最佳答案

嗯,X_train_std 未定义/声明。您需要在使用变量之前声明该变量并为其赋值。

喜欢:

X_train_std = 3

关于python - 为什么我得到 X_train_std 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55223059/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com