0

嗨,我正在尝试创建一个具有高召回率和精度值的员工晋升算法,试图适应我的模型,但得到这个错误请帮助下面是我到目前为止的作品的协作链接 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]
4

1 回答 1

1

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

expected_y = y_test

代替

expected_y  = y_train
于 2019-10-22T21:29:00.107 回答