Coder Social home page Coder Social logo

Comments (8)

sangfrois avatar sangfrois commented on June 6, 2024 1

Hey @hcp4715 !

have you imported sklearn in your env ?
it should look like this :

from sklearn.externals import joblib
 bio = nk.bio_process(ecg=df["ECG"], rsp=df["RSP"], eda=df["EDA"], add=df["Photosensor"], sampling_rate=100)

# plot the processed dataframe, normalizing all variables
 nk.z_score(bio["df"]).plot()

of course, you have to import Neurokit as nk and pandas as pd, as well, to use the functions and play around with the data. I've ran into this error and multiple times, untill i realized I just hadn't import the sklearn dependency.

Tell me if it works out for you

from neurokit.py.

louis-youpling avatar louis-youpling commented on June 6, 2024 1

For an easy way to fix this is to reverse to an earlier version of scikit-learn
pip install scikit-learn==0.20.0

A more definite would be to remove references to externals.joblib here

model = sklearn.externals.joblib.load(Path.materials() + 'heartbeat_classification.model')

and use joblib directly

if quality_model == "default":
    quality_model = Path.materials() + 'heartbeat_classification.model'
model = joblib.load(quality_model)

from neurokit.py.

DominiqueMakowski avatar DominiqueMakowski commented on June 6, 2024 1

I am super sorry about all this, as I currently don't have time to fix the module as much as I'd like it! Thanks a lot for all the people finding the workarounds 😍 💪

In fact, as I already mentioned somewhere, I plan on starting a massive overhaul, i.e., reimplementing some of the best stuff from neurokit almost from scratch, soon. As the package's scope has become quite fuzzy over the years, the goal of the refactoring is to make it safer, more flexible, more powerful, more documented, and overall better. This will probably be happening in a separated repo first (NeuroKit2?), with the aim of one day replacing the current version.

If you're by any chances interested in being somehow involved in this, please do let me know (e.g. via email [email protected]). I could set up the repo in which we could start discussing ideas, design, roadmap, bugs, priorities and so on ☺️

from neurokit.py.

hcp4715 avatar hcp4715 commented on June 6, 2024

For an easy way to fix this is to reverse to an earlier version of scikit-learn
pip install scikit-learn==0.20.0

A more definite would be to remove references to externals.joblib here

model = sklearn.externals.joblib.load(Path.materials() + 'heartbeat_classification.model')

and use joblib directly

if quality_model == "default":
    quality_model = Path.materials() + 'heartbeat_classification.model'
model = joblib.load(quality_model)

Thanks, Louis. I think maybe install an early version will solve this.

from neurokit.py.

hcp4715 avatar hcp4715 commented on June 6, 2024

Hey @hcp4715 !

have you imported sklearn in your env ?
it should look like this :

from sklearn.externals import joblib
 bio = nk.bio_process(ecg=df["ECG"], rsp=df["RSP"], eda=df["EDA"], add=df["Photosensor"], sampling_rate=100)

# plot the processed dataframe, normalizing all variables
 nk.z_score(bio["df"]).plot()

of course, you have to import Neurokit as nk and pandas as pd, as well, to use the functions and play around with the data. I've ran into this error and multiple times, untill i realized I just hadn't import the sklearn dependency.

Tell me if it works out for you

Dear François,

Thanks for your response, I tried, but I guess the problem is the version of sklearn ;-).

Because my data is mainly skin conductance, so I directly used eda process function, without testing bio_process further. BTW, the EDA data are processed very well.

from neurokit.py.

louis-youpling avatar louis-youpling commented on June 6, 2024

Some changes suggested there: 06890a4

from neurokit.py.

anniezhi avatar anniezhi commented on June 6, 2024

For an easy way to fix this is to reverse to an earlier version of scikit-learn
pip install scikit-learn==0.20.0

A more definite would be to remove references to externals.joblib here

model = sklearn.externals.joblib.load(Path.materials() + 'heartbeat_classification.model')

and use joblib directly

if quality_model == "default":
    quality_model = Path.materials() + 'heartbeat_classification.model'
model = joblib.load(quality_model)

I have tried this, and the following error appears:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-6-a95faca0bef5> in <module>
      1 # ECG analysis - neurokit
----> 2 result_org_2 = nk.ecg_process(X_train[100,:][~np.isnan(X_train[100,:])],
      3                               sampling_rate=300)

~/opt/anaconda3/envs/ML/lib/python3.8/site-packages/neurokit/bio/bio_ecg.py in ecg_process(ecg, rsp, sampling_rate, filter_type, filter_band, filter_frequency, segmenter, quality_model, hrv_features, age, sex, position)
    118     # ===============
    119     if quality_model is not None:
--> 120         quality = ecg_signal_quality(processed_ecg["ECG"]["Cardiac_Cycles"], sampling_rate, quality_model=quality_model)
    121         processed_ecg["ECG"].update(quality)
    122 

~/opt/anaconda3/envs/ML/lib/python3.8/site-packages/neurokit/bio/bio_ecg.py in ecg_signal_quality(cardiac_cycles, sampling_rate, quality_model)
    353     if quality_model == "default":
    354         quality_model = Path.materials() + 'heartbeat_classification.model'
--> 355     model = joblib.load(quality_model)
    356 
    357     # Initialize empty dict

~/opt/anaconda3/envs/ML/lib/python3.8/site-packages/joblib/numpy_pickle.py in load(filename, mmap_mode)
    583                     return load_compatibility(fobj)
    584 
--> 585                 obj = _unpickle(fobj, filename, mmap_mode)
    586     return obj

~/opt/anaconda3/envs/ML/lib/python3.8/site-packages/joblib/numpy_pickle.py in _unpickle(fobj, filename, mmap_mode)
    502     obj = None
    503     try:
--> 504         obj = unpickler.load()
    505         if unpickler.compat_mode:
    506             warnings.warn("The file '%s' has been generated with a "

~/opt/anaconda3/envs/ML/lib/python3.8/pickle.py in load(self)
   1208                     raise EOFError
   1209                 assert isinstance(key, bytes_types)
-> 1210                 dispatch[key[0]](self)
   1211         except _Stop as stopinst:
   1212             return stopinst.value

~/opt/anaconda3/envs/ML/lib/python3.8/pickle.py in load_global(self)
   1524         module = self.readline()[:-1].decode("utf-8")
   1525         name = self.readline()[:-1].decode("utf-8")
-> 1526         klass = self.find_class(module, name)
   1527         self.append(klass)
   1528     dispatch[GLOBAL[0]] = load_global

~/opt/anaconda3/envs/ML/lib/python3.8/pickle.py in find_class(self, module, name)
   1575             elif module in _compat_pickle.IMPORT_MAPPING:
   1576                 module = _compat_pickle.IMPORT_MAPPING[module]
-> 1577         __import__(module, level=0)
   1578         if self.proto >= 4:
   1579             return _getattribute(sys.modules[module], name)[0]

ModuleNotFoundError: No module named 'sklearn.externals.joblib'

from neurokit.py.

DominiqueMakowski avatar DominiqueMakowski commented on June 6, 2024

@anniezhi please consider using NeuroKit2 (https://github.com/neuropsychology/NeuroKit) which should work ☺️

from neurokit.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.