我坚持在scikit-learn中使用Multilabel二进制化程序和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
提前感谢您的帮助!
答案 0 :(得分:1)
mlb.fit_transform(_labels)
的输出将是inverse_transform
的输入。
有关详情,请点击此处:Multilabel Binarizer