[英]How to solve ImportError: cannot import name 'DecisionBoundaryDisplay' from 'sklearn.inspection' in Google Colaboratory?
I am trying to design a decision surface of decision trees trained on pairs of features in my dataset in Google Colaboratory.我正在尝试设计一个决策树的决策面,该决策树是在 Google Colaboratory 的数据集中对特征对进行训练的。
Example Code:示例代码:
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.inspection import DecisionBoundaryDisplay
iris = load_iris()
But colab produces a error like, ImportError: cannot import name 'DecisionBoundaryDisplay' from 'sklearn.inspection' (/usr/local/lib/python3.7/dist-packages/sklearn/inspection/ init .py).但是 colab 会产生类似 ImportError: cannot import name 'DecisionBoundaryDisplay' from ' sklearn.inspection ' (/usr/local/lib/python3.7/dist-packages/sklearn/inspection/init.py) 的错误。
How can I solve this problem in Google Colab?我怎样才能在 Google Colab 中解决这个问题?
Thanks.谢谢。
DecisionBoundaryDisplay
was added in sklearn v1.1. DecisionBoundaryDisplay
是在 sklearn v1.1 中添加的。 At present, Colab has sklearn v1.0.2 by default, and you can't upgrade because sklv1.1 requires python>=v3.8 but Colab has with python3.7.15.目前Colab默认有sklearn v1.0.2,无法升级,因为sklv1.1要求python>=v3.8,而Colab有python3.7.15。
There are a few posts here already about upgrading the python version of Colab;这里已经有一些关于升级 Colab python 版本的帖子; start at Install Python 3.8 kernel in Google Colaboratory and view Linked/Related questions as needed.从在 Google Colaboratory 中安装 Python 3.8 kernel开始,并根据需要查看链接/相关问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.