TypeError:' str'对象在scikit中无法调用学习预测

时间:2017-10-30 15:29:49

标签: machine-learning scikit-learn xgboost

我正在使用joblib

将xgboost分类器模型文件的pickle存储到磁盘
from sklearn.externals import joblib
joblib.dump(clf, 'model.pkl')

然后,我正在加载模型并尝试预测测试数据集

from sklearn.externals import joblib
model=joblib.load('model.pkl')
model.predict(X_test)

当我在加载的分类器对象上执行predict方法时,我得到了TypeError: 'str' object is not callable

有关如何解决此问题的任何帮助?

这是追溯

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-72-0da70f003ba0> in <module>()
----> 1 model.predict(X_test)

C:\Users\Sriram\Anaconda3\lib\site-packages\sklearn\utils\metaestimators.py in <lambda>(*args, **kwargs)
    113 
    114         # lambda, but not partial, allows help() to work with update_wrapper
--> 115         out = lambda *args, **kwargs: self.fn(obj, *args, **kwargs)
    116         # update the docstring of the returned function
    117         update_wrapper(out, self.fn)

C:\Users\Sriram\Anaconda3\lib\site-packages\sklearn\pipeline.py in predict(self, X)
    314             if transform is not None:
    315                 Xt = transform.transform(Xt)
--> 316         return self.steps[-1][-1].predict(Xt)
    317 
    318     @if_delegate_has_method(delegate='_final_estimator')

C:\Users\Sriram\Anaconda3\lib\site-packages\xgboost\sklearn.py in predict(self, data, output_margin, ntree_limit)
    461     def predict(self, data, output_margin=False, ntree_limit=0):
    462         test_dmatrix = DMatrix(data, missing=self.missing)
--> 463         class_probs = self.booster().predict(test_dmatrix,
    464                                              output_margin=output_margin,
    465                                              ntree_limit=ntree_limit)

TypeError: 'str' object is not callable

0 个答案:

没有答案