随机森林分类器演示期间用户输入的问题

问题描述 投票:0回答:1

我使用随机森林分类器获得了超过 90% 的准确率,但我担心其余算法给出的结果要低得多,尤其是逻辑回归(55% 准确率) enter image description here 但这不是主要问题。问题是,当我使用用户输入时,预测是 100% 错误的。用户输入的列的顺序对应于训练数据集列的位置。

model = RandomForestClassifier()
model.fit(X_train, y_train)
prediction = model.predict(X_test)
acc = accuracy_score(y_test, prediction)   # output: 0.91

X_test_user = df_user_compounds_1.to_numpy()
user_input_predictions_1 = model.predict(X_test_user) # 
user_input_predictions_1    # output: array([0, 0, 0, 0, 0], dtype=int64), but it should be: array([1, 1, 1, 1, 1],dtype=int64) 

有人知道为什么会发生这种情况吗?

数据集经过预处理 - 没有缺失值,没有重复,使用 RandomOverSampler 进行平衡,使用 MinMaxScaler 进行缩放,没有负值,并且包含 11 个特征/7K 行。

python user-input
1个回答
0
投票

首先,不同的算法给出不同的准确率是可以接受的。

其次,就你的情况而言,可能有几个原因。

  1. 您已缩放数据中的输入,但未缩放 df_user_compounds_1
  2. 您的模型可能过度拟合

第三,这不是选择模型的方法。你必须尝试K-Fold交叉验证超参数调整

© www.soinside.com 2019 - 2024. All rights reserved.