0

I am trying to design a decision surface of decision trees trained on pairs of features in my dataset in 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).

How can I solve this problem in Google Colab?

Thanks.

1 Answers1

0

DecisionBoundaryDisplay was added in 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.

There are a few posts here already about upgrading the python version of Colab; start at Install Python 3.8 kernel in Google Colaboratory and view Linked/Related questions as needed.

Ben Reiniger
  • 10,517
  • 3
  • 16
  • 29