how to solve errors in sklearn library for gmm - python

I imported pickle
import _pickle as cPickle
and I get this error
Traceback (most recent call last):
models = [cPickle.load(open(fname,'rb')) for fname in gmm_files]
models = [cPickle.load(open(fname,'rb')) for fname in gmm_files]
ModuleNotFoundError: No module named 'sklearn.mixture.gmm'

You most likely have a wrong scikit learn version. The module sklearn.mixture.gmm is deprecated since version 0.18 and was removed in v0.20. So you have some Options:
Downgrade your scikit learn
Example:
pip uninstall scikit-learn
pip install scikit-learn==0.19.2
Change your code so that it it tries to import from sklearn.mixture import GaussianMixture

Related

error while using scikit-learn in jupyter

so i'm working on a project in jupyter and have encountered a problem with the scikit-learn library.
I have successfully installed it using the command pip install scikit-learn, so it's already satisfied, but when I import it using the commands
from sk_learn.feature_extraction.text import CountVectorizer
and from sk_learn.feature_extraction.text import TfidVectorizer it gives me an error.
this is the error:---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_17216/1887820170.py in <module>
----> 1 from sk_learn.feature_extraction.text import CountVectorizer
2 from sk_learn.feature_extraction.text import TfidVectorizer
ModuleNotFoundError: No module named 'sk_learn'

cannot import name 'SMOTEN' from 'imblearn.over_sampling'

SMOTE and SMOTENC is working. But unable to use SMOTEN.
I tried solution in this. But still only for SMOTEN it returns the error,
ImportError: cannot import name 'SMOTEN' from 'imblearn.over_sampling'.
I am using Jupyter Notebook and below is the snippet of error returned.
ImportError Traceback (most recent call last)
<ipython-input-3-222dc3b0b449> in <module>
1 #import imblearn library
----> 2 from imblearn.over_sampling import SMOTEN
It solved after upgrading to Version 0.8.0 of Imbalanced-Learn. Because I found updations in imbalanced-learn releases of SMOTEN
Previous version I had:
import imblearn
print("Imbalanced-Learn", imblearn.__version__)
Imbalanced-Learn 0.7.0
Now SMOTEN is working after upgrading to Imbalanced-Learn 0.8.0

cannot import sklearn even though it is installed successfully

I have installed sklearn through pip successfully using this command:
$pip install -U scikit-learn
But I cannot import it.
import sklearn
Result:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-b7c74cbf5af0> in <module>
----> 1 import sklearn
ModuleNotFoundError: No module named 'sklearn'
Please help
You might want to try installing scikit-learn: pip install scikit-learn
Try pip3 install sklearn.
This will install the libraries you need for python 3.

How to resolve error importing stats.scipy.loguniform

When importing 'loguniform' from scipy.stats i get an importerror.
Both in colab.google and jupyter.
I am running python 3.7.
scipy version 1.3.0
I even just upgraded to version 1.4.1, still the same error.
code:
from scipy.stats import loguniform
error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-b01b9ec1c262> in <module>
----> 1 from scipy.stats import loguniform
ImportError: cannot import name 'loguniform' from 'scipy.stats'
other distributions load just fine,
from scipy.stats import uniform
no problem.
For Python 3 SciPy version 1.4.0 or higher should allow you to install loguniform.
So, type import scipy, then type print(scipy.__version__) and make sure 1.4.0 or newer is installed, then type from loguniform import scripy.stats.
You have the import backwards. You are importing scipy.stats from the library loguniform.
Try:
from loguniform import scripy.stats
You can reference the Library description for more details on the uses of the library Here

Why I cannot import 'make_vec_env' from stable baselines?

I have some problems with the example of stable-baselines and look forward to your help.
The environment is set as:
Windows 10
spyder 3.6
tensorflow 1.4.0
gym 0.15.4
stable_baselines 2.8.0
However, I cannot import:
from stable_baselines.common import make_vec_env
The error is:
Traceback (most recent call last):
File "<ipython-input-96-9dcb30379014>", line 1, in <module>
from stable_baselines.common import make_vec_env
ImportError: cannot import name 'make_vec_env'
If this is the module we are talking about.
https://github.com/hill-a/stable-baselines
Seems like there was an issue that has been solved in 2.9.0:
https://github.com/araffin/rl-baselines-zoo/issues/51
Upgrade your stable-baselines:
pip install stable-baselines==2.9.0
And then it should be enough to use:
from stable_baselines.common.cmd_util import make_vec_env

Categories