Le 17 avril 2012 05:32, Dimitrios Pritsos <[email protected]> a écrit :
>
> Hello again
>
> I am trying to run an OneClassSVM() test:
>
> import sklearn.svm.sparse as sp_svm
>
> ocsvm = sp_svm.OneClassSVM(nu=0.5, kernel='linear')
>
> ocsvm.fit( ssp.csr_matrix(train_X, shape=train_X.shape, dtype=np.float64) )
>
>
>  and I am getting the following message:
>
> File
> "/home/dimitrios/Development_Workspace/webgenreidentification/src/experiments_lowbow.py",
> line 147, in evaluate
>     ocsvm.fit( ssp.csr_matrix(train_X, shape=train_X.shape,
> dtype=np.float64) )   #, train_Y)
>   File
> "/usr/local/lib/python2.6/dist-packages/sklearn/svm/sparse/classes.py", line
> 175, in fit
>     X, [], sample_weight=sample_weight)
>   File "/usr/local/lib/python2.6/dist-packages/sklearn/svm/sparse/base.py",
> line 22, in fit
>     return super(SparseBaseLibSVM, self).fit(X, y, sample_weight)
>   File "/usr/local/lib/python2.6/dist-packages/sklearn/svm/base.py", line
> 150, in fit
>     fit(X, y, sample_weight)
>   File "/usr/local/lib/python2.6/dist-packages/sklearn/svm/base.py", line
> 263, in _sparse_fit
>     % (X.shape, y.shape))
> ValueError: X and y have incompatible shapes: (180, 255) vs (0,)
> Note: Sparse matrices cannot be indexed w/boolean masks (use `indices=True`
> in CV).

It seems that sparse.OneClassSVM has been broken by the last
refactoring: there is no `y` hence for unsupervised models so the
error message does not make sense.

Anyway sklearn.svm.sparse.OneClassSVM should just be a backward compat
estimator. sklearn.svm.OneClassSVM should work with both dense and
sparse data now. Can you confirm that you don't have the issue with
sklearn.svm.OneClassSVM ?

If so we might just remove the sklearn.svm.sparse.OneClassSVM
implementation and create an alias to sklearn.svm.OneClassSVM for the
backward compat instead.

-- 
Olivier
http://twitter.com/ogrisel - http://github.com/ogrisel

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to