Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
53e7fa6
mark production tests
LennartPurucker Jan 9, 2024
5cf9f0f
make production test run
LennartPurucker Jan 9, 2024
b84dc2e
fix test bug -1/N
LennartPurucker Jan 9, 2024
9bab91c
add retry raise again after refactor
LennartPurucker Jan 10, 2024
83ba06f
fix str dict representation
LennartPurucker Jan 10, 2024
8174ea1
test: Fix non-writable home mocks
eddiebergman Jan 10, 2024
a1839ee
Merge branch 'develop' of https://github.com/openml/openml-python int…
LennartPurucker Jan 10, 2024
d09f4f8
testing: not not a change
eddiebergman Jan 10, 2024
bba35a6
Merge branch 'make_tests_great_again' of https://github.com/openml/op…
LennartPurucker Jan 10, 2024
cbd2339
testing: trigger CI
eddiebergman Jan 11, 2024
8d769e7
typing: Update typing
eddiebergman Jan 11, 2024
52ad974
ci: Update testing matrix
eddiebergman Jan 11, 2024
10eb967
testing: Fixup run flow error check
eddiebergman Jan 11, 2024
648b557
ci: Manual dispatch, disable double testing
eddiebergman Jan 11, 2024
5fc565b
ci: Prevent further ci duplication
eddiebergman Jan 11, 2024
00a5280
ci: Add concurrency checks to all
eddiebergman Jan 11, 2024
6cb175d
ci: Remove the max-parallel on test ci
eddiebergman Jan 11, 2024
1fc7819
testing: Fix windows path generation
eddiebergman Jan 11, 2024
1624375
add pytest for server state
LennartPurucker Jan 11, 2024
9ca10b6
add assert cache state
LennartPurucker Jan 12, 2024
7c5106d
some formatting
LennartPurucker Jan 12, 2024
1ae6573
fix with cache fixture
LennartPurucker Jan 12, 2024
b22fd4d
finally remove th finally
LennartPurucker Jan 12, 2024
43744be
doc: Fix link
eddiebergman Jan 12, 2024
4a07696
update test matrix
LennartPurucker Jan 12, 2024
4b74022
Merge branch 'make_tests_great_again' of https://github.com/openml/op…
LennartPurucker Jan 12, 2024
305dee0
doc: Update to just point to contributing
eddiebergman Jan 12, 2024
a66d1be
Merge branch 'make_tests_great_again' of github.com:openml/openml-pyt…
eddiebergman Jan 12, 2024
1b70078
add linkcheck ignore for test server
LennartPurucker Jan 12, 2024
9671c39
add special case for class labels that are dtype string
LennartPurucker Jan 12, 2024
c048f7f
Merge branch 'develop' of https://github.com/openml/openml-python int…
LennartPurucker Jan 12, 2024
1097b7b
fix bug and add test
LennartPurucker Jan 12, 2024
f3c520d
formatting
LennartPurucker Jan 12, 2024
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
14 changes: 12 additions & 2 deletions openml/datasets/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,18 @@ def retrieve_class_labels(self, target_name: str = "class") -> None | list[str]:
list
"""
for feature in self.features.values():
if (feature.name == target_name) and (feature.data_type == "nominal"):
return feature.nominal_values
if feature.name == target_name:
if feature.data_type == "nominal":
return feature.nominal_values

if feature.data_type == "string":
# Rel.: #1311
# The target is invalid for a classification task if the feature type is string
# and not nominal. For such miss-configured tasks, we silently fix it here as
# we can safely interpreter string as nominal.
df, *_ = self.get_data()
return list(df[feature.name].unique())

return None

def get_features_by_type( # noqa: C901
Expand Down
7 changes: 7 additions & 0 deletions tests/test_datasets/test_dataset_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,18 @@ def test__retrieve_class_labels(self):
openml.config.set_root_cache_directory(self.static_cache_dir)
labels = openml.datasets.get_dataset(2, download_data=False).retrieve_class_labels()
assert labels == ["1", "2", "3", "4", "5", "U"]

labels = openml.datasets.get_dataset(2, download_data=False).retrieve_class_labels(
target_name="product-type",
)
assert labels == ["C", "H", "G"]

# Test workaround for string-typed class labels
custom_ds = openml.datasets.get_dataset(2, download_data=False)
custom_ds.features[31].data_type = "string"
labels = custom_ds.retrieve_class_labels(target_name=custom_ds.features[31].name)
assert labels == ["COIL", "SHEET"]

def test_upload_dataset_with_url(self):
dataset = OpenMLDataset(
"%s-UploadTestWithURL" % self._get_sentinel(),
Expand Down