Skip to content

Commit affe078

Browse files
committed
fix bug in tests
1 parent 12b982e commit affe078

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

autoPyTorch/pipeline/components/preprocessing/tabular_preprocessing/feature_preprocessing/SelectPercentileClassification.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ def get_hyperparameter_search_space(
6666
default_value="chi2",
6767
),
6868
) -> ConfigurationSpace:
69-
value_range = ["mutual_info_classif"]
69+
value_range = []
7070
if dataset_properties is not None:
7171
if (
7272
dataset_properties.get("issigned") is False
7373
):
74-
value_range.append("chi2")
74+
value_range.extend(["mutual_info_classif", "chi2"])
7575
if dataset_properties.get("issparse") is False:
7676
value_range.append("f_classif")
7777
else:
@@ -81,6 +81,9 @@ def get_hyperparameter_search_space(
8181
warnings.warn(f"Given choices for `score_func` are not compatible with the dataset. "
8282
f"Updating choices to {value_range}")
8383

84+
if len(value_range) == 0:
85+
raise TypeError("`SelectPercentileClassification` is not compatible with the"
86+
" current dataset as it is both `signed` and `sparse`")
8487
score_func = HyperparameterSearchSpace(hyperparameter="score_func",
8588
value_range=value_range,
8689
default_value=value_range[-1],

autoPyTorch/pipeline/components/preprocessing/tabular_preprocessing/feature_preprocessing/SelectRatesRegression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from autoPyTorch.utils.common import HyperparameterSearchSpace, add_hyperparameter
1818

1919

20-
class SelectPercentileRegression(autoPyTorchFeaturePreprocessingComponent):
20+
class SelectRatesRegression(autoPyTorchFeaturePreprocessingComponent):
2121
"""
2222
Univariate feature selector by selecting the best features based on
2323
univariate statistical tests. Tests can be one of 'f_regression'

test/test_pipeline/components/preprocessing/test_feature_preprocessor.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ def test_pipeline_fit_include(self, fit_dictionary_tabular, preprocessor):
9393
in the include
9494
"""
9595

96+
task_type = str(fit_dictionary_tabular['dataset_properties']['task_type'])
97+
if (
98+
("Classification" in preprocessor or preprocessor == "LibLinearSVCPreprocessor")
99+
and STRING_TO_TASK_TYPES[task_type] not in CLASSIFICATION_TASKS
100+
):
101+
pytest.skip("Tests not relevant for {}".format(preprocessor.__class__.__name__))
102+
elif "Regression" in preprocessor and STRING_TO_TASK_TYPES[task_type] not in REGRESSION_TASKS:
103+
pytest.skip("Tests not relevant for {}".format(preprocessor.__class__.__name__))
96104
fit_dictionary_tabular['epochs'] = 1
97105

98106
pipeline = TabularClassificationPipeline(

0 commit comments

Comments
 (0)