首页 > 解决方案 > 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

标签: pythonmachine-learningdata-scienceconfusion-matrix

解决方案


推荐阅读