Skip to content

Instantly share code, notes, and snippets.

@amueller
Created September 2, 2012 13:52
Show Gist options
  • Save amueller/3599098 to your computer and use it in GitHub Desktop.
Save amueller/3599098 to your computer and use it in GitHub Desktop.
sparse svm error
import numpy as np
from scipy import sparse
from sklearn import svm
from nose.tools import assert_raises
X = np.array([[-2, -1], [-1, -1], [-1, -2], [1, 1], [1, 2], [2, 1]])
X_sp = sparse.lil_matrix(X)
Y = [1, 1, 1, 2, 2, 2]
sp = svm.sparse.SVC(C=1, kernel=lambda x, y: x * y.T, probability=True)
assert_raises(ValueError, sp.fit, X_sp, Y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment