On Sun, Nov 06, 2011 at 09:41:31AM +0100, Gael Varoquaux wrote:
> Can you send us a small self-contained script that reproduces your
> problem, and we'll try to fix it ASAP.
Sure. This script reproduces the problem for me:
------------------------------------------------------------
from sklearn import svm
from scipy import array, arange
from scipy.sparse import lil_matrix, csr_matrix
from sklearn.cross_validation import StratifiedKFold
from sklearn.grid_search import GridSearchCV
from random import randint, shuffle
TUNED_PARAMS = [
{'kernel': ['rbf'], 'gamma': 10.0**arange(-2,-5,-.5),
'C': 10.0**arange(0,4,.5)},
{'kernel': ['linear'], 'C': 10.0**arange(0,4,.5)}]
tf = lil_matrix((1000,448))
for i in range(29000):
tf[randint(0,999),randint(0,447)] = 1
tf = csr_matrix(tf)
tc = [1]*500 + [0]*500
shuffle(tc)
tc = array(tc)
clf = GridSearchCV(svm.sparse.SVC(C=1), TUNED_PARAMS, n_jobs=10)
clf.fit(tf, tc, cv=StratifiedKFold(tc, 5, indices=True))
------------------------------------------------------------
And here's the error:
------------------------------------------------------------
$ python bug.py
Traceback (most recent call last):
File "bug.py", line 22, in <module>
clf.fit(tf, tc, cv=StratifiedKFold(tc, 5, indices=True))
File "/usr/lib/pymodules/python2.7/sklearn/grid_search.py", line 322, in fit
best_estimator.fit(X, y, **self.fit_params)
File "/usr/lib/pymodules/python2.7/sklearn/svm/sparse/base.py", line 112, in
fit
int(self.shrinking), int(self.probability))
File "libsvm.pyx", line 157, in sklearn.svm.sparse.libsvm.libsvm_sparse_train
(sklearn/svm/sparse/libsvm.c:1924)
ValueError: cannot resize this array: it does not own its data
------------------------------------------------------------
FWIW, I'm using the distribution-provided packages on Debian sid
(unstable). sklearn version is 0.9.0, Python 2.7.2, numpy is 1.5.1 and
scipy 0.9.0.
Sami
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general