如何提高查准率和查全率

2024-04-19 12:30:36 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,我正在尝试创建一个员工晋升aloghritim,这将有一个高召回和精度的价值,试图符合我的模式,但得到这个错误 请帮助下面是我的合作链接到我的作品到目前为止 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]

Tags: oftheinimportinputmodeltrainsklearn