Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does importing 'comb' from scipy fail when using numpy 1.13.3?

I am working on feature selection and classification problems in Google Collab. I was able to execute the program with numpy version 1.11.3. Unfortunately, today I encountered an error using numpy(1.13.3) as scipy no longer supports 1.11.3 in Collab. I was working with numpy 1.11.3 because it just worked for me though it may be old. It seems 'comb' can be no longer imported in the python environment. How can I make this work with newer versions of numpy? Also, how and where do I check for such incompatibility issues for other libraries that may arise in the future?

I tried manually typing 'from scipy.misc import comb' and 'from scipy import comb' but it still doesn't work.

import numpy as np
from sklearn.feature_selection import SelectPercentile, f_classif
from time import time

np.seterr(divide='ignore', invalid='ignore');
selector=SelectPercentile(f_classif , percentile = 8)
t0 = time()
X_newDoS = selector.fit_transform(X_DoS,Y_DoS)
print ('Time =', time() - t0)

The error message I got was: "ImportError: cannot import name 'comb'"

like image 720
dEBA M Avatar asked Sep 05 '25 17:09

dEBA M


1 Answers

According to the doc of scipy,

from scipy.misc import comb 

has been deprecated since version 1.0.0. Should use

from scipy.special import comb 

instead.

https://docs.scipy.org/doc/scipy-1.2.1/reference/generated/scipy.misc.comb.html

like image 177
eric.li Avatar answered Sep 07 '25 16:09

eric.li