8000 DOC on parallelisation of custom scorer (#12813) · scikit-learn/scikit-learn@9928713 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9928713

Browse files
fx86jnothman
authored andcommitted
DOC on parallelisation of custom scorer (#12813)
1 parent fce73db commit 9928713

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

doc/modules/model_evaluation.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,25 @@ the following two rules:
215215
Again, by convention higher numbers are better, so if your scorer
216216
returns loss, that value should be negated.
217217

218+
.. note:: **Using custom scorers in functions where n_jobs > 1**
219+
220+
While defining the custom scoring function alongside the calling function
221+
should work out of the box with the default joblib backend (loky),
222+
importing it from another module will be a more robust approach and work
223+
independently of the joblib backend.
224+
225+
For example, to use, ``n_jobs`` greater than 1 in the example below,
226+
``custom_scoring_function`` function is saved in a user-created module
227+
(``custom_scorer_module.py``) and imported::
228+
229+
>>> from custom_scorer_module import custom_scoring_function # doctest: +SKIP
230+
>>> cross_val_score(model,
231+
... X_train,
232+
... y_train,
233+
... scoring=make_scorer(custom_scoring_function, greater_is_better=False),
234+
... cv=5,
235+
... n_jobs=-1) # doctest: +SKIP
236+
218237
.. _multimetric_scoring:
219238

220239
Using multiple metric evaluation

0 commit comments

Comments
 (0)
0