machine learning - OneVsRestClassifier(svm.SVC()).predict() gives continous values -
i trying use y_scores=onevsrestclassifier(svm.svc()).predict() on datasets iris , titanic .the trouble getting y_scores continous values.like iris dataset getting :
[[ -3.70047231 -0.74209097 2.29720159] [ -1.93190155 0.69106231 -2.24974856] .....
i using onevsrestclassifier other classifier models knn,randomforest,naive bayes , giving appropriate results in form of
[[ 0 1 0] [ 1 0 1]...
etc on iris dataset .please help.
well not true.
>>> sklearn.multiclass import onevsrestclassifier >>> sklearn.svm import svc >>> sklearn.datasets import load_iris >>> iris = load_iris() >>> clf = onevsrestclassifier(svc()) >>> clf.fit(iris['data'], iris['target']) onevsrestclassifier(estimator=svc(c=1.0, cache_size=200, class_weight=none, coef0=0.0, degree=3, gamma=0.0, kernel='rbf', max_iter=-1, probability=false, random_state=none, shrinking=true, tol=0.001, verbose=false), n_jobs=1) >>> print clf.predict(iris['data']) [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2]
maybe called decision_function
instead (which match output dimension, predict supposed return vector, not matrix). then, svm returns signed distances each hyperplane, decision function mathematical perspective.
Comments
Post a Comment