Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
24faeb7
bump to 0.11.1dev to continue developing (#971)
mfeurer Oct 25, 2020
e84cdf9
update home page example to numerical dataset (pendigits) (#976)
a-moadel Oct 26, 2020
07e87ad
Speed up tests (#977)
PGijsbers Oct 29, 2020
4923e5b
Additional fixes to PR 777 (#967)
Neeratyoy Oct 29, 2020
f2af798
Improving the performance of check_datasets_active (#980)
ArlindKadra Oct 29, 2020
756e747
Add CI through Github Actions (#975)
PGijsbers Oct 29, 2020
3132dac
add validation for ignore_attributes and default_target_attribute at …
a-moadel Oct 29, 2020
6afc880
Updated the way 'image features' are stored, updated old unit tests, …
ArlindKadra Oct 29, 2020
5b6de8a
Retry on database error to reduce number of test failures (#984)
mfeurer Oct 30, 2020
63ec0ae
Transition other Travis jobs to Github Actions (#988)
PGijsbers Nov 2, 2020
9a3a6dd
update progress file (#991)
a-moadel Nov 2, 2020
81cc423
docs: add a-moadel as a contributor (#992)
allcontributors[bot] Nov 2, 2020
51eaff6
docs: add Neeratyoy as a contributor (#998)
allcontributors[bot] Nov 2, 2020
a629562
Improve unit tests (#985)
mfeurer Nov 3, 2020
accde88
Warning if fitted sklearn model being used (#989)
Neeratyoy Nov 3, 2020
560e952
Cache dataset features and qualities as pickle (#979)
mfeurer Nov 3, 2020
5d5a48e
Update string formatting (#1001)
PGijsbers Nov 17, 2020
16799ad
Specify encoding for README file (#1004)
PGijsbers Nov 18, 2020
fba6aab
Making some unit tests work (#1000)
Neeratyoy Dec 24, 2020
e074c14
Refactor data loading/storing (#1018)
PGijsbers Jan 19, 2021
ab793a6
Adding helper functions to support ColumnTransformer (#982)
Neeratyoy Jan 28, 2021
47cda65
Rework local openml directory (#987)
mfeurer Feb 10, 2021
80ae046
Feature/give possibility to not download the dataset qualities (#1017)
a-moadel Feb 11, 2021
d2945ba
Adding sklearn 0.24 support (#1016)
Neeratyoy Feb 11, 2021
3c680c1
improve path detection (#1021)
mfeurer Feb 12, 2021
7553281
Removing flaky decorator for study unit test (#1024)
Neeratyoy Feb 16, 2021
ff7a251
Adding sklearn min. dependencies for all versions (#1022)
Neeratyoy Feb 18, 2021
4ff66ed
Parallel evaluation of tasks (#1020)
Neeratyoy Feb 18, 2021
38f9bf0
Parquet Support (#1029)
PGijsbers Mar 4, 2021
6c609b8
API for topics (#1023)
sahithyaravi Mar 9, 2021
4aec00a
Remove nan-likes from category header (#1037)
PGijsbers Mar 12, 2021
f94672e
Measuring runtimes (#1031)
Neeratyoy Mar 12, 2021
bd8ae14
Fix 1013: Store run `setup_string` (#1015)
PGijsbers Mar 25, 2021
11e6235
Fix #1033: skip two unit tests on Windows (#1040)
mfeurer Mar 26, 2021
d9037e7
bump version for new release (#1041)
mfeurer Mar 29, 2021
5511fa0
fix loky/concurrency issue (#1042)
mfeurer Mar 30, 2021
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
Prev Previous commit
Next Next commit
Remove nan-likes from category header (#1037)
* Remove nan-likes from category header

Pandas does not accept None/nan as a category (note: of course
it does allow nan-values in the data itself). However outside source
(i.e. ARFF files) do allow nan as a category, so we must filter these.

* Test output of _unpack_categories
  • Loading branch information
PGijsbers authored Mar 12, 2021
commit 4aec00a6c92053d0f24c0cb80eae2818ed60c814
7 changes: 6 additions & 1 deletion openml/datasets/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,11 @@ def _encode_if_category(column):

@staticmethod
def _unpack_categories(series, categories):
# nan-likes can not be explicitly specified as a category
def valid_category(cat):
return isinstance(cat, str) or (cat is not None and not np.isnan(cat))

filtered_categories = [c for c in categories if valid_category(c)]
col = []
for x in series:
try:
Expand All @@ -647,7 +652,7 @@ def _unpack_categories(series, categories):
col.append(np.nan)
# We require two lines to create a series of categories as detailed here:
# https://pandas.pydata.org/pandas-docs/version/0.24/user_guide/categorical.html#series-creation # noqa E501
raw_cat = pd.Categorical(col, ordered=True, categories=categories)
raw_cat = pd.Categorical(col, ordered=True, categories=filtered_categories)
return pd.Series(raw_cat, index=series.index, name=series.name)

def get_data(
Expand Down
11 changes: 11 additions & 0 deletions tests/test_datasets/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ def test_init_string_validation(self):
name="somename", description="a description", citation="Something by Müller"
)

def test__unpack_categories_with_nan_likes(self):
# unpack_categories decodes numeric categorical values according to the header
# Containing a 'non' category in the header shouldn't lead to failure.
categories = ["a", "b", None, float("nan"), np.nan]
series = pd.Series([0, 1, None, float("nan"), np.nan, 1, 0])
clean_series = OpenMLDataset._unpack_categories(series, categories)

expected_values = ["a", "b", np.nan, np.nan, np.nan, "b", "a"]
self.assertListEqual(list(clean_series.values), expected_values)
self.assertListEqual(list(clean_series.cat.categories.values), list("ab"))

def test_get_data_array(self):
# Basic usage
rval, _, categorical, attribute_names = self.dataset.get_data(dataset_format="array")
Expand Down