Skip to content

Commit 9de474c

Browse files
authored
Expose keep_selected_variables_only for sklearn predictors (KhiopsClassifier and KhiopsRegressor) (#567)
1 parent 0129d20 commit 9de474c

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
## Unreleased
1010

11+
### Added
12+
- (`sklearn`) `keep_selected_variables_only` parameter to the predictors (`KhiopsClassifier` and `KhiopsRegressor`)
13+
1114
### Changed
1215
- (`core`) Rename `variable_part_dimensions` to `inner_variable_dimensions` in Coclustering results.
1316

khiops/sklearn/estimators.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,7 @@ def __init__(
11961196
all_possible_pairs=True,
11971197
construction_rules=None,
11981198
n_feature_parts=0,
1199+
keep_selected_variables_only=True,
11991200
verbose=False,
12001201
output_dir=None,
12011202
auto_sort=True,
@@ -1213,6 +1214,7 @@ def __init__(
12131214
self.all_possible_pairs = all_possible_pairs
12141215
self.construction_rules = construction_rules
12151216
self.n_feature_parts = n_feature_parts
1217+
self.keep_selected_variables_only = keep_selected_variables_only
12161218
self._original_target_dtype = None
12171219
self._predicted_target_meta_data_tag = None
12181220
self._khiops_baseline_model_prefix = None
@@ -1523,6 +1525,7 @@ def __init__(
15231525
all_possible_pairs=True,
15241526
construction_rules=None,
15251527
n_feature_parts=0,
1528+
keep_selected_variables_only=True,
15261529
verbose=False,
15271530
output_dir=None,
15281531
auto_sort=True,
@@ -1536,6 +1539,7 @@ def __init__(
15361539
all_possible_pairs=all_possible_pairs,
15371540
construction_rules=construction_rules,
15381541
n_feature_parts=n_feature_parts,
1542+
keep_selected_variables_only=keep_selected_variables_only,
15391543
verbose=verbose,
15401544
output_dir=output_dir,
15411545
auto_sort=auto_sort,
@@ -1703,6 +1707,8 @@ class KhiopsClassifier(ClassifierMixin, KhiopsPredictor):
17031707
group_target_value : bool, default ``False``
17041708
Allows grouping of the target values in classification. It can substantially
17051709
increase the training time.
1710+
keep_selected_variables_only : bool, default ``True``
1711+
Keeps only predictor-selected variables in the supervised analysis report.
17061712
verbose : bool, default ``False``
17071713
If ``True`` it prints debug information and it does not erase temporary files
17081714
when fitting, predicting or transforming.
@@ -1760,6 +1766,7 @@ def __init__(
17601766
construction_rules=None,
17611767
n_feature_parts=0,
17621768
group_target_value=False,
1769+
keep_selected_variables_only=True,
17631770
verbose=False,
17641771
output_dir=None,
17651772
auto_sort=True,
@@ -1773,6 +1780,7 @@ def __init__(
17731780
n_evaluated_features=n_evaluated_features,
17741781
construction_rules=construction_rules,
17751782
n_feature_parts=n_feature_parts,
1783+
keep_selected_variables_only=keep_selected_variables_only,
17761784
verbose=verbose,
17771785
output_dir=output_dir,
17781786
auto_sort=auto_sort,
@@ -2105,6 +2113,8 @@ class KhiopsRegressor(RegressorMixin, KhiopsPredictor):
21052113
n_feature_parts : int, default 0
21062114
Maximum number of variable parts produced by preprocessing methods. If equal
21072115
to 0 it is automatically calculated.
2116+
keep_selected_variables_only : bool, default ``True``
2117+
Keeps only predictor-selected variables in the supervised analysis report.
21082118
verbose : bool, default ``False``
21092119
If ``True`` it prints debug information and it does not erase temporary files
21102120
when fitting, predicting or transforming.
@@ -2149,6 +2159,7 @@ def __init__(
21492159
n_evaluated_features=0,
21502160
construction_rules=None,
21512161
n_feature_parts=0,
2162+
keep_selected_variables_only=True,
21522163
verbose=False,
21532164
output_dir=None,
21542165
auto_sort=True,
@@ -2162,6 +2173,7 @@ def __init__(
21622173
n_evaluated_features=n_evaluated_features,
21632174
construction_rules=construction_rules,
21642175
n_feature_parts=n_feature_parts,
2176+
keep_selected_variables_only=keep_selected_variables_only,
21652177
verbose=verbose,
21662178
output_dir=output_dir,
21672179
auto_sort=auto_sort,

tests/test_sklearn.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ def setUpClass(cls):
766766
"max_parts": 3,
767767
"group_target_value": False,
768768
"additional_data_tables": {},
769+
"keep_selected_variables_only": False,
769770
}
770771
},
771772
"predict": {
@@ -794,6 +795,7 @@ def setUpClass(cls):
794795
"max_evaluated_variables": 3,
795796
"construction_rules": ["TableMode", "TableSelection"],
796797
"max_parts": 5,
798+
"keep_selected_variables_only": False,
797799
"additional_data_tables": {},
798800
}
799801
},
@@ -1449,6 +1451,7 @@ def test_parameter_transfer_classifier_fit_from_monotable_dataframe(self):
14491451
"construction_rules": ["TableMode", "TableSelection"],
14501452
"n_feature_parts": 3,
14511453
"group_target_value": False,
1454+
"keep_selected_variables_only": False,
14521455
},
14531456
)
14541457

@@ -1474,6 +1477,7 @@ def test_parameter_transfer_classifier_fit_from_monotable_dataframe_with_df_y(
14741477
"construction_rules": ["TableMode", "TableSelection"],
14751478
"n_feature_parts": 3,
14761479
"group_target_value": False,
1480+
"keep_selected_variables_only": False,
14771481
},
14781482
)
14791483

@@ -1631,6 +1635,7 @@ def test_parameter_transfer_regressor_fit_from_monotable_dataframe(self):
16311635
"type_text_features": "ngrams",
16321636
"construction_rules": ["TableMode", "TableSelection"],
16331637
"n_feature_parts": 5,
1638+
"keep_selected_variables_only": False,
16341639
},
16351640
)
16361641

@@ -1651,6 +1656,7 @@ def test_parameter_transfer_regressor_fit_from_monotable_dataframe_with_df_y(
16511656
"type_text_features": "ngrams",
16521657
"construction_rules": ["TableMode", "TableSelection"],
16531658
"n_feature_parts": 5,
1659+
"keep_selected_variables_only": False,
16541660
},
16551661
)
16561662

0 commit comments

Comments
 (0)