<jupyter_start><jupyter_text>Tasks=====A tutorial on how to list and download tasks.<jupyter_code>import openml
import pandas as pd
from pprint import pprint<jupyter_output><empty_output><jupyter_text>Tasks are identified by IDs and can be accessed in two different ways:1. In a list providing basic information on all tasks available on OpenML.This function will not download the actual tasks, but will instead downloadmeta data that can be used to filter the tasks and retrieve a set of IDs.We can filter this list, for example, we can only list tasks having aspecial tag or only tasks for a specific target such as*supervised classification*.2. A single task by its ID. It contains all meta information, the targetmetric, the splits and an iterator which can be used to access thesplits in a useful manner. Listing tasks^^^^^^^^^^^^^We will start by simply listing only *supervised classification* tasks:<jupyter_code>tasks = openml.tasks.list_tasks(task_type_id=1)<jupyter_output><empty_output><jupyter_text>**openml.tasks.list_tasks()** returns a dictionary of dictionaries, we convert it into a`pandas dataframe `_to have better visualization and easier access:<jupyter_code>tasks = pd.DataFrame.from_dict(tasks, orient='index')
print(tasks.columns)
print("First 5 of %s tasks:" % len(tasks))
pprint(tasks.head())<jupyter_output><empty_output><jupyter_text>We can filter the list of tasks to only contain datasets with more than500 samples, but less than 1000 samples:<jupyter_code>filtered_tasks = tasks.query('NumberOfInstances > 500 and NumberOfInstances < 1000')
print(list(filtered_tasks.index))
# Number of tasks
print(len(filtered_tasks))<jupyter_output><empty_output><jupyter_text>Then, we can further restrict the tasks to all have the same resampling strategy:<jupyter_code>filtered_tasks = filtered_tasks.query('estimation_procedure == "10-fold Crossvalidation"')
print(list(filtered_tasks.index))
# Number of tasks
print(len(filtered_tasks))<jupyter_output><empty_output><jupyter_text>Resampling strategies can be found on the`OpenML Website `_.Similar to listing tasks by task type, we can list tasks by tags:<jupyter_code>tasks = openml.tasks.list_tasks(tag='OpenML100')
tasks = pd.DataFrame.from_dict(tasks, orient='index')
print("First 5 of %s tasks:" % len(tasks))
pprint(tasks.head())<jupyter_output><empty_output><jupyter_text>Furthermore, we can list tasks based on the dataset id:<jupyter_code>tasks = openml.tasks.list_tasks(data_id=61)
tasks = pd.DataFrame.from_dict(tasks, orient='index')
print("First 5 of %s tasks:" % len(tasks))
pprint(tasks.head())<jupyter_output><empty_output><jupyter_text>In addition, a size limit and an offset can be applied both separately and simultaneously:<jupyter_code>tasks = openml.tasks.list_tasks(size=10, offset=50)
tasks = pd.DataFrame.from_dict(tasks, orient='index')
pprint(tasks)<jupyter_output><empty_output><jupyter_text>**OpenML 100**is a curated list of 100 tasks to start using OpenML. They are allsupervised classification tasks with more than 500 instances and less than 50000instances per task. To make things easier, the tasks do not contain highlyunbalanced data and sparse data. However, the tasks include missing values andcategorical features. You can find out more about the *OpenML 100* on`the OpenML benchmarking page `_.Finally, it is also possible to list all tasks on OpenML with:<jupyter_code>tasks = openml.tasks.list_tasks()
tasks = pd.DataFrame.from_dict(tasks, orient='index')
print(len(tasks))<jupyter_output><empty_output><jupyter_text>ExerciseSearch for the tasks on the 'eeg-eye-state' dataset.<jupyter_code>tasks.query('name=="eeg-eye-state"')<jupyter_output><empty_output><jupyter_text>Downloading tasks^^^^^^^^^^^^^^^^^We provide two functions to download tasks, one which downloads only asingle task by its ID, and one which takes a list of IDs and downloadsall of these tasks:<jupyter_code>task_id = 1
task = openml.tasks.get_task(task_id)<jupyter_output><empty_output><jupyter_text>Properties of the task are stored as member variables:<jupyter_code>pprint(vars(task))<jupyter_output><empty_output><jupyter_text>And:<jupyter_code>ids = [1, 2, 19, 97, 403]
tasks = openml.tasks.get_tasks(ids)
pprint(tasks[0])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0983026874115983, 'fraction_numerical': 0.013908533710513909, 'mean_word_length': 7.571717171717172, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '283683', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1290, 'n_words': 416, 'path': 'doc/examples/tasks_tutorial.ipynb', 'repo_name': 'MichaelMMeskhi/openml-python', 'size': '4242'}