【AI之路】Catboost报错AttributeError: ‘DataFrame‘ object has no attribute ‘iteritems‘,竟然是版本问题!

文章目录

  • 前言
  • 一、运行报错
  • 二、解决办法
  • 总结


前言


有2台电脑进行Catboost训练,新电脑训练一直正常,换到老电脑里总是报错,各种百度,还是没有解决问题,突然想到,会不会是版本环境问题。

一、运行报错

运行到:
train_pool = Pool(X_train, y_train, cat_features=cat_features)
报错:
AttributeError: ‘DataFrame’ object has no attribute ‘iteritems’

二、解决办法

升级Catboost库

pip install catboost -U -i https://pypi.tuna.tsinghua.edu.cn/simple

升级后,从catboost-1.0.6升级到catboost-1.2,再运行程序,一切OK。

(base) C:\Users\Administrator>pip install catboost -U -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: catboost in d:\programdata\anaconda3\lib\site-packages (1.0.6)
Collecting catboost
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/94/d5/9ba3dd322006a4b6d9d07d759baa8956081cfca512031adcbef67bf8bcbe/catboost-1.2-cp310-cp310-win_amd64.whl (101.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 101.0/101.0 MB 7.5 MB/s eta 0:00:00
Requirement already satisfied: matplotlib in d:\programdata\anaconda3\lib\site-packages (from catboost) (3.7.1)
Requirement already satisfied: numpy>=1.16.0 in d:\programdata\anaconda3\lib\site-packages (from catboost) (1.23.5)
Requirement already satisfied: pandas>=0.24 in d:\programdata\anaconda3\lib\site-packages (from catboost) (2.0.1)
Requirement already satisfied: six in d:\programdata\anaconda3\lib\site-packages (from catboost) (1.16.0)
Requirement already satisfied: graphviz in d:\programdata\anaconda3\lib\site-packages (from catboost) (0.20.1)
Requirement already satisfied: plotly in d:\programdata\anaconda3\lib\site-packages (from catboost) (5.9.0)
Requirement already satisfied: scipy in d:\programdata\anaconda3\lib\site-packages (from catboost) (1.10.0)
Requirement already satisfied: tzdata>=2022.1 in d:\programdata\anaconda3\lib\site-packages (from pandas>=0.24->catboost) (2023.3)
Requirement already satisfied: pytz>=2020.1 in d:\programdata\anaconda3\lib\site-packages (from pandas>=0.24->catboost) (2022.7)
Requirement already satisfied: python-dateutil>=2.8.2 in d:\programdata\anaconda3\lib\site-packages (from pandas>=0.24->catboost) (2.8.2)
Requirement already satisfied: contourpy>=1.0.1 in d:\programdata\anaconda3\lib\site-packages (from matplotlib->catboost) (1.0.5)
Requirement already satisfied: fonttools>=4.22.0 in d:\programdata\anaconda3\lib\site-packages (from matplotlib->catboost) (4.25.0)
Requirement already satisfied: pillow>=6.2.0 in d:\programdata\anaconda3\lib\site-packages (from matplotlib->catboost) (9.4.0)
Requirement already satisfied: kiwisolver>=1.0.1 in d:\programdata\anaconda3\lib\site-packages (from matplotlib->catboost) (1.4.4)
Requirement already satisfied: pyparsing>=2.3.1 in d:\programdata\anaconda3\lib\site-packages (from matplotlib->catboost) (3.0.9)
Requirement already satisfied: packaging>=20.0 in d:\programdata\anaconda3\lib\site-packages (from matplotlib->catboost) (22.0)
Requirement already satisfied: cycler>=0.10 in d:\programdata\anaconda3\lib\site-packages (from matplotlib->catboost) (0.11.0)
Requirement already satisfied: tenacity>=6.2.0 in d:\programdata\anaconda3\lib\site-packages (from plotly->catboost) (8.0.1)
Installing collected packages: catboost
  Attempting uninstall: catboost
    Found existing installation: catboost 1.0.6
    Uninstalling catboost-1.0.6:
      Successfully uninstalled catboost-1.0.6
Successfully installed catboost-1.2

(base) C:\Users\Administrator>

总结

踏破铁鞋无觅处,得来全不费工夫。

以后报错了,先检查库文件版本,甚至是Python版本。生产系统和测试系统要保持环境一致,避免不必要的麻烦。

你可能感兴趣的:(AI,人工智能)