x_train, x_test, y_train, y_test =
sklearn.model_selection.train_test_split(X, y, test_size=0.2,
shuffle=False)
return(x_train, x_test, y_train, y_test)
logisticR = LogisticRegression(random_state=0, max_iter = '800',
solver='saga', multi_class='multinomial')
logisticR.fit(x_train, encoded_ytrain)
acc = logisticR.score(x_test, encoded_ytest)
print(acc)
运行时会出现以下错误:ValueError:最大迭代次数必须为正。得到了(max_iter ='800')
由于max_iter默认为100,是否有另一种更改迭代大小的方法?
答案 0 :(得分:0)
实际上,max_iter
应该是int
,而不应该是str
您可以尝试以下方法吗?
logisticR = LogisticRegression(random_state=0, max_iter=800,
solver='saga', multi_class='multinomial')
答案 1 :(得分:0)
为什么要将max_iter对象值放在''之内。您正在创建一个Str。您需要提供一个整数。只需等于800。