Skip to content

Commit cf02221

Browse files
committed
FIX attempt to fix parallelization
1 parent 6801508 commit cf02221

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

sklearn/ensemble/_forest.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,13 +1323,10 @@ def partial_fit(self, X, y, sample_weight=None, classes=None):
13231323
# would have got if we hadn't used a warm_start.
13241324
random_state.randint(MAX_INT, size=len(self.estimators_))
13251325

1326-
# Parallel loop: we prefer the threading backend as the Cython code
1327-
# for fitting the trees is internally releasing the Python GIL
1328-
# making threading more efficient than multiprocessing in
1329-
# that case. However, for joblib 0.12+ we respect any
1330-
# parallel_backend contexts set at a higher level,
1331-
# since correctness does not rely on using threads.
1332-
Parallel(
1326+
# Copy estimator list
1327+
trees = self.estimators_
1328+
1329+
trees = Parallel(
13331330
n_jobs=self.n_jobs,
13341331
verbose=self.verbose,
13351332
prefer="threads",
@@ -1341,15 +1338,18 @@ def partial_fit(self, X, y, sample_weight=None, classes=None):
13411338
y,
13421339
sample_weight,
13431340
i,
1344-
len(self.estimators_),
1341+
len(trees),
13451342
verbose=self.verbose,
13461343
class_weight=self.class_weight,
13471344
n_samples_bootstrap=n_samples_bootstrap,
13481345
classes=classes[0],
13491346
)
1350-
for i, t in enumerate(self.estimators_)
1347+
for i, t in enumerate(trees)
13511348
)
13521349

1350+
# Update estimator references
1351+
self.estimators_ = trees
1352+
13531353
if self.oob_score:
13541354
y_type = type_of_target(y)
13551355
if y_type in ("multiclass-multioutput", "unknown"):

0 commit comments

Comments
 (0)