I am trying to import imblearn into my python notebook after installing the required modules. However, I am getting the following error:
Additional info: I am using a virtual environment in Visual Studio Code.
I’ve made sure that venv was selected as interpreter and as the notebook kernel. I’ve reloaded the window and restarted the kernel several times. I have also uninstalled and installed imbalanced-learn and scikit-learn several times, with and without "–upgrade". I’m still getting the same error.
Edit: Full traceback of error
{
"name": "ImportError",
"message": "cannot import name '_MissingValues' from 'sklearn.utils._param_validation' (c:\Users\wen\OneDrive\Desktop\Colab_Notebooks\.venv\Lib\site-packages\sklearn\utils\_param_validation.py)",
"stack": "u001b[1;31m---------------------------------------------------------------------------u001b[0mnu001b[1;31mImportErroru001b[0m Traceback (most recent call last)nCell u001b[1;32mIn[1], line 1u001b[0mnu001b[1;32m----> 1u001b[0m u001b[39mimportu001b[39;00m u001b[39mimblearnu001b[39;00mnu001b[0;32m 2u001b[0m u001b[39m# Data Processingu001b[39;00mnu001b[0;32m 3u001b[0m u001b[39mimportu001b[39;00m u001b[39mpandasu001b[39;00m u001b[39masu001b[39;00m u001b[39mpdu001b[39;00mnnFile u001b[1;32mc:\Users\wen\OneDrive\Desktop\Colab_Notebooks\.venv\Lib\site-packages\imblearn\__init__.py:52u001b[0mnu001b[0;32m 48u001b[0m sysu001b[39m.u001b[39mstderru001b[39m.u001b[39mwrite(u001b[39m"u001b[39mu001b[39mPartial import of imblearn during the build process.u001b[39mu001b[39m\nu001b[39;00mu001b[39m"u001b[39m)nu001b[0;32m 49u001b[0m u001b[39m# We are not importing the rest of scikit-learn during the buildu001b[39;00mnu001b[0;32m 50u001b[0m u001b[39m# process, as it may not be compiled yetu001b[39;00mnu001b[0;32m 51u001b[0m u001b[39melseu001b[39;00m:nu001b[1;32m---> 52u001b[0m u001b[39mfromu001b[39;00m u001b[39m.u001b[39;00m u001b[39mimportu001b[39;00m (nu001b[0;32m 53u001b[0m combine,nu001b[0;32m 54u001b[0m ensemble,nu001b[0;32m 55u001b[0m exceptions,nu001b[0;32m 56u001b[0m metrics,nu001b[0;32m 57u001b[0m over_sampling,nu001b[0;32m 58u001b[0m pipeline,nu001b[0;32m 59u001b[0m tensorflow,nu001b[0;32m 60u001b[0m under_sampling,nu001b[0;32m 61u001b[0m utils,nu001b[0;32m 62u001b[0m )nu001b[0;32m 63u001b[0m u001b[39mfromu001b[39;00m u001b[39m.u001b[39;00mu001b[39m_versionu001b[39;00m u001b[39mimportu001b[39;00m __version__nu001b[0;32m 64u001b[0m u001b[39mfromu001b[39;00m u001b[39m.u001b[39;00mu001b[39mbaseu001b[39;00m u001b[39mimportu001b[39;00m FunctionSamplernnFile u001b[1;32mc:\Users\wen\OneDrive\Desktop\Colab_Notebooks\.venv\Lib\site-packages\imblearn\combine\__init__.py:5u001b[0mnu001b[0;32m 1u001b[0m u001b[39m"""The :mod:`imblearn.combine` provides methods which combineu001b[39;00mnu001b[0;32m 2u001b[0m u001b[39mover-sampling and under-sampling.u001b[39;00mnu001b[0;32m 3u001b[0m u001b[39m"""u001b[39;00mnu001b[1;32m----> 5u001b[0m u001b[39mfromu001b[39;00m u001b[39m.u001b[39;00mu001b[39m_smote_ennu001b[39;00m u001b[39mimportu001b[39;00m SMOTEENNnu001b[0;32m 6u001b[0m u001b[39mfromu001b[39;00m u001b[39m.u001b[39;00mu001b[39m_smote_tomeku001b[39;00m u001b[39mimportu001b[39;00m SMOTETomeknu001b[0;32m 8u001b[0m __all__ u001b[39m=u001b[39m [u001b[39m"u001b[39mu001b[39mSMOTEENNu001b[39mu001b[39m"u001b[39m, u001b[39m"u001b[39mu001b[39mSMOTETomeku001b[39mu001b[39m"u001b[39m]nnFile u001b[1;32mc:\Users\wen\OneDrive\Desktop\Colab_Notebooks\.venv\Lib\site-packages\imblearn\combine\_smote_enn.py:12u001b[0mnu001b[0;32m 9u001b[0m u001b[39mfromu001b[39;00m u001b[39msklearnu001b[39;00mu001b[39m.u001b[39;00mu001b[39mbaseu001b[39;00m u001b[39mimportu001b[39;00m clonenu001b[0;32m 10u001b[0m u001b[39mfromu001b[39;00m u001b[39msklearnu001b[39;00mu001b[39m.u001b[39;00mu001b[39mutilsu001b[39;00m u001b[39mimportu001b[39;00m check_X_ynu001b[1;32m---> 12u001b[0m u001b[39mfromu001b[39;00m u001b[39m.u001b[39;00mu001b[39m.u001b[39;00mu001b[39mbaseu001b[39;00m u001b[39mimportu001b[39;00m BaseSamplernu001b[0;32m 13u001b[0m u001b[39mfromu001b[39;00m u001b[39m.u001b[39;00mu001b[39m.u001b[39;00mu001b[39mover_samplingu001b[39;00m u001b[39mimportu001b[39;00m SMOTEnu001b[0;32m 14u001b[0m u001b[39mfromu001b[39;00m u001b[39m.u001b[39;00mu001b[39m.u001b[39;00mu001b[39mover_samplingu001b[39;00mu001b[39m.u001b[39;00mu001b[39mbaseu001b[39;00m u001b[39mimportu001b[39;00m BaseOverSamplernnFile u001b[1;32mc:\Users\wen\OneDrive\Desktop\Colab_Notebooks\.venv\Lib\site-packages\imblearn\base.py:21u001b[0mnu001b[0;32m 18u001b[0m u001b[39mfromu001b[39;00m u001b[39msklearnu001b[39;00mu001b[39m.u001b[39;00mu001b[39mutilsu001b[39;00mu001b[39m.u001b[39;00mu001b[39mmulticlassu001b[39;00m u001b[39mimportu001b[39;00m check_classification_targetsnu001b[0;32m 20u001b[0m u001b[39mfromu001b[39;00m u001b[39m.u001b[39;00mu001b[39mutilsu001b[39;00m u001b[39mimportu001b[39;00m check_sampling_strategy, check_target_typenu001b[1;32m---> 21u001b[0m u001b[39mfromu001b[39;00m u001b[39m.u001b[39;00mu001b[39mutilsu001b[39;00mu001b[39m.u001b[39;00mu001b[39m_param_validationu001b[39;00m u001b[39mimportu001b[39;00m validate_parameter_constraintsnu001b[0;32m 22u001b[0m u001b[39mfromu001b[39;00m u001b[39m.u001b[39;00mu001b[39mutilsu001b[39;00mu001b[39m.u001b[39;00mu001b[39m_validationu001b[39;00m u001b[39mimportu001b[39;00m ArraysTransformernu001b[0;32m 25u001b[0m u001b[39mclassu001b[39;00m u001b[39mSamplerMixinu001b[39;00m(BaseEstimator, metaclassu001b[39m=u001b[39mABCMeta):nnFile u001b[1;32mc:\Users\wen\OneDrive\Desktop\Colab_Notebooks\.venv\Lib\site-packages\imblearn\utils\_param_validation.py:908u001b[0mnu001b[0;32m 906u001b[0m u001b[39mfromu001b[39;00m u001b[39msklearnu001b[39;00mu001b[39m.u001b[39;00mu001b[39mutilsu001b[39;00mu001b[39m.u001b[39;00mu001b[39m_param_validationu001b[39;00m u001b[39mimportu001b[39;00m generate_valid_param u001b[39m# noqau001b[39;00mnu001b[0;32m 907u001b[0m u001b[39mfromu001b[39;00m u001b[39msklearnu001b[39;00mu001b[39m.u001b[39;00mu001b[39mutilsu001b[39;00mu001b[39m.u001b[39;00mu001b[39m_param_validationu001b[39;00m u001b[39mimportu001b[39;00m validate_parameter_constraints u001b[39m# noqau001b[39;00mnu001b[1;32m--> 908u001b[0m u001b[39mfromu001b[39;00m u001b[39msklearnu001b[39;00mu001b[39m.u001b[39;00mu001b[39mutilsu001b[39;00mu001b[39m.u001b[39;00mu001b[39m_param_validationu001b[39;00m u001b[39mimportu001b[39;00m (nu001b[0;32m 909u001b[0m HasMethods,nu001b[0;32m 910u001b[0m Hidden,nu001b[0;32m 911u001b[0m Interval,nu001b[0;32m 912u001b[0m Options,nu001b[0;32m 913u001b[0m StrOptions,nu001b[0;32m 914u001b[0m _ArrayLikes,nu001b[0;32m 915u001b[0m _Booleans,nu001b[0;32m 916u001b[0m _Callables,nu001b[0;32m 917u001b[0m _CVObjects,nu001b[0;32m 918u001b[0m _InstancesOf,nu001b[0;32m 919u001b[0m _IterablesNotString,nu001b[0;32m 920u001b[0m _MissingValues,nu001b[0;32m 921u001b[0m _NoneConstraint,nu001b[0;32m 922u001b[0m _PandasNAConstraint,nu001b[0;32m 923u001b[0m _RandomStates,nu001b[0;32m 924u001b[0m _SparseMatrices,nu001b[0;32m 925u001b[0m _VerboseHelper,nu001b[0;32m 926u001b[0m make_constraint,nu001b[0;32m 927u001b[0m validate_params,nu001b[0;32m 928u001b[0m )nnu001b[1;31mImportErroru001b[0m: cannot import name '_MissingValues' from 'sklearn.utils._param_validation' (c:\Users\wen\OneDrive\Desktop\Colab_Notebooks\.venv\Lib\site-packages\sklearn\utils\_param_validation.py)"
}
The versions of the modules are as follows:
scikit-learn 1.3.0
imblearn 0.0
imbalanced-learn 0.10.1
2
Answers
I was having the same issue, downgrading to scikit-learn 1.2.2 fixed it for me
I have the Same issue I restart My Kernal(In Pycharm Jupiter) it solve For me