Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions doc/run_experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
5 changes: 3 additions & 2 deletions skll/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
19 changes: 19 additions & 0 deletions tests/configs/test_feature_scaling_none.template.cfg
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions tests/test_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down