How to upgrade the sklearn library in sagemaker

Viewed 634

I noticed my Sagemaker (Amazon aws) jupyter notebook has an outdated version of the sklearn library.

when I run ! pip freeze I get:

sklearn==0.0

and when I run (with python) print(sklearn.__version__) I get

0.24.1

I'm not sure which one is my real version but I need 1.0.0 in order to use the from_predictions() method.

But when I am trying to run ! /home/ec2-user/anaconda3/envs/amazonei_mxnet_p36/bin/python -m pip install --upgrade sklearn I am getting the following output:

Requirement already satisfied: sklearn in /home/ec2-user/anaconda3/envs/amazonei_mxnet_p36/lib/python3.6/site-packages (0.0) Requirement already satisfied: scikit-learn in /home/ec2-user/anaconda3/envs/amazonei_mxnet_p36/lib/python3.6/site-packages (from sklearn) (0.24.1) Requirement already satisfied: scipy>=0.19.1 in /home/ec2-user/anaconda3/envs/amazonei_mxnet_p36/lib/python3.6/site-packages (from scikit-learn->sklearn) (1.5.3) Requirement already satisfied: joblib>=0.11 in /home/ec2-user/anaconda3/envs/amazonei_mxnet_p36/lib/python3.6/site-packages (from scikit-learn->sklearn) (1.0.1) Requirement already satisfied: threadpoolctl>=2.0.0 in /home/ec2-user/anaconda3/envs/amazonei_mxnet_p36/lib/python3.6/site-packages (from scikit-learn->sklearn) (2.1.0) Requirement already satisfied: numpy>=1.13.3 in /home/ec2-user/anaconda3/envs/amazonei_mxnet_p36/lib/python3.6/site-packages (from scikit-learn->sklearn) (1.19.5)

This is a very pupular library so it's weird if sagemaker cant upgrade it. Anyone has an idea what am I doing wrong?

1 Answers

I managed to update sklearn to version 0.24.2 via the following command:

!conda update scikit-learn --yes

To further update it, you probably have to also update Python, which is version 3.6 in the current conda_python3 kernel on Sagemaker.

It also looks promising to create your custom conda environment, as explained here: https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-add-external.html

Related