我究竟做错了什么?意想不到的意外
What am I doing wrong? unexpected unindent
我在 python 中测试 ARIMA 时间序列模型,运行 中出现“IndentationError: unexpected unindent”消息。我试过在几个点上缩进和取消缩进都无济于事。所以我希望有人能指出我正确的方向。请查看下面的代码,它会导致以下错误:
File "<ipython-input-64-8f9bf4ba4a44>", line 13
results = mod.fit()
^
IndentationError: unexpected unindent
for param in pdq:
for param_seasonal in seasonal_pdq:
try:
mod = sm.tsa.statespace.SARIMAX(y,
order=param,
seasonal_order=param_seasonal,
enforce_stationarity=False,
enforce_invertibility=False)
results = mod.fit()
print('ARIMA{}x{}12 - AIC:{}'.format(param, param_seasonal,
results.aic))
except:
continue
错误消息尽可能清楚:您的缩进级别错误。以下作品:
for param in pdq:
for param_seasonal in seasonal_pdq:
try:
mod = sm.tsa.statespace.SARIMAX(
y,
order=param,
seasonal_order=param_seasonal,
enforce_stationarity=False, enforce_invertibility=False
)
results = mod.fit()
print('ARIMA{}x{}12 - AIC:{}'.format(
param,
param_seasonal,
results.aic
))
except:
continue
try 块有问题,try 块应该是这样的
try:
mod = sm.tsa.statespace.SARIMAX(
y,
order=param,
seasonal_order=param_seasonal,
enforce_stationarity=False, enforce_invertibility=False
)
results = mod.fit()
print('ARIMA{}x{}12 - AIC:{}'.format(
param,
param_seasonal,
results.aic
))
except:
continue
还建议使用任何现代 IDE 来消除缩进问题,
我在 python 中测试 ARIMA 时间序列模型,运行 中出现“IndentationError: unexpected unindent”消息。我试过在几个点上缩进和取消缩进都无济于事。所以我希望有人能指出我正确的方向。请查看下面的代码,它会导致以下错误:
File "<ipython-input-64-8f9bf4ba4a44>", line 13
results = mod.fit()
^
IndentationError: unexpected unindent
for param in pdq:
for param_seasonal in seasonal_pdq:
try:
mod = sm.tsa.statespace.SARIMAX(y,
order=param,
seasonal_order=param_seasonal,
enforce_stationarity=False,
enforce_invertibility=False)
results = mod.fit()
print('ARIMA{}x{}12 - AIC:{}'.format(param, param_seasonal,
results.aic))
except:
continue
错误消息尽可能清楚:您的缩进级别错误。以下作品:
for param in pdq:
for param_seasonal in seasonal_pdq:
try:
mod = sm.tsa.statespace.SARIMAX(
y,
order=param,
seasonal_order=param_seasonal,
enforce_stationarity=False, enforce_invertibility=False
)
results = mod.fit()
print('ARIMA{}x{}12 - AIC:{}'.format(
param,
param_seasonal,
results.aic
))
except:
continue
try 块有问题,try 块应该是这样的
try:
mod = sm.tsa.statespace.SARIMAX(
y,
order=param,
seasonal_order=param_seasonal,
enforce_stationarity=False, enforce_invertibility=False
)
results = mod.fit()
print('ARIMA{}x{}12 - AIC:{}'.format(
param,
param_seasonal,
results.aic
))
except:
continue
还建议使用任何现代 IDE 来消除缩进问题,