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

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

Related

Cannot import PyTorch/XLA for using TPU in CoLab with ImportError: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found

I want to use TPU to run a PyTorch program on Google Colab, and I installed PyTorch/XLA in my CoLab notebook by using this code:
!pip install cloud-tpu-client==0.10 torch==1.12.0 https://storage.googleapis.com/tpu-pytorch/wheels/tpuvm/torch_xla-1.12-cp38-cp38-linux_x86_64.whl
Then, I successfully imported pytorch by
import torch.
But, when I tried to import torch_xla by using import torch_xla, I got this error message:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-4-7fe098b5b807> in <module>
----> 1 import torch_xla
/usr/local/lib/python3.8/dist-packages/torch_xla/__init__.py in <module>
99 from ._patched_functions import _apply_patches
100 from .version import __version__
--> 101 import _XLAC
102
103
ImportError: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /usr/local/lib/python3.8/dist-packages/torch_xla/lib/libxla_computation_client.so)
---------------------------------------------------------------------------
The version of Python is Python 3.8.15.
I thought that perhaps downgrading the Python version to Python 3.7 might help, but is there a solution that does not need to downgrade the Python version?
https://storage.googleapis.com/tpu-pytorch/wheels/tpuvm/torch_xla-1.12-cp38-cp38-linux_x86_64.whl doesn't look like the correct colab wheel.
If you plan to run the colab on TPU, can you try the command !pip install cloud-tpu-client==0.10 torch==1.13.0 https://storage.googleapis.com/tpu-pytorch/wheels/colab/torch_xla-1.13-cp38-cp38-linux_x86_64.whl instead?

how to solve errors in sklearn library for gmm

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

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

Rodeo: ImportError: No module named 'statsmodels'

I just start to use Rodeo with Python 3.6.2. But there is an error when importing statsmodels under Windows 10. Here is the script:
import pandas as pd
import statsmodels.api as sm
import pylab as pl
import numpy as np
When highlight import statsmodels.api as sm and click Run line, there is an error:
>>> import statsmodels.api as sm
ImportError: No module named 'statsmodels'
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-6030a6549dc0> in <module>()
----> 1 import statsmodels.api as sm
ImportError: No module named 'statsmodels'
Then I downloaded the statsmodels from Github and installed it. Here is the output of pip list:
C:\Users\Documents\statsmodels-master\statsmodels-master>pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
Cython (0.26)
numpy (1.13.1)
pandas (0.20.3)
patsy (0.4.1)
pip (9.0.1)
python-dateutil (2.6.1)
pytz (2017.2)
scipy (0.19.1)
setuptools (28.8.0)
six (1.10.0)
statsmodels (0.8.0)
The output shows that statsmodels 0.8.0 is installed. But there is still importing error. It seems that the Rodeo has difficulty to see statsmodels.
UPDATE:
Here is the output of print(sys.pth) in Rodeo. There is a path for the statsmodels.
>>> print(sys.path)
['', 'C:\\Python36\\Scripts', 'c:\\python36\\lib\\site-packages\\statsmodels-0.8.0-py3.6-win-amd64.egg', 'C:\\Python36', 'C:\\Python36\\python36.zip', 'C:\\Python36\\DLLs', 'C:\\Python36\\lib', 'C:\\Python36\\lib\\site-packages', 'C:\\Python36\\lib\\site-packages\\patsy-0.4.1-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\pandas-0.20.3-py3.6-win-amd64.egg', 'C:\\Python36\\lib\\site-packages\\six-1.10.0-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\pytz-2017.2-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\python_dateutil-2.6.1-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\JunC\\.ipython']
I had the same issue. I solved it by adding the path to statsmodels to rodes>preferences>environment variables. In my case the path was "C:\ProgramData\Miniconda3\pkgs".
You might not have latest version of python2. Either update it, or use python3 instead.
To use python 3, use pip3 instead of pip. So run the following:
pip3 install statsmodels

Categories