You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Google Colab中导入pmdarima的auto_arima遇numpy版本兼容错误

解决pmdarima导入时的numpy版本兼容性错误

错误原因

该错误属于二进制兼容性冲突:pmdarima预编译的二进制文件依赖的numpy版本与当前Google Colab环境中安装的numpy版本不匹配,导致C头文件期望的numpy.dtype大小(96)和实际Python对象的大小(88)不一致。

解决方案

步骤1:卸载冲突包

先移除当前环境中可能存在冲突的pmdarima和numpy版本:

!pip uninstall -y pmdarima numpy

步骤2:重新安装兼容版本

安装经过验证的兼容版本组合,或让pip自动处理依赖兼容性:

# 安装指定兼容版本(推荐)
!pip install numpy==1.23.5 pmdarima

# 或让pip自动适配最新兼容版本
!pip install --no-cache-dir pmdarima

步骤3:重启Colab运行时

执行完安装命令后,点击Colab界面顶部的**「运行时」>「重启运行时」**,确保新安装的包生效。

修正后的完整代码

# 安装兼容依赖
!pip install numpy==1.23.5 pmdarima

# 导入auto_arima函数
from pmdarima.arima import auto_arima

# 加载数据集
data = medical_timeseries

# 运行auto_arima寻找最优ARIMA参数
auto_arima_model = auto_arima(train_set, start_p=1, start_q=1,
                          test='adf',       # 使用ADF检验确定最优d值
                          max_p=3, max_q=3, # p和q的最大取值
                          m=1,              # 时间序列频率(非季节性设为1)
                          d=optimal_d,      # 传入预先计算的最优d值
                          seasonal=True,    # 启用季节性模型
                          start_P=0, 
                          D=0, 
                          trace=True,
                          error_action='ignore',  
                          suppress_warnings=True, 
                          stepwise=True)

# 输出模型摘要
print(auto_arima_model.summary())

内容的提问来源于stack exchange,提问作者amlk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 14:13:12