python - ANN 的无意义混淆矩阵
问题描述
我使用以下方法尝试创建 ANN 模型。但是,我的分类矩阵(在底部)强烈表明出现了问题。但是,我不确定问题从哪里开始以及为什么。我使用的数据集是这样拆分的:
X = df.drop('Recurrence', axis = 1)
y = df['Recurrence']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3, random_state = 0)
print(X_train.shape)
print(y_train.shape)
print(X_test.shape)
print(y_test.shape)
这是训练/测试方法:
from sklearn.neural_network import MLPClassifier
from sklearn.model_selection import train_test_split
# Set seed for reproducibility
SEED = 1
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1)
clf = MLPClassifier(hidden_layer_sizes=(100), activation='logistic', solver='lbfgs', learning_rate= 'adaptive',
random_state=SEED, max_iter=200).fit(X_train, y_train)
classificationSummary(y_train, clf.predict(X_train))
classificationSummary(y_test, clf.predict(X_test))
给出了以下分类总结
Confusion Matrix (Accuracy 1.0000)
Prediction
Actual 0
0 1
Confusion Matrix (Accuracy 0.0000)
Prediction
Actual 0 1
0 0 1
1 0 0
解决方案
推荐阅读
- angular - mat-optgroup 不适用于 compareWith
- performance - MySQL 8.0.18:关键效率 0.0%
- java - 是否有任何 API 可以在 java 中格式化货币值?
- pagination - 与客户端同步服务器端分页
- c++ - C++ 捕获错误“抛出 'std::out_of_range' 的实例”
- vue.js - 超时后如何更改 V-Snackbar 的值
- python - python web scrape如何用逗号分隔结果
- excel - 同一公式中有多个 IF
- cmake - 如何编译 wfreerdp.dll 而不是 wfreerdp.exe?
- mysql - MYSQL,如何获取条件行