python - error with sklearn CalibratedClassifierCV and SVM -
i want use sklearn's calibratedclassifiercv in conjuction sklearn's svc make predictions multiclass (9 classes) prediction problem. when run it, following error. same code run no problem different model (i.e randomforestcalssifier).
kf = stratifiedshufflesplit(y, n_iter=1, test_size=0.2) clf = svm.svc(c=1,probability=true) sig_clf = calibratedclassifiercv(clf, method="isotonic", cv=kf) sig_clf.fit(x, y) traceback (most recent call last): file "<stdin>", line 1, in <module> file "/home/g/anaconda/lib/python2.7/site-packages/sklearn/calibration.py", line 166, in fit calibrated_classifier.fit(x[test], y[test]) file "/home/g/anaconda/lib/python2.7/site-packages/sklearn/calibration.py", line 309, in fit calibrator.fit(this_df, y[:, k], sample_weight) indexerror: index 9 out of bounds axis 1 size 9
this problem of svc using one-vs-one strategy, , therefore decision function having shape (n_samples, n_classes * (n_classes - 1) / 2)
. possible workaround callibratedclassifiercv(onevsrestclassifier(svc()))
. if want use sigmoidal calibration, can svc(probability=true)
, not use callibratedclassifiercv
.
we should fix svc decision function, think.
Comments
Post a Comment