diff --git a/doc/run_experiment.rst b/doc/run_experiment.rst index 16718de6..f1e299f2 100644 --- a/doc/run_experiment.rst +++ b/doc/run_experiment.rst @@ -530,19 +530,19 @@ Whether to scale features by their mean and/or their standard deviation. If you scale by mean, your data will automatically be converted to dense, so use caution when you have a very large dataset. Valid options are: -none +"none" or `None` Perform no feature scaling at all. -with_std +"with_std" Scale feature values by their standard deviation. -with_mean +"with_mean" Center features by subtracting their mean. -both +"both" Perform both centering and scaling. -Defaults to none. +The values are case insensitive. Defaults to "none". .. _featureset_names: diff --git a/skll/config/__init__.py b/skll/config/__init__.py index a3e3407c..f56dd347 100644 --- a/skll/config/__init__.py +++ b/skll/config/__init__.py @@ -720,9 +720,10 @@ def parse_config_file( # ensure that feature_scaling is specified only as one of the # four available choices - feature_scaling = config.get("Input", "feature_scaling") + feature_scaling = config.get("Input", "feature_scaling").lower() if feature_scaling not in VALID_FEATURE_SCALING_OPTIONS: - raise ValueError("Invalid value for feature_scaling parameter: " f"{feature_scaling}") + raise ValueError("Invalid value for feature_scaling parameter: " + f"{feature_scaling}") suffix = config.get("Input", "suffix") label_col = config.get("Input", "label_col") diff --git a/tests/configs/test_feature_scaling_none.template.cfg b/tests/configs/test_feature_scaling_none.template.cfg new file mode 100644 index 00000000..7ad23831 --- /dev/null +++ b/tests/configs/test_feature_scaling_none.template.cfg @@ -0,0 +1,19 @@ +[General] +experiment_name=test_class_map +task=evaluate + +[Input] +feature_hasher = true +hasher_features = 100 +featuresets=[["test_class_map"]] +learners=["LogisticRegression"] +suffix=.jsonlines +class_map={'dog': ['beagle', 'dachsund']} +feature_scaling=None + +[Tuning] +grid_search=False +objectives=['accuracy'] + +[Output] +probability=false diff --git a/tests/test_input.py b/tests/test_input.py index fb575e8e..3a66b3c5 100644 --- a/tests/test_input.py +++ b/tests/test_input.py @@ -1848,6 +1848,32 @@ def test_config_parsing_set_wandb_values(self): self.assertEqual(wandb_credentials["wandb_entity"], "wandb_entity") self.assertEqual(wandb_credentials["wandb_project"], "wandb_project") + def test_config_parsing_feature_scaling_none(self): + """Test that feature scaling value of None is converted to a string""" + values_to_fill_dict = { + "experiment_name": "config_parsing", + "task": "evaluate", + "train_directory": train_dir, + "test_directory": test_dir, + "featuresets": "[['f1', 'f2', 'f3']]", + "fixed_parameters": '[{"estimator_names": ' + '["SVC", "LogisticRegression", "MultinomialNB"]}]', + "learners": "['VotingClassifier']", + "objectives": "['accuracy']", + "logs": output_dir, + "results": output_dir, + } + + config_template_path = config_dir / "test_feature_scaling_none.template.cfg" + + config_path = fill_in_config_options( + config_template_path, values_to_fill_dict, "default_value_save_votes" + ) + + configuration = parse_config_file(config_path) + feature_scaling = configuration[20] + + self.assertEqual("none", feature_scaling) def test_config_parsing_set_wandb_missing_value(self): """Test that config parsing works as expected for when values are missing `wandb_credentials`.""" values_to_fill_dict = {