scikit learn output metrics.classification_report into CSV/tab-delimited format

后端 未结 17 2211
青春惊慌失措
青春惊慌失措 2021-01-31 03:08

I\'m doing a multiclass text classification in Scikit-Learn. The dataset is being trained using the Multinomial Naive Bayes classifier having hundreds of labels. Here\'s an extr

17条回答
  •  时光取名叫无心
    2021-01-31 04:04

    The simplest and best way I found is:

    classes = ['class 1','class 2','class 3']
    
    report = classification_report(Y[test], Y_pred, target_names=classes)
    
    report_path = "report.txt"
    
    text_file = open(report_path, "w")
    n = text_file.write(report)
    text_file.close()
    

提交回复
热议问题