Scaling Data In Scikit-learn Svm
While libsvm provides tools for scaling data, with Scikit-Learn (which should be based upon libSVM for the SVC classifier) I find no way to scale my data. Basically I want to use
Solution 1:
You have that functionality in sklearn.preprocessing
:
>>>from sklearn import preprocessing>>>X = [[ 1., -1., 2.],... [ 2., 0., 0.],... [ 0., 1., -1.]]>>>X_scaled = preprocessing.scale(X)>>>X_scaled
array([[ 0. ..., -1.22..., 1.33...],
[ 1.22..., 0. ..., -0.26...],
[-1.22..., 1.22..., -1.06...]])
The data will then have zero mean and unit variance.
Post a Comment for "Scaling Data In Scikit-learn Svm"