-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: module 'sklearn.externals' #101
Comments
Hey @hcp4715 ! have you imported sklearn in your env ?
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 |
For an easy way to fix this is to reverse to an earlier version of scikit-learn A more definite would be to remove references to externals.joblib here NeuroKit.py/neurokit/bio/bio_ecg.py Line 357 in c958934
and use joblib directly if quality_model == "default":
quality_model = Path.materials() + 'heartbeat_classification.model'
model = joblib.load(quality_model) |
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 dom.makowski@gmail.com). I could set up the repo in which we could start discussing ideas, design, roadmap, bugs, priorities and so on |
Thanks, Louis. I think maybe install an early version will solve this. |
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. |
Some changes suggested there: 06890a4 |
I have tried this, and the following error appears:
|
@anniezhi please consider using NeuroKit2 (https://github.com/neuropsychology/NeuroKit) which should work |
Dear experts,
I really happy that there is a python package for psychophysiological data!
I am trying to run the tutorial codes (https://neurokit.readthedocs.io/en/latest/tutorials/Bio.html) on my PC, but encountered this error.
Seems that I used an newer sklearn package, which no longer has 'joblib' module, but not very sure. Your help will be highly appreciated.
Here is information about my settings:
OS: Win 10, running on AMD64
Packages:
Python 3.7.4
IPython 7.8.0
Neurokit 0.2.8
pandas 0.25.1
Numpy 1.16.4
seaborn 0.9.0
sklearn 0.21.2
More specifically, I run this code:
bio = nk.bio_process(ecg=df["ECG"], rsp=df["RSP"], eda=df["EDA"], add=df["Photosensor"], sampling_rate=100)
and here comes the error message:
AttributeError Traceback (most recent call last)
in
1 # process the signals
----> 2 bio = nk.bio_process(ecg=df["ECG"], rsp=df["RSP"], eda=df["EDA"], add=df["Photosensor"], sampling_rate=100)
3
4 # plot the processed dataframe, normalizing all variables
5 nk.z_score(bio["df"]).plot()
~\Anaconda3\envs\biosigPy\lib\site-packages\neurokit\bio\bio_meta.py in bio_process(ecg, rsp, eda, emg, add, sampling_rate, age, sex, position, ecg_filter_type, ecg_filter_band, ecg_filter_frequency, ecg_segmenter, ecg_quality_model, ecg_hrv_features, eda_alpha, eda_gamma, scr_method, scr_treshold, emg_names, emg_envelope_freqs, emg_envelope_lfreq, emg_activation_treshold, emg_activation_n_above, emg_activation_n_below)
123 # ECG & RSP
124 if ecg is not None:
--> 125 ecg = ecg_process(ecg=ecg, rsp=rsp, sampling_rate=sampling_rate, filter_type=ecg_filter_type, filter_band=ecg_filter_band, filter_frequency=ecg_filter_frequency, segmenter=ecg_segmenter, quality_model=ecg_quality_model, hrv_features=ecg_hrv_features, age=age, sex=sex, position=position)
126 processed_bio["ECG"] = ecg["ECG"]
127 if rsp is not None:
~\Anaconda3\envs\biosigPy\lib\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)
117 # ===============
118 if quality_model is not None:
--> 119 quality = ecg_signal_quality(cardiac_cycles=processed_ecg["ECG"]["Cardiac_Cycles"], sampling_rate=sampling_rate, rpeaks=processed_ecg["ECG"]["R_Peaks"], quality_model=quality_model)
120 processed_ecg["ECG"].update(quality)
121 processed_ecg["df"] = pd.concat([processed_ecg["df"], quality["ECG_Signal_Quality"]], axis=1)
~\Anaconda3\envs\biosigPy\lib\site-packages\neurokit\bio\bio_ecg.py in ecg_signal_quality(cardiac_cycles, sampling_rate, rpeaks, quality_model)
355
356 if quality_model == "default":
--> 357 model = sklearn.externals.joblib.load(Path.materials() + 'heartbeat_classification.model')
358 else:
359 model = sklearn.externals.joblib.load(quality_model)
AttributeError: module 'sklearn.externals' has no attribute 'joblib'
The text was updated successfully, but these errors were encountered: