我一直在scikit-learn中使用Multilabel binarizer和One-vs-all分类器。我的挑战是一旦获得预测,
获取原始标签。 (我分别训练和腌制了一对多休息分类器和矢量化器)
_labels = load_labels()
mlb = MultiLabelBinarizer()
mlb.fit_transform(_labels)
print mlb.classes_ # this prints the binarized labels
_clf,_vect = load_pickle('./pickles')
for q in queries:
#query vector q
X = vect.transform([q])
res = clf.predict_proba(X)
print res #[[ 0.00164113 0.00706595 0.00683465 .... 0.00837984]]
#this is where I am stuck on what to pass into the inverse_transform to obtain
preds = mlb.inverse_transform(??)
print preds
感谢您的帮助!
最佳答案
mlb.fit_transform(_labels)
的输出将是inverse_transform
的输入。
有关更多信息,请参见:Multilabel Binarizer
关于python - Multilabel Binarizer-获得逆变换,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47356433/