{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3266","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3266/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3266/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3266/events","html_url":"https://github.com/scikit-learn/scikit-learn/issues/3266","id":35415440,"number":3266,"title":"Many redundant prediction probabilities for test instances with sparse SVM","user":{"login":"cbmeyer","id":7852783,"avatar_url":"https://avatars.githubusercontent.com/u/7852783?v=3","gravatar_id":"","url":"https://api.github.com/users/cbmeyer","html_url":"https://github.com/cbmeyer","followers_url":"https://api.github.com/users/cbmeyer/followers","following_url":"https://api.github.com/users/cbmeyer/following{/other_user}","gists_url":"https://api.github.com/users/cbmeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/cbmeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbmeyer/subscriptions","organizations_url":"https://api.github.com/users/cbmeyer/orgs","repos_url":"https://api.github.com/users/cbmeyer/repos","events_url":"https://api.github.com/users/cbmeyer/events{/privacy}","received_events_url":"https://api.github.com/users/cbmeyer/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/labels/Bug","name":"Bug","color":"e10c02"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/milestones/12","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/milestones/12/labels","id":527004,"number":12,"title":"0.16","description":"","creator":{"login":"GaelVaroquaux","id":208217,"avatar_url":"https://avatars.githubusercontent.com/u/208217?v=3","gravatar_id":"","url":"https://api.github.com/users/GaelVaroquaux","html_url":"https://github.com/GaelVaroquaux","followers_url":"https://api.github.com/users/GaelVaroquaux/followers","following_url":"https://api.github.com/users/GaelVaroquaux/following{/other_user}","gists_url":"https://api.github.com/users/GaelVaroquaux/gists{/gist_id}","starred_url":"https://api.github.com/users/GaelVaroquaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GaelVaroquaux/subscriptions","organizations_url":"https://api.github.com/users/GaelVaroquaux/orgs","repos_url":"https://api.github.com/users/GaelVaroquaux/repos","events_url":"https://api.github.com/users/GaelVaroquaux/events{/privacy}","received_events_url":"https://api.github.com/users/GaelVaroquaux/received_events","type":"User","site_admin":false},"open_issues":79,"closed_issues":29,"state":"open","created_at":"2014-01-05T21:19:20Z","updated_at":"2015-01-28T08:15:10Z","due_on":"2016-01-31T05:00:00Z","closed_at":null},"comments":28,"created_at":"2014-06-10T19:20:09Z","updated_at":"2015-01-28T14:13:21Z","closed_at":null,"body":"I’m having an issue using the prediction probabilities for sparse SVM, where many of the predictions come out the same for my test instances.  These probabilities are produced during cross validation, and when I plot an ROC curve for the folds, the results look very strange, as there are a handful of clustered points on the graph.  Here is my cross validation code, I based it off of the samples on the scikit website:\r\n\r\n    skf = StratifiedKFold(y, n_folds=numfolds)\r\n\r\n    for train_index, test_index in skf:\r\n             #split the training and testing sets\r\n             X_train, X_test = X_scaled[train_index], X_scaled[test_index]\r\n             y_train, y_test = y[train_index], y[test_index]\r\n\r\n             #train on the subset for this fold\r\n             print 'Training on fold ' + str(fold)\r\n             classifier = svm.SVC(C=C_val, kernel='rbf', gamma=gamma_val, probability=True)\r\n             probas_ = classifier.fit(X_train, y_train).predict_proba(X_test)\r\n\r\n             #Compute ROC curve and area the curve\r\n             fpr, tpr, thresholds = roc_curve(y_test, probas_[:, 1])\r\n             mean_tpr += interp(mean_fpr, fpr, tpr)\r\n             mean_tpr[0] = 0.0\r\n             roc_auc = auc(fpr, tpr)\r\n\r\nI’m just trying to figure out if there’s something I’m obviously missing here, since I used this same training set and SVM parameters with libsvm and got much better results.  When I used libsvm and printed out the distances from the hyperplane for the CV test instances and then plotted the ROC, it came out much more like I expected, and a much better AUC.  Since the decision_function() method is not supported for sparse matrices, I cannot recreate this functionality in scikit, and therefore have to rely on the prediction probabilities.\r\n\r\nThere are 20k instances total, 10k positive and 10k negative, and I'm using 5-fold cross-validation.  In the cross-validation results, there are several prediction values for which there are 1k-2k samples that all have the same prediction value, and there are only 3600 distinct prediction values over all of the folds for cross-validation.  The resulting ROC looks like five big stair steps, with some little bits of fuzziness around the inner corners.\r\n\r\nI have many sparse features, so I'm hashing those into index ranges for different types of feature subsets, so one feature subset will be in the index range 1 million to 2 million, the next will be in the range 2 million to 3 million, etc.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments/71840320","html_url":"https://github.com/scikit-learn/scikit-learn/issues/3266#issuecomment-71840320","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3266","id":71840320,"user":{"login":"cbmeyer","id":7852783,"avatar_url":"https://avatars.githubusercontent.com/u/7852783?v=3","gravatar_id":"","url":"https://api.github.com/users/cbmeyer","html_url":"https://github.com/cbmeyer","followers_url":"https://api.github.com/users/cbmeyer/followers","following_url":"https://api.github.com/users/cbmeyer/following{/other_user}","gists_url":"https://api.github.com/users/cbmeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/cbmeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbmeyer/subscriptions","organizations_url":"https://api.github.com/users/cbmeyer/orgs","repos_url":"https://api.github.com/users/cbmeyer/repos","events_url":"https://api.github.com/users/cbmeyer/events{/privacy}","received_events_url":"https://api.github.com/users/cbmeyer/received_events","type":"User","site_admin":false},"created_at":"2015-01-28T14:13:21Z","updated_at":"2015-01-28T14:13:21Z","body":"The C value is 94.1605007514 and gamma value is 0.00456579534043.  I'll see if I can put together a smaller dataset that will reproduce the issue."}}