python - 如何提高查准率和查全率

标签 python machine-learning catboost

您好,我正在尝试创建一个员工晋升算法,它将具有很高的召回率和精确度值,试图适合我的模型,但出现此错误 请帮助下面是我迄今为止作品的协作链接 https://colab.research.google.com/drive/1ugKUswSjwnrfActsu2E-1gSg94ylwUJK

import catboost as ctb
from sklearn import metrics 
    # fit a CART model to the data
parameters = {'depth'         : [6,8,10],
                  'learning_rate' : [0.01, 0.05, 0.1],
                  'iterations'    : [30, 50, 100]
                 }
model = ctb.CatBoostClassifier(silent=True)
model.fit(X_train, y_train)
print(); print(model)


     # make predictions
expected_y  = y_train
predicted_y = model.predict(X_test)

    # summarize the fit of the model
print(); print(metrics.classification_report(expected_y, predicted_y))
print(); print(metrics.confusion_matrix(expected_y, predicted_y))
ValueError                                Traceback (most recent call last)
<ipython-input-26-abdfdbe585e3> in <module>()
     16 
     17     # summarize the fit of the model
---> 18 print(); print(metrics.classification_report(expected_y, predicted_y))
     19 print(); print(metrics.confusion_matrix(expected_y, predicted_y))

2 frames
/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py in check_consistent_length(*arrays)
    203     if len(uniques) > 1:
    204         raise ValueError("Found input variables with inconsistent numbers of"
--> 205                          " samples: %r" % [int(l) for l in lengths])
    206 
    207 

ValueError: Found input variables with inconsistent numbers of samples: [30649, 7663]

最佳答案

从你的缩写来看,我认为应该是

expected_y = y_test

而不是

expected_y  = y_train

关于python - 如何提高查准率和查全率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58512394/

相关文章:

r - 使用 R 中的 tidymodels 获取 catboost 模型的摘要形状图

python - 在 Python 中重置类的首选方法

python - 在哪里可以找到 python 中类的方法定义?

java - 为什么我们需要在某些语言中使用它之前声明变量,而在其他语言中则不需要?

machine-learning - 使用神经网络识别输入序列

python - 如何将 numpy 数组作为 Catboost Python 中的分类特征传递

python - 如何使用 Keras 在二值图像上使用卷积神经网络?

machine-learning - 构建 ROC 曲线涉及哪些变量?

algorithm - 有没有数据挖掘的在线判断

r - ubuntu上离线安装R catboost包