0
텍스트 분류 및 지침 here에 scikit-learn SVM을 사용하고 있습니다.scikit-learn/svm - 'predict_proba'뒤에 확률 및 관련 레이블을 가져옵니다.
: 그러나 나는이 예외가 올바른 라벨, 동료를 확률을 가져 오도록TypeError: only integer arrays with one element can be converted to an index
predict_proba
방법을 사용하여 위의 코드를 실행에 상위 3
vectorizer = HashingVectorizer()
clf = svm.SVC(probability=True,class_weight='balanced')
test_data = [...]
test_vectors = vectorizer.transform(test_data)
predicted = clf.predict_proba(test_vectors)
for doc, pred in zip(test_labels, predicted):
print('%r => %s' % (doc, test_labels[pred]))
를 가져 오는 방법에 관한 혼란 스러워요
이것은 test_labels이 확률의 배열이기 때문에 이해할 수 있지만 관련 레이블과 확률을 가져 오는 방법을 모르겠습니다.
전체 오류 스택 추적을 게시하십시오. 어느 라인에서 오류가 발생합니까? 또한 데이터 샘플을 보여줍니다. –