我正在创建一个具有4种可能结果的多类分类模型。它昨天有效,但是今天,我收到以下错误。我对Python不太熟悉,因此希望对如何解决此问题有所帮助。
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
scaler.fit(X_train)
X_train_scaled = scaler.transform(X_train)
X_test_scaled = scaler.transform(X_test)
Logistic=LogisticRegression()
logistic.fit(X_train_scaled,y_train)
y_pred_log=logistic.predict(X_test_scaled)
log_cm=(metrics.confusion_matrix(y_test, y_pred_log))
TypeError Traceback (most recent call last)
<ipython-input-213-8e436855d9cc> in <module>
1 logistic=LogisticRegression()
----> 2 logistic.fit(X_train_scaled,y_train)
3 y_pred_log=logistic.predict(X_test_scaled)
4 log_cm=(metrics.confusion_matrix(y_test, y_pred_log))
~\Anaconda3\lib\site-packages\sklearn\linear_model\logistic.py in fit(self, X, y, sample_weight)
1491 The SAGA solver supports both float64 and float32 bit arrays.
1492 """
-> 1493 solver = _check_solver(self.solver, self.penalty, self.dual)
1494
1495 if not isinstance(self.C, numbers.Number) or self.C < 0:
~\Anaconda3\lib\site-packages\sklearn\linear_model\logistic.py in _check_solver(solver, penalty, dual)
430 warnings.warn("Default solver will be changed to 'lbfgs' in 0.22. "
431 "Specify a solver to silence this warning.",
--> 432 FutureWarning)
433
434 all_solvers = ['liblinear', 'newton-cg', 'lbfgs', 'sag', 'saga']
TypeError: issubclass() arg 2 must be a class or tuple of classes
答案 0 :(得分:0)
似乎是您的求解器引起了错误。尝试更改您的求解器:
solver = 'lbfgs'