Моя логистика c Прогнозная модель дает мне точность обучения 80% и точность тестирования 79%.
Точность модели обучения: 0,8039535210772422 Точность модели тестирования: 0,7937496044721021
Моя путаница Матрица дает мне следующие значения: ![enter image description here](https://i.stack.imgur.com/7mvCo.png)
Использование настройки гиперпараметров и печать моих классификационных отчетов:
precision recall f1-score support
0 0.87 0.88 0.87 172299
1 0.77 0.70 0.74 17321
micro avg 0.85 0.85 0.85 189620
macro avg 0.77 0.74 0.76 189620
weighted avg 0.85 0.85 0.85 189620
Когда я сравниваю результаты с фактическими данными, то я протестировали модель прогнозирования только на 40% совпадений данных. Как я могу улучшить свой фактический вывод.
Это мой код, любые предложения будут действительно полезны.
# Create the hyperparameter grid
c_space = np.logspace(-5, 8, 15)
log_param_grid = {'C': c_space, 'penalty': ['l1', 'l2']}
# Setup the GridSearchCV object: logReg_cv
logReg=LogisticRegression()
logReg_cv = GridSearchCV(logReg,log_param_grid,cv=5)
y=predict_pi.P_I
X=pd.get_dummies(X)
test=pd.get_dummies(test)
extra_cols_train = [i for i in list(test) if i not in list(X)]
extra_cols_test = [i for i in list(X) if i not in list(test)]
X = X.reindex(columns=X.columns.tolist() + extra_cols_train)
X[extra_cols_train] = 0
test = test.reindex(columns=test.columns.tolist() + extra_cols_test)
test[extra_cols_test] = 0
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.4,random_state=42)
logReg_cv.fit(X_train,y_train)
pred_pi=logReg_cv.predict(X_test)
test_pi=logReg_cv.predict(X_train)
print("Training Model Accuracy:{}".format(accuracy_score(y_train,test_pi)))
print("Testing Model Accuracy:{}".format(accuracy_score(y_test,pred_pi)))
print(confusion_matrix(y_test, pred_pi))
print(classification_report(y_test, pred_pi))
print("Tuned Logistic Regression Parameter: {}".format(logReg_cv.best_params_))
print("Tuned Logistic Regression Accuracy: {}".format(logReg_cv.best_score_))
С уважением, Рен.