I have searched for this error on stackoverflow, people have asked about it but I'm using and working in Kaggle which doesn't need any environment and library to install and set up. Help me out with this.
import warnings
warnings.filterwarnings('ignore')
from sklearn.datasets import load_iris
from sklearn.cluster import KMeans
from sklearn.inspection import DecisionBoundaryDisplay
# Fix the random seed for reproducibility
# !! Important !! : do not change this
seed = 1234
np.random.seed(seed)
DecisionBoundaryDisplay requires nightly build version of sklearn as it's a new feature. (https://scikit-learn.org/dev/modules/generated/sklearn.inspection.DecisionBoundaryDisplay.html)
If you run this in your Kaggle notebook:
import sklearn; sklearn.show_versions()
you should see that the version is insufficient. (I got sklearn 1.0.2)
Unfortunately, I don't think you can upgrade the sci-kit learn package in Kaggle further as the latest build requires a newer version of Python (3.8).
Below I used this code to get an error on purpose to see what are the available versions of sklearn, and you can see that all the later versions require Python 3.8.
!pip install scikit-learn==
ERROR: Ignored the following versions that require a different python version: 1.1.0 Requires-Python >=3.8; 1.1.0rc1 Requires-Python >=3.8; 1.1.1 Requires-Python >=3.8; 1.1.2 Requires-Python >=3.8; 1.1.3 Requires-Python >=3.8
ERROR: Could not find a version that satisfies the requirement scikit-learn== (from versions: 0.9, 0.10, 0.11, 0.12, 0.12.1, 0.13, 0.13.1, 0.14, 0.14.1, 0.15.0b1, 0.15.0b2, 0.15.0, 0.15.1, 0.15.2, 0.16b1, 0.16.0, 0.16.1, 0.17b1, 0.17, 0.17.1, 0.18, 0.18.1, 0.18.2, 0.19b2, 0.19.0, 0.19.1, 0.19.2, 0.20rc1, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.20.4, 0.21rc2, 0.21.0, 0.21.1, 0.21.2, 0.21.3, 0.22rc2.post1, 0.22rc3, 0.22, 0.22.1, 0.22.2, 0.22.2.post1, 0.23.0rc1, 0.23.0, 0.23.1, 0.23.2, 0.24.dev0, 0.24.0rc1, 0.24.0, 0.24.1, 0.24.2, 1.0rc1, 1.0rc2, 1.0, 1.0.1, 1.0.2)
ERROR: No matching distribution found for scikit-learn==
Based on this, it seems we are unable to change Python version in Kaggle environment: https://www.kaggle.com/questions-and-answers/210493
They also mention workarounds, how to use Kaggle APIs to access the dataset from your local environment, where you would be able to install the required versions for python/sklearn for your needs.