anaconda 中 scikit-learn包 安裝升級問題


在anaconda 環境下,jupyter中編寫監督學習代碼,繪制決策樹,出現如下錯誤:

問題: ImportError: cannot import name ‘plot_tree’ 或 module ‘sklearn.tree’ has no attribute ‘plot_tree’

        意思就是說,找不到plot_tree函數,經過查閱百度,知道,plot_tree 函數是在 scikit-learn 的 0.21 版本加入的,所以需要 0.21 之后的的版本才能使用這個函數,如果環境中的 scikit-learn 低於這個版本,在導入或調用 plot_tree 函數時自然就會報錯了。

  接下來,解決辦法:

  1. 在prompt環境下,命令行模式打開

  2. 換源

  清華源 官方網址:https://mirror.tuna.tsinghua.edu.cn/help/anaconda/
  conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  conda config --set show_channel_urls yes

  3. 升級
  conda install scikit-learn=0.24.2
————————————————
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM