简体   繁体   English

如何解决 ImportError: cannot import name 'DecisionBoundaryDisplay' from 'sklearn.inspection' in Google Colaboratory?

[英]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.

相关问题 ImportError:无法从“sklearn.inspection”导入名称“DecisionBoundaryDisplay” - ImportError: cannot import name 'DecisionBoundaryDisplay' from 'sklearn.inspection' 导入错误:无法从“sklearn.neighbors._base”导入名称“克隆” - ImportError: cannot import name 'clone' from 'sklearn.neighbors._base 如何修复“ImportError: cannot import name '_raise_dep_warning_if_not_pytest' from 'sklearn.utils.deprecation'”? - How to fix “ImportError: cannot import name '_raise_dep_warning_if_not_pytest' from 'sklearn.utils.deprecation'”? python 3.4“ ImportError:无法导入名称'数据集'”中的sklearn - sklearn in Python 3.4 “ImportError: cannot import name 'datasets'” sklearn ImportError:无法导入名称 plot_roc_curve - sklearn ImportError: cannot import name plot_roc_curve lazypredict.Supervised.LazyClassifier。 ImportError:无法从“sklearn.utils.deprecation”导入名称“_raise_dep_warning_if_not_pytest” - lazypredict.Supervised.LazyClassifier. ImportError: Cannot import name '_raise_dep_warning_if_not_pytest' from 'sklearn.utils.deprecation' ImportError:无法导入名称VarianceThreshold - ImportError: cannot import name VarianceThreshold 无法从“sklearn.metrics”导入名称“RocCurveDisplay” - cannot import name 'RocCurveDisplay' from 'sklearn.metrics' 无法从“sklearn.ensemble”导入名称“StackingClassifier” - cannot import name 'StackingClassifier' from 'sklearn.ensemble' 导入错误:无法从“contractions”导入名称“CONTRACTION_MAP” - ImportError: cannot import name 'CONTRACTION_MAP' from 'contractions'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM