[SciPy-User] lstsq/Scipy and python multiprocessing

Charles Pierre af.charles.pierre at gmail.com
Thu Dec 5 08:47:47 EST 2013


I was trying to do some simple multivariate regression using
sklearn.linear_model and mutliprocessing module when i found this really
confusing behavior.

For some reason, the linear regression seems to be broken for particular
input vectors when using multiprocessing. Using the same training set
without multiprocessing yields correct values ...

Here a piece of code that demonstrates this weird behavior:

import multiprocessingfrom sklearn import linear_model
def test_without_multi(input_x,input_y):
    clf = linear_model.LinearRegression(normalize=True)
    clf.fit(input_x,
            input_y,
            n_jobs=1)
    print clf.coef_
def test_with_multi(input_x,input_y):
    process = multiprocessing.Process(target=test_without_multi,args=(input_x,input_y))
    process.start()
    process.join()
if __name__ == '__main__':
    input_x = [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[1,1350]]
    input_y = [2,1,1,2,3,1,3,2,1]
    test_without_multi(input_x,input_y)
    test_with_multi(input_x,input_y)

Does anyone know what is happening ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20131205/16cd7ed0/attachment.html>


More information about the SciPy-User mailing list