Hi there!

I've noticed that sklearn uses numpy.linalg instead of scipy.linalg for its linear algebra implementations (e.g. dot or svd). However I found that scipy.linalg consistently performs better on my machines. Since sklearn requires scipy anyways, I was wondering what the reason is for sticking with the numpy.linalg versions in sklearn?

Details:
----------
It seems to be that the scipy.linalg variants are consistently faster than the numpy.linalg variants (~5 - 10% difference). This is across 3 different BLAS libraries (MKL, ACML and OpenBLAS) and two different machines (AMD FX-8150 and mobile Intel i5), using both the numpy/scipy versions from the ubuntu repository as well as binaries I compiled on my own.

It's also relevant that this behavior is observable both with numpy 1.7.1 as well as numpy 1.8.0rc2 (as far as I understand np1.8 should have some improved routines for C-contiguous arrays, which is what I used in my tests).

for example, running various matrix-routines with inputs of size 1000x1000 using OpenBLAS on my laptop (reported times are the mean of 5 runs):
scipy.linalg:
            test_dot :   250.2ms (sd: 4.9ms)
            test_det :    65.4ms (sd: 1.8ms)
            test_inv :   147.2ms (sd: 0.8ms)
            test_svd :  1838.4ms (sd: 6.9ms)
          test_eigen :  1864.9ms (sd: 12.6ms)

numpy.linalg:
            test_dot :   278.4ms (sd: 4.0ms)
            test_det :    72.3ms (sd: 5.6ms)
            test_inv :   182.4ms (sd: 0.7ms)
            test_svd :  1866.4ms (sd: 16.0ms)
          test_eigen :  1886.6ms (sd: 9.7ms)


(The benchmark is a slightly modified version of http://software.intel.com/sites/default/files/m/d/4/1/d/8/mkl_benchmark.py , where I switch the import from numpy.linalg to scipy.linalg when needed)


Cheers

Thomas
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to