-
-
Notifications
You must be signed in to change notification settings - Fork 270
add validation for ignore_attributes and default_target_attribute at … #978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
1c6c5de
07c85cc
ff3d27a
ace60aa
afdd949
4cf640f
89c2ada
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -875,6 +875,51 @@ def test_get_online_dataset_format(self): | |
| _get_online_dataset_format(dataset_id), | ||
| "The format of the ARFF files is different", | ||
| ) | ||
| @pytest.mark.parametrize("default_target_attribute,row_id_attribute,ignore_attribute", | ||
| [("wrong", None,None), (None,"wrong",None), (None,None,"wrong")]) | ||
| def test_attribute_validations(self): | ||
| data = [ | ||
| ["a", "sunny", 85.0, 85.0, "FALSE", "no"], | ||
| ["b", "sunny", 80.0, 90.0, "TRUE", "no"], | ||
| ["c", "overcast", 83.0, 86.0, "FALSE", "yes"], | ||
| ["d", "rainy", 70.0, 96.0, "FALSE", "yes"], | ||
| ["e", "rainy", 68.0, 80.0, "FALSE", "yes"], | ||
| ] | ||
| column_names = ["rnd_str", "outlook", "temperature", "humidity", "windy", "play"] | ||
| df = pd.DataFrame(data, columns=column_names) | ||
| # enforce the type of each column | ||
| df["outlook"] = df["outlook"].astype("category") | ||
| df["windy"] = df["windy"].astype("bool") | ||
| df["play"] = df["play"].astype("category") | ||
| # meta-information | ||
| name = "%s-pandas_testing_dataset" % self._get_sentinel() | ||
| description = "Synthetic dataset created from a Pandas DataFrame" | ||
| creator = "OpenML tester" | ||
| collection_date = "01-01-2018" | ||
| language = "English" | ||
| licence = "MIT" | ||
| citation = "None" | ||
| original_data_url = "http://openml.github.io/openml-python" | ||
| paper_url = "http://openml.github.io/openml-python" | ||
| with self.assertRaises(ValueError): | ||
| _ = openml.datasets.functions.create_dataset( | ||
| name=name, | ||
| description=description, | ||
| creator=creator, | ||
| contributor=None, | ||
| collection_date=collection_date, | ||
| language=language, | ||
| licence=licence, | ||
| default_target_attribute="wrong", | ||
| row_id_attribute=None, | ||
| ignore_attribute=None, | ||
| citation=citation, | ||
| attributes="auto", | ||
| data=df, | ||
| version_label="test", | ||
| original_data_url=original_data_url, | ||
| paper_url=paper_url, | ||
| ) | ||
|
|
||
| def test_create_dataset_pandas(self): | ||
| data = [ | ||
|
|
@@ -897,7 +942,6 @@ def test_create_dataset_pandas(self): | |
| collection_date = "01-01-2018" | ||
| language = "English" | ||
| licence = "MIT" | ||
| default_target_attribute = "play" | ||
| citation = "None" | ||
| original_data_url = "http://openml.github.io/openml-python" | ||
| paper_url = "http://openml.github.io/openml-python" | ||
|
|
@@ -909,7 +953,7 @@ def test_create_dataset_pandas(self): | |
| collection_date=collection_date, | ||
| language=language, | ||
| licence=licence, | ||
| default_target_attribute=default_target_attribute, | ||
| default_target_attribute="play", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you change these tests?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one will fail because of the new logic , as "play" is not in the dataset columns.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But previously it was also set to |
||
| row_id_attribute=None, | ||
| ignore_attribute=None, | ||
| citation=citation, | ||
|
|
@@ -944,7 +988,7 @@ def test_create_dataset_pandas(self): | |
| collection_date=collection_date, | ||
| language=language, | ||
| licence=licence, | ||
| default_target_attribute=default_target_attribute, | ||
| default_target_attribute="y", | ||
| row_id_attribute=None, | ||
| ignore_attribute=None, | ||
| citation=citation, | ||
|
|
@@ -980,7 +1024,7 @@ def test_create_dataset_pandas(self): | |
| collection_date=collection_date, | ||
| language=language, | ||
| licence=licence, | ||
| default_target_attribute=default_target_attribute, | ||
| default_target_attribute="rnd_str", | ||
| row_id_attribute=None, | ||
| ignore_attribute=None, | ||
| citation=citation, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.