-
-
Notifications
You must be signed in to change notification settings - Fork 270
Expand file tree
/
Copy pathsimple_tasks_tutorial.py
More file actions
30 lines (22 loc) · 832 Bytes
/
simple_tasks_tutorial.py
File metadata and controls
30 lines (22 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# %% [markdown]
# A brief example on how to use tasks from OpenML.
# %%
import openml
# %% [markdown]
# Get a [task](https://docs.openml.org/concepts/tasks/) for
# [supervised classification on credit-g](https://www.openml.org/search?type=task&id=31&source_data.data_id=31):
# %%
# New: top-level convenience alias
task = openml.get_task(31)
# Old path still works:
# task = openml.tasks.get_task(31)
# %% [markdown]
# Get the dataset and its data from the task.
# %%
dataset = task.get_dataset()
X, y, categorical_indicator, attribute_names = dataset.get_data(target=task.target_name)
# %% [markdown]
# Get the first out of the 10 cross-validation splits from the task.
# %%
train_indices, test_indices = task.get_train_test_split_indices(fold=0)
print(train_indices[:10]) # print the first 10 indices of the training set