小编Dan*_*nny的帖子

如何在 Jupyter Notebook 中隐藏错误消息?

有什么方法可以隐藏 jupyter 笔记本中的错误消息吗?我想在课堂上做笔记并写下一些代码片段,但当然这些代码实际上并没有运行。有没有办法隐藏错误消息(而不是警告消息)?

非常感谢!

python jupyter-notebook

5
推荐指数
1
解决办法
1万
查看次数

在 Python 类中定义和调用函数

我正在创建一个类,我希望在该类的方法中调用用户定义的函数。我还想在类定义中定义函数。但是,当我调用该类时,收到错误消息name *whatever function* is not defined

例如,这样的事情:

class ExampleClass():

    def __init__(self, number):
        self.number = number

    def plus_2_times_4(x):
        return(4*(x + 2))

    def arithmetic(self):
        return(plus_2_times_4(self.number))
Run Code Online (Sandbox Code Playgroud)

但是当我打电话时:

instance = ExampleClass(number = 4)
instance.arithmetic() 
Run Code Online (Sandbox Code Playgroud)

我收到错误消息。

所以基本上我想在一个步骤 ( def plus_2_times_4) 中定义函数,并在另一个步骤 (d ef arithmetic...) 中定义方法时使用该函数。这可能吗?

非常感谢!

python

1
推荐指数
2
解决办法
3245
查看次数

statsmodels ARIMA 预测,没有外生变量的未来值

我正在 statsmodels 中运行带有外生变量的 ARIMA 模型,并且我尝试在不知道外生变量的未来值的情况下对未来的多个步骤进行预测。exog中的选项需要results.forecast()样本值。我想知道是否可以在不知道这些值的情况下对未来多天进行预测?

如果问题不清楚,假设我将我的智商建模为时间序列变量,并将受教育年限作为外生变量。我在高中结束时训练模型,我想预测 4 年后我的智商,但我不知道我是否会继续上学。我可以在不知道自己的上学年数的情况下使用 statsmodels 进行预测吗?谢谢!

forecasting statsmodels arima

1
推荐指数
1
解决办法
1505
查看次数