【问题标题】:How to silent an output from Prophet?如何使 Prophet 的输出静音?
【发布时间】:2021-04-08 12:01:59
【问题描述】:

我正在使用 Prophet(Facebook 的时间序列库),它产生了很多输出。像这样的东西: Prophet output

我已经沉默了一些这样的输出:

@contextmanager
def suppress_stdout():
    with open(os.devnull, "w") as devnull:
        old_stdout = sys.stdout
        sys.stdout = devnull
        try:  
            yield
        finally:
            sys.stdout = old_stdout

但它不会静默所有类型的输出,我如何静默所有类型?

【问题讨论】:

    标签: python output facebook-prophet


    【解决方案1】:

    我怀疑您正在使用类似 IPython 的环境,例如Jupyter 笔记本。然后您可以在单元格中使用%%capture magic command

    例如,

    %%capture
    output = do_some_verbose_things(args)
    

    默认情况下,它还捕获stderr,我认为您看到的输出将在那里。

    【讨论】:

    • 不幸的是,输出如下:“INFO:fbprophet:Making 4 predicts with cutoffs between...”(来自我的屏幕截图)仍然可见。
    • @josqa 有趣。那么请检查您在该包中使用的功能,它们可能有一些verbosesilent 参数。您可以调整它们,例如verbose=0silent=True。我不熟悉那个库,你没有分享产生的代码,所以我不确定它们是否有这样的参数。
    • 谢谢!是的,我先检查了这个,没有这个参数。
    猜你喜欢
    • 2021-05-09
    • 2021-08-18
    • 1970-01-01
    • 2011-01-18
    • 1970-01-01
    • 2015-03-10
    • 1970-01-01
    • 2011-03-24
    • 2015-08-25
    相关资源
    最近更新 更多