【问题标题】:Show Print Format in Jupyter Widgets在 Jupyter 小部件中显示打印格式
【发布时间】:2018-09-15 09:09:09
【问题描述】:

我有来自sklearn.metricsclassification_report 的结果,然后是print 的报告,它会是这样的:

             precision    recall  f1-score   support

          1       1.00      0.84      0.91        43
          2       0.12      1.00      0.22         1

avg / total       0.98      0.84      0.90        44

现在,问题是如何在 Jupyter 小部件(上述格式)中显示结果并更新其值? 目前,我正在使用html 小部件来显示结果:

#pass test and result vectors
report = classification_report(pred_test , self.y_test_data) 
predict_table = widgets.HTML(value = "")
predict_table.value = report

但它喜欢以下内容:

precision recall f1-score support 1 1.00 0.81 0.90 43 2 0.00 0.00 0.00 0 avg / total 1.00 0.81 0.90 43 

【问题讨论】:

    标签: python-2.7 widget jupyter


    【解决方案1】:

    我找到了一个使用 html 技术的简单解决方案!由于我们在 Jupyter 中使用了 html 小部件,因此可以通过在 html 中使用 pre 标签来解决问题:

    predict_table.value = "<pre>" + report + "</pre>
    

    【讨论】:

      猜你喜欢
      • 2019-05-02
      • 1970-01-01
      • 2021-01-18
      • 2020-06-23
      • 1970-01-01
      • 1970-01-01
      • 2018-11-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多