Python:索引器错误:数组的索引太多

2024-04-26 17:33:20 发布

您现在位置:Python中文网/ 问答频道 /正文

以下代码在我运行时引发错误:

model_ridge = lm.LogisticRegression(penalty='l2', dual=False, tol=0.0001, C=9081)
model_randomforest = RandomForestClassifier(n_estimators = 200)
pred_ridge = []
pred_randomforest = []
new_Y = []
for i in range(10):
    indxs = np.arange(i, X.shape[0], 10)
    indxs_to_fit = list(set(range(X.shape[0])) - set(np.arange(i, X.shape[0], 10)))
    pred_ridge = pred_ridge + list(model_ridge.fit(X[indxs_to_fit,:1], y[indxs_to_fit,:1]).predict_proba(X[indxs,:1])[:,1])
    pred_randomforest = pred_randomforest + list(model_randomforest.fit(X[indxs_to_fit,:], y[indxs_to_fit,:]).predict_proba(X[indxs,:])[:,1])
    new_Y = new_Y + list(y[indxs,:])

这是错误:

^{pr2}$

我不明白发生了什么事,你能帮我弄清楚我做错了什么吗?在


Tags: tonewmodel错误nprangelistfit