ellawang44 / Breidablik

Interpolate lithium spectra and predict lithium abundance for late-type stars
MIT License
3 stars 0 forks source link

No module named 'sklearn.neural_network.multilayer_perceptron' #6

Closed robdjeff closed 4 months ago

robdjeff commented 4 months ago

Hi Ella, I've wrestled with this for quite a while (having used your code successfully in the past).

I'm using anaconda and have built a fresh environment to run breidablik v1.3.0 (installed with pip) using the following versions

numpy 1.24.3 pytorch 2.2.0 scikit-learn 1.1.3 scipy 1.10.1 sklearn-pandas 2.2.0

The breidablik package will import correctly but on executing

from breidablik.interpolate.nlte import Nlte mymodel = Nlte()

I obtain the following crash. Any ideas about how I might roll anything back to fix this (all the packages are the uptodate versions I believe)?

Traceback (most recent call last):

Cell In[7], line 2 mymodel = Nlte()

File C:\cygwin64\home\robdj\progs\python\Breidablik\breidablik\interpolate\nlte.py:28 in init self.models = [None, joblib.load(model_path), None]

File ~\anaconda3\envs\work\lib\site-packages\joblib\numpy_pickle.py:658 in load obj = _unpickle(fobj, filename, mmap_mode)

File ~\anaconda3\envs\work\lib\site-packages\joblib\numpy_pickle.py:577 in _unpickle obj = unpickler.load()

File ~\anaconda3\envs\work\lib\pickle.py:1212 in load dispatchkey[0]

File ~\anaconda3\envs\work\lib\pickle.py:1528 in load_global klass = self.find_class(module, name)

File ~\anaconda3\envs\work\lib\pickle.py:1579 in find_class import(module, level=0)

ModuleNotFoundError: No module named 'sklearn.neural_network.multilayer_perceptron'

ellawang44 commented 4 months ago

I think you're running an old version of the code.

Current version 1.3.0 does not make use of sklearn anymore. I'm relatively sure sklearn has not been used since v1.0.0. In particular, your error message says line 28 of nlte.py is using joblib which is throwing the error. But the current version of that file on line 28 does not use that: https://github.com/ellawang44/Breidablik/blob/v1.3.0/breidablik/interpolate/nlte.py

Have you tried a clean install? Is it possible that you have multiple versions of the code on your computer and the wrong one is on $PYTHONPATH?

robdjeff commented 4 months ago

Thank you very much - my mistake. Running the script in the folder containing the old installation! This is resolved.