Want to Stop Rebuilding "Expensive" Parts of your Flow? Explicit Builds are the Answer!READ MORE

No module named sklearn.linear_model.logistic when I do dataiku.Model(model_name).get_predictor()

Solved!
msr
Level 2
Level 2
No module named sklearn.linear_model.logistic when I do dataiku.Model(model_name).get_predictor()

I am trying to get the predictor name of a model, so that I can further get the coefficients of LR model,  but I am getting the following error-

"No module named sklearn.linear_model.logistic" when I do dataiku.Model(model_name).get_predictor()

 

Screenshot 2022-08-18 162638.png

Thanks,
Mahendra
0 Kudos
1 Solution
MiguelangelC
Dataiker
Dataiker

Hi,

It seems a package is missing in your code env. You can check that on Administration > Code Envs >  <select the notebook's code env> > Currently installed packages

Do you find 'scikit-learn' among them? If so, what version is it?, it may need to be updated.

If not, could you please make sure the code env used for this notebook has installed the 'Visual Machine Learning (scikit-learn, XGBoost,LightGBM)' package set?

View solution in original post

9 Replies
MiguelangelC
Dataiker
Dataiker

Hi,

It seems a package is missing in your code env. You can check that on Administration > Code Envs >  <select the notebook's code env> > Currently installed packages

Do you find 'scikit-learn' among them? If so, what version is it?, it may need to be updated.

If not, could you please make sure the code env used for this notebook has installed the 'Visual Machine Learning (scikit-learn, XGBoost,LightGBM)' package set?

msr
Level 2
Level 2
Author

Thanks for your response! It helped. The sklearn version in Visual ML recipe was older then the one I was using in the python recipe.

Thanks,
Mahendra
0 Kudos
vaishnavi
Level 2

@MiguelangelC I am still facing the same issue even after having the updated version of scikit-learn(version: 0.24.2) in my code envs installed packages. I also have installed the 'Visual Machine Learning (scikit-learn, XGBoost,LightGBM)' package set in my code env. Could you please help me in resolving this issue ?

0 Kudos
vaishnavi
Level 2

No module named sklearn.linear_model.logistic when I do model_1.get_predictor() where I am trying to load the already saved model.

Can anyone please help me here to resolve this issue ?

0 Kudos
sergeyd
Dataiker
Dataiker

Hi @vaishnavi 

logistic appeared in sklearn since 0.22 version:

https://github.com/scikit-learn/scikit-learn/blob/0.22.X/sklearn/linear_model/_logistic.py

Please make sure that you are using the correct code env and either stop the current kernel/ kill the session or "Force reload" the notebook to make sure you are loading the updated code env.  

0 Kudos
vaishnavi
Level 2

Hi @sergeyd I did check the python code env and made sure that am using scikit-learn == 0.24.2 version. I then force reloaded the python notebook as well. Still facing the same issue.

0 Kudos
sergeyd
Dataiker
Dataiker

I cannot reproduce the issue with scikit-learn>0.22 in the code env. 

0 Kudos
vaishnavi
Level 2

Hi @sergeyd I have attached few images related to the python env I am using and the packages version for better understanding of the issue.

0 Kudos
vaishnavi
Level 2

@sergeyd After updating the python version to 3.9, I am getting the below error when I execute 

model_1 = dataiku.Model(<model_id>)
pred_1 = model_1.get_predictor()

TypeError: an integer is required (got type bytes)

 

 

0 Kudos