|
20 | 20 | from ..utils import check_random_state, check_X_y, check_array, column_or_1d |
21 | 21 | from ..utils.random import sample_without_replacement |
22 | 22 | from ..utils.validation import has_fit_parameter, check_is_fitted |
23 | | -from ..utils import indices_to_mask |
| 23 | +from ..utils import indices_to_mask, check_consistent_length |
24 | 24 | from ..utils.fixes import bincount |
25 | 25 | from ..utils.metaestimators import if_delegate_has_method |
26 | 26 | from ..utils.multiclass import check_classification_targets |
@@ -82,8 +82,8 @@ def _parallel_build_estimators(n_estimators, ensemble, X, y, sample_weight, |
82 | 82 |
|
83 | 83 | for i in range(n_estimators): |
84 | 84 | if verbose > 1: |
85 | | - print("Building estimator %d of %d for this parallel run (total %d)..." % |
86 | | - (i + 1, n_estimators, total_n_estimators)) |
| 85 | + print("Building estimator %d of %d for this parallel run " |
| 86 | + "(total %d)..." % (i + 1, n_estimators, total_n_estimators)) |
87 | 87 |
|
88 | 88 | random_state = np.random.RandomState(seeds[i]) |
89 | 89 | estimator = ensemble._make_estimator(append=False, |
@@ -282,6 +282,9 @@ def _fit(self, X, y, max_samples=None, max_depth=None, sample_weight=None): |
282 | 282 |
|
283 | 283 | # Convert data |
284 | 284 | X, y = check_X_y(X, y, ['csr', 'csc']) |
| 285 | + if sample_weight is not None: |
| 286 | + sample_weight = check_array(sample_weight, ensure_2d=False) |
| 287 | + check_consistent_length(y, sample_weight) |
285 | 288 |
|
286 | 289 | # Remap output |
287 | 290 | n_samples, self.n_features_ = X.shape |
|
0 commit comments