Hi Lars,

I completely forgot about `safe_sparse_dot` - thanks for the
clarification. I simply ran the test suite and noticed lots of errors
and attributed most of them to the `np.dot` issue. It turns out that
only one module (sparse.coordinate_decent) was affected. I'll submit a
patch immediately.

Nonetheless, when one tries to build scikit-learn with numpy dev-0.2
12 tests fail due to regressions. I traced the most common error to
the fact that `X -= mean` fails on numpy-dev if (X - mean) cannot be
cast safely to X.dtype. This is the case for X.dtype == int64 and mean
== float64. Here is the trace::

    X -= X_mean
    TypeError: Cannot cast ufunc subtract output from dtype('float64')
to dtype('int64') with casting rule 'same_kind'

I see two ways to deal with that: a) cast X to either float32 or
float64 or b) compute X = X - mean. I prefer b).

best,
 Peter

2011/11/11 Lars Buitinck <[email protected]>:
> 2011/11/10 Peter Prettenhofer <[email protected]>:
>> if somebody tries to use scikit-learn with the current dev version of
>> numpy he/she will experience strange behavior (even segfaults) when
>> dealing with sparse matrices. It seems that there's a bug in the
>> current numpy HEAD that causes `np.dot` to fail if one of the operands
>> is a sparse matrix. This used to work at least for numpy <= 1.6.x and
>> is used in the scikit all over the place. Now the question: is np.dot
>> supposed to work on sparse matrices at all? If not, we should try to
>> make the scikit future proof ASAP!
>
> What do you mean, all over the place? All sparse matrix handling code
> should have been using safe_sparse_dot in the first place, which uses
> the * operator when at least one of the arguments is sparse.
>
> --
> Lars Buitinck
> Scientific programmer, ILPS
> University of Amsterdam
>
> ------------------------------------------------------------------------------
> 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
>



-- 
Peter Prettenhofer

------------------------------------------------------------------------------
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

Reply via email to