Scikit-learn 在 LOGISTIC REGRESSION、随机森林、SVM 上的准确度非常低,但在线性回归上准确度很高 [关闭]

原文标题Scikit-learn has very low accuracy on LOGISTIC REGRESSION, Random Forest, SVM but has high accuracy on linear regression [closed]

这是我的数据集

data

我通过这样做将字符串类型的列转换为浮动

df2['Sex'] = df['Sex'].astype('category')
df2['Housing'] = df['Housing'].astype('category')
df2['Saving accounts'] = df['Saving accounts'].astype('category')
df2['Checking account'] = df['Checking account'].astype('category')
df2['Purpose'] = df['Purpose'].astype('category')

enter image description here

训练模型:

train, test = train_test_split(df2, test_size=0.2)
Y_train = pd.DataFrame()
Y_test = pd.DataFrame()
Y_train["score"] = train["score"]
Y_test["score"] = test["score"]
X_train = train.drop('score', 1)
X_test = test.drop('score', 1)


lr = LogisticRegression(penalty='l1', C=0.9, solver='liblinear', n_jobs=-1)
lr.fit(X_train, Y_train)
Y_pred = lr.predict(X_test)

我使用 LOGISTIC REGRESSION、RandomForest 或 SVM 的准确性非常低

from sklearn.metrics import accuracy_score
accuracy_score(Y_test,Y_pred)

0.05

原文链接:https://stackoverflow.com//questions/71502352/scikit-learn-has-very-low-accuracy-on-logistic-regression-random-forest-svm-bu

回复

我来回复
  • lejlot的头像
    lejlot 评论

    您的问题是回归,但您尝试了分类模型(逻辑回归、SVM 和 RandomForest)。您应该尝试 RandomForestRegressor、SVR(相对于 SVC)等。

    2年前 0条评论