Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable multicore processing with sklearn LogisticRegression?

Sklearn's LogisticRegression model refuses to run in parallel. I set n_jobs=-1, and also tried n_jobs=4. No luck -- only one core is engaged. I've run other sklearn models in parallel, e.g., RandomForestClassifier and XGBoostClassifier.

I'm running Python 2.7.12 with sklearn 0.18 on Ubuntu 14.04.

Other people have asked the same question (e.g., here), thus far without receiving any promising replies. I'm hoping my luck will be better.

like image 950
Jim Olness Avatar asked Oct 29 '25 05:10

Jim Olness


1 Answers

From the doco for LogisticRegresssion it looks like the n_jobs parameter is only used for separate cross-validation folds (unlike the case for RandomForestClassifier where the individual trees are computed in parallel).

n_jobs : int, default: 1

Number of CPU cores used during the cross-validation loop. If given a value of -1, all cores are used.

like image 72
maxymoo Avatar answered Nov 01 '25 14:11

maxymoo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!