Search code examples
numpyparallel-processingscipymathematical-optimizationcurve-fitting

How can I parallelize functions "leastsq" or/and "curve_fit"


What is the best way to parallelize the fitting procedure for multicore computers using scipy functions? As far as I see from manual, these functions do not have parameters like npocs. Does it mean they are not supposed to be parallelized?


Solution

  • Short answer: there is no built-in parallelization at the moment. There is a proposal to use multiprocessing in leastsq, but it's not clear whether this is worth it. (if you feel like giving that code a drive and report the results, that'll be appreciated).

    That being said, you can parallelize the evaluation of your objective function as you wish. Eg push it to a compiled extension (Cython, C, Fortran), release the GIL and use OpenMP or even explicit threads. Your mileage may vary a lot depending on details of your particular problem.