Python ConvergenceWarning:最大可能会减慢内核运行时间?

Python ConvergenceWarning:最大可能会减慢内核运行时间?,python,time-series,forecasting,statsmodels,Python,Time Series,Forecasting,Statsmodels,我使用非常小的代码对象arma\u order\u select\u ic,以找到chor选择p值和q值的最低信息标准 我不确定我是否做得对,或者代码是否只是偶然发现了一些错误 在: 输出: 另外:它打印出三个矩阵样式列表(每个IC一个矩阵)以及最终建议: AIC-order: (7, 5) BIC-order: (7, 0) HQIC-order: (7, 0) 所以,整个事情似乎都起作用了 问题是,每次计算都会打印警告,大约需要30-60秒,即速度非常慢 我检查了相关的源代码(statsm

我使用非常小的代码对象
arma\u order\u select\u ic
,以找到chor选择p值和q值的最低信息标准

我不确定我是否做得对,或者代码是否只是偶然发现了一些错误

在:

输出:

另外:它打印出三个矩阵样式列表(每个IC一个矩阵)以及最终建议:

AIC-order: (7, 5)
BIC-order: (7, 0)
HQIC-order: (7, 0)
所以,整个事情似乎都起作用了

问题是,每次计算都会打印警告,大约需要30-60秒,即速度非常慢

我检查了相关的源代码(statsmodels/base/model.py)以及如何跳过CovergenceWarning的打印:

   #TODO: hardcode scale?
        if isinstance(retvals, dict):
            mlefit.mle_retvals = retvals
            if warn_convergence and not retvals['converged']:
                from warnings import warn
                from statsmodels.tools.sm_exceptions import ConvergenceWarning
                warn("Maximum Likelihood optimization failed to converge. "
                     "Check mle_retvals", ConvergenceWarning)

        mlefit.mle_settings = optim_settings
        return mlefit
因此,我尝试删除链接到ConvergenceWarning的if部分,但它不起作用

此部分来自相同的源代码:

mle_retvals : dict
    Contains the values returned from the chosen optimization method if
    full_output is True during the fit.  Available only if the model
    is fit by maximum likelihood.  See notes below for the output from
    the different methods. 
不告诉我在何处以及如何更改mle_retvals

如何检查mle_retvals和要更改的内容


有没有办法让ConvergenceWarning消失以加快计算速度

注释部分中的文档明确说明了如何加快速度…请参阅
fit\u kw
的文档字符串,以更改为
ARMA.fit
方法提供的参数。对于大量型号而言,这将是缓慢的。这是一个幼稚的实现,只是将它们成对地结合起来。尝试执行
method='css'
以获得更快的结果


我不知道您为什么要更改
mle\u retvals
。它在返回部分。这不是你直接改变的东西。您不必删除任何源代码来运行。那张支票是用来警告你事情出了差错的。也就是说,可能是导致这些警告的模型对于您的数据来说非常糟糕。

您可以尝试隐藏这些警告

import warnings

with warnings.catch_warnings():
    warnings.simplefilter("ignore", category=ConvergenceWarning)
    y = indexed_df
    res = arma_order_select_ic(y, max_ar=7, max_ma=7, ic=['aic', 'bic', 'hqic'], trend='c', fit_kw=dict(method='css'))
    print res
    print ('AIC-order: {}' .format(res.aic_min_order))
    print ('BIC-order: {}' .format(res.bic_min_order))
    print ('HQIC-order: {}' .format(res.hqic_min_order))
mle_retvals : dict
    Contains the values returned from the chosen optimization method if
    full_output is True during the fit.  Available only if the model
    is fit by maximum likelihood.  See notes below for the output from
    the different methods. 
import warnings

with warnings.catch_warnings():
    warnings.simplefilter("ignore", category=ConvergenceWarning)
    y = indexed_df
    res = arma_order_select_ic(y, max_ar=7, max_ma=7, ic=['aic', 'bic', 'hqic'], trend='c', fit_kw=dict(method='css'))
    print res
    print ('AIC-order: {}' .format(res.aic_min_order))
    print ('BIC-order: {}' .format(res.bic_min_order))
    print ('HQIC-order: {}' .format(res.hqic_min_order))