ImportError: No module named sklearn.cross_validation
It must relate to the renaming and deprecation of cross_validation sub-module to model_selection. Try substituting cross_validation to model_selection
It must relate to the renaming and deprecation of cross_validation sub-module to model_selection. Try substituting cross_validation to model_selection
If you’re using scikit-learn you can use sklearn.preprocessing.normalize: import numpy as np from sklearn.preprocessing import normalize x = np.random.rand(1000)*10 norm1 = x / np.linalg.norm(x) norm2 = normalize(x[:,np.newaxis], axis=0).ravel() print np.all(norm1 == norm2) # True
You can easily do this though, df.apply(LabelEncoder().fit_transform) EDIT2: In scikit-learn 0.20, the recommended way is OneHotEncoder().fit_transform(df) as the OneHotEncoder now supports string input. Applying OneHotEncoder only to certain columns is possible with the ColumnTransformer. EDIT: Since this original answer is over a year ago, and generated many upvotes (including a bounty), I should probably extend … Read more