![](/img/trans.png)
[英]Scikit Learn model results in error when calling local predict or creating model version on Google Cloud ml engine
[英]How to convert Scikit Learn OneVsRestClassifier predict method output to dense array for google cloud ML?
我有一个模型,我使用sklearn Pipeline和我试图部署到Cloud ML Engine的OneVsRestClassifier进行训练,但是当我使用命令时:
gcloud ml-engine predict --model $MODEL_NAME --version $VERSION_NAME --json-instances $INPUT_FILE
我收到错误:
{ "error": "Prediction failed: Bad output type returned.The predict function should return either a numpy ndarray or a list." }
这让我相信OneVsRestClassifier的预测方法输出是一个稀疏矩阵,而它应该是一个numpy数组。 如何将其输出转换为我的管道中的密集数组?
管道的架构如下所示:
Pipeline([('tfidf', tfidf), ('clf', OneVsRestClassifier(XGBClassifier())])
谢谢!
我尝试使用这里的方法( Google Cloud ML-engine scikit-learn预测概率'predict_proba()' )用它的predict_proba方法覆盖OneVsRestClassifier的预测方法,但是当我尝试挑选新的方法时会导致以下错误管道:
PicklingError: Can't pickle <function OneVsRestClassifier.predict_proba at 0x10a8f9d08>: it's not the same object as sklearn.multiclass.OneVsRestClassifier.predict_proba
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.