Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion sklearn/ensemble/_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,16 @@ def _parallel_build_trees(
verbose=0,
class_weight=None,
n_samples_bootstrap=None,
feature_names_in_=None,
):
"""
Private function used to fit a single tree in parallel."""
if verbose > 1:
print("building tree %d of %d" % (tree_idx + 1, n_trees))

if feature_names_in_ is not None:
tree.feature_names_in_ = feature_names_in_

if bootstrap:
n_samples = X.shape[0]
if sample_weight is None:
Expand Down Expand Up @@ -343,9 +347,15 @@ def fit(self, X, y, sample_weight=None):
# Validate or convert input data
if issparse(y):
raise ValueError("sparse multilabel-indicator for y is not supported.")

X, y = self._validate_data(
X, y, multi_output=True, accept_sparse="csc", dtype=DTYPE
X,
y,
multi_output=True,
accept_sparse="csc",
dtype=DTYPE,
)

if sample_weight is not None:
sample_weight = _check_sample_weight(sample_weight, X)

Expand Down Expand Up @@ -467,6 +477,7 @@ def fit(self, X, y, sample_weight=None):
verbose=self.verbose,
class_weight=self.class_weight,
n_samples_bootstrap=n_samples_bootstrap,
feature_names_in_=getattr(self, "feature_names_in_", None),
)
for i, t in enumerate(trees)
)
Expand Down
1 change: 0 additions & 1 deletion sklearn/tree/_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,6 @@ def fit(self, X, y, sample_weight=None, check_input=True):
self : DecisionTreeClassifier
Fitted estimator.
"""

super().fit(
X,
y,
Expand Down