【问题标题】:How to use correclty pyprind with scikit-learn?如何在 scikit-learn 中使用正确的 pyprint?
【发布时间】:2016-11-23 05:37:32
【问题描述】:

目前我正在使用pyprind,一个实现进度条的库:

#Compute training time elapsed
pbar = pyprind.ProgBar(45, width=120, bar_char='█')
for _ in range(45):
    #Fiting
    clf = SVC().fit(X_train, y_train)
    pbar.update()
#End of bar

但是,我不知道这是否是使用pbar 的正确方法,因为我想我适合clf 45 次。那么,我应该如何正确使用pbar?。

【问题讨论】:

  • 您无法监控一个 SVM 模型的拟合进度,因为您所做的只是调用 fit 函数,它不会告诉您到目前为止它已经取得了多少进展。
  • @cel 我认为他并没有试图监控 SVM 模型的拟合,它只是库查看并更新栏的 for 循环迭代。
  • @hashcode55,嗯,可能是。也许我误解了这个问题。

标签: python python-2.7 python-3.x scikit-learn


【解决方案1】:

请注意,如果您想了解有关学习过程的更多信息,可以使用vebose 标记:

X = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]])
y = np.array([1, 1, 2, 2])
clf = SVC(verbose =True)
clf.fit(X, y)

输出:

optimization finished, #iter = 12
obj = -1.253423, rho = 0.000003
nSV = 4, nBSV = 0
Total nSV = 4

【讨论】:

    【解决方案2】:

    我没用过pyprind,但我用过progressbar。只需使用 -

    安装它
    pip install progressbar
    

    然后-

    from progressbar import ProgressBar
    pbar = ProgressBar()
    for x in pbar(range(45)):
        clf = SVC().fit(X_train, y_train)
    

    你可以走了。

    【讨论】:

    • 感谢您的帮助!
    • 我在安装时遇到问题...我现在就测试一下,稍等!谢谢!
    • 我终于有时间尝试这个解决方案了。但是,我相信它仍然适合 45 次......它花了将近 2:00 分钟才能完成......知道如何进行吗?感谢您的帮助!
    猜你喜欢
    • 2017-03-22
    • 2023-03-22
    • 2016-03-17
    • 2021-02-11
    • 2017-01-05
    • 2015-08-03
    • 2016-08-31
    • 2017-06-08
    • 2016-04-22
    相关资源
    最近更新 更多