@@ -74,12 +74,9 @@ def _local_parallel_build_trees(
74
74
"bootstrap" : bootstrap ,
75
75
}
76
76
77
- if sklearn_version >= parse_version ("1.4" ):
78
- # TODO: remove when the minimum supported version of scikit-learn will be 1.4
79
- # support for missing values
80
- params_parallel_build_trees ["missing_values_in_feature_mask" ] = (
81
- missing_values_in_feature_mask
82
- )
77
+ params_parallel_build_trees ["missing_values_in_feature_mask" ] = (
78
+ missing_values_in_feature_mask
79
+ )
83
80
84
81
tree = _parallel_build_trees (** params_parallel_build_trees )
85
82
@@ -469,20 +466,9 @@ def __init__(
469
466
"min_impurity_decrease" : min_impurity_decrease ,
470
467
"ccp_alpha" : ccp_alpha ,
471
468
"max_samples" : max_samples ,
469
+ "monotonic_cst" : monotonic_cst ,
472
470
}
473
- # TODO: remove when the minimum supported version of scikit-learn will be 1.4
474
- if sklearn_version >= parse_version ("1.4" ):
475
- # use scikit-learn support for monotonic constraints
476
- params_random_forest ["monotonic_cst" ] = monotonic_cst
477
- else :
478
- if monotonic_cst is not None :
479
- raise ValueError (
480
- "Monotonic constraints are not supported for scikit-learn "
481
- "version < 1.4."
482
- )
483
- # create an attribute for compatibility with other scikit-learn tools such
484
- # as HTML representation.
485
- self .monotonic_cst = monotonic_cst
471
+
486
472
super ().__init__ (** params_random_forest )
487
473
488
474
self .sampling_strategy = sampling_strategy
@@ -548,37 +534,26 @@ def fit(self, X, y, sample_weight=None):
548
534
if issparse (y ):
549
535
raise ValueError ("sparse multilabel-indicator for y is not supported." )
550
536
551
- # TODO: remove when the minimum supported version of scipy will be 1.4
552
- # Support for missing values
553
- if sklearn_version >= parse_version ("1.4" ):
554
- ensure_all_finite = False
555
- else :
556
- ensure_all_finite = True
557
-
558
537
X , y = validate_data (
559
538
self ,
560
539
X = X ,
561
540
y = y ,
562
541
multi_output = True ,
563
542
accept_sparse = "csc" ,
564
543
dtype = DTYPE ,
565
- ensure_all_finite = ensure_all_finite ,
544
+ ensure_all_finite = False ,
566
545
)
567
546
568
- # TODO: remove when the minimum supported version of scikit-learn will be 1.4
569
- if sklearn_version >= parse_version ("1.4" ):
570
- # _compute_missing_values_in_feature_mask checks if X has missing values and
571
- # will raise an error if the underlying tree base estimator can't handle
572
- # missing values. Only the criterion is required to determine if the tree
573
- # supports missing values.
574
- estimator = type (self .estimator )(criterion = self .criterion )
575
- missing_values_in_feature_mask = (
576
- estimator ._compute_missing_values_in_feature_mask (
577
- X , estimator_name = self .__class__ .__name__
578
- )
547
+ # _compute_missing_values_in_feature_mask checks if X has missing values and
548
+ # will raise an error if the underlying tree base estimator can't handle
549
+ # missing values. Only the criterion is required to determine if the tree
550
+ # supports missing values.
551
+ estimator = type (self .estimator )(criterion = self .criterion )
552
+ missing_values_in_feature_mask = (
553
+ estimator ._compute_missing_values_in_feature_mask (
554
+ X , estimator_name = self .__class__ .__name__
579
555
)
580
- else :
581
- missing_values_in_feature_mask = None
556
+ )
582
557
583
558
if sample_weight is not None :
584
559
sample_weight = _check_sample_weight (sample_weight , X )
0 commit comments