functions
attributes_arff_from_df(df)
¶
Describe attributes of the dataframe according to ARFF specification.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
(DataFrame, shape(n_samples, n_features))
|
The dataframe containing the data set. |
required |
Returns:
Name | Type | Description |
---|---|---|
attributes_arff |
list[str]
|
The data set attributes as required by the ARFF format. |
Source code in openml/datasets/functions.py
check_datasets_active(dataset_ids, raise_error_if_not_exist=True)
¶
Check if the dataset ids provided are active.
Raises an error if a dataset_id in the given list
of dataset_ids does not exist on the server and
raise_error_if_not_exist
is set to True (default).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_ids
|
List[int]
|
A list of integers representing dataset ids. |
required |
raise_error_if_not_exist
|
bool(default=True)
|
Flag that if activated can raise an error, if one or more of the given dataset ids do not exist on the server. |
True
|
Returns:
Type | Description |
---|---|
dict
|
A dictionary with items {did: bool} |
Source code in openml/datasets/functions.py
create_dataset(name, description, creator, contributor, collection_date, language, licence, attributes, data, default_target_attribute, ignore_attribute, citation, row_id_attribute=None, original_data_url=None, paper_url=None, update_comment=None, version_label=None)
¶
Create a dataset.
This function creates an OpenMLDataset object. The OpenMLDataset object contains information related to the dataset and the actual data file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the dataset. |
required |
description
|
str
|
Description of the dataset. |
required |
creator
|
str
|
The person who created the dataset. |
required |
contributor
|
str
|
People who contributed to the current version of the dataset. |
required |
collection_date
|
str
|
The date the data was originally collected, given by the uploader. |
required |
language
|
str
|
Language in which the data is represented. Starts with 1 upper case letter, rest lower case, e.g. 'English'. |
required |
licence
|
str
|
License of the data. |
required |
attributes
|
list, dict, or 'auto'
|
A list of tuples. Each tuple consists of the attribute name and type.
If passing a pandas DataFrame, the attributes can be automatically
inferred by passing |
required |
data
|
(ndarray, list, dataframe, coo_matrix, shape(n_samples, n_features))
|
An array that contains both the attributes and the targets. When
providing a dataframe, the attribute names and type can be inferred by
passing |
required |
default_target_attribute
|
str
|
The default target attribute, if it exists. Can have multiple values, comma separated. |
required |
ignore_attribute
|
str | list
|
Attributes that should be excluded in modelling, such as identifiers and indexes. Can have multiple values, comma separated. |
required |
citation
|
str
|
Reference(s) that should be cited when building on this data. |
required |
version_label
|
str
|
Version label provided by user. Can be a date, hash, or some other type of id. |
None
|
row_id_attribute
|
str
|
The attribute that represents the row-id column, if present in the
dataset. If .. versionadded: 0.8
Inference of |
None
|
original_data_url
|
str
|
For derived data, the url to the original dataset. |
None
|
paper_url
|
str
|
Link to a paper describing the dataset. |
None
|
update_comment
|
str
|
An explanation for when the dataset is uploaded. |
None
|
Returns:
Name | Type | Description |
---|---|---|
class |
`openml.OpenMLDataset`
|
|
Dataset description.
|
|
Source code in openml/datasets/functions.py
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 |
|
data_feature_add_ontology(data_id, index, ontology)
¶
An ontology describes the concept that are described in a feature. An ontology is defined by an URL where the information is provided. Adds an ontology (URL) to a given dataset feature (defined by a dataset id and index). The dataset has to exists on OpenML and needs to have been processed by the evaluation engine.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_id
|
int
|
id of the dataset to which the feature belongs |
required |
index
|
int
|
index of the feature in dataset (0-based) |
required |
ontology
|
str
|
URL to ontology (max. 256 characters) |
required |
Returns:
Type | Description |
---|---|
True or throws an OpenML server exception
|
|
Source code in openml/datasets/functions.py
data_feature_remove_ontology(data_id, index, ontology)
¶
Removes an existing ontology (URL) from a given dataset feature (defined by a dataset id and index). The dataset has to exists on OpenML and needs to have been processed by the evaluation engine. Ontology needs to be attached to the specific fearure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_id
|
int
|
id of the dataset to which the feature belongs |
required |
index
|
int
|
index of the feature in dataset (0-based) |
required |
ontology
|
str
|
URL to ontology (max. 256 characters) |
required |
Returns:
Type | Description |
---|---|
True or throws an OpenML server exception
|
|
Source code in openml/datasets/functions.py
delete_dataset(dataset_id)
¶
Delete dataset with id dataset_id
from the OpenML server.
This can only be done if you are the owner of the dataset and no tasks are attached to the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
int
|
OpenML id of the dataset |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the deletion was successful. False otherwise. |
Source code in openml/datasets/functions.py
edit_dataset(data_id, description=None, creator=None, contributor=None, collection_date=None, language=None, default_target_attribute=None, ignore_attribute=None, citation=None, row_id_attribute=None, original_data_url=None, paper_url=None)
¶
Edits an OpenMLDataset.
In addition to providing the dataset id of the dataset to edit (through data_id), you must specify a value for at least one of the optional function arguments, i.e. one value for a field to edit.
This function allows editing of both non-critical and critical fields. Critical fields are default_target_attribute, ignore_attribute, row_id_attribute.
- Editing non-critical data fields is allowed for all authenticated users.
- Editing critical fields is allowed only for the owner, provided there are no tasks associated with this dataset.
If dataset has tasks or if the user is not the owner, the only way to edit critical fields is to use fork_dataset followed by edit_dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_id
|
int
|
ID of the dataset. |
required |
description
|
str
|
Description of the dataset. |
None
|
creator
|
str
|
The person who created the dataset. |
None
|
contributor
|
str
|
People who contributed to the current version of the dataset. |
None
|
collection_date
|
str
|
The date the data was originally collected, given by the uploader. |
None
|
language
|
str
|
Language in which the data is represented. Starts with 1 upper case letter, rest lower case, e.g. 'English'. |
None
|
default_target_attribute
|
str
|
The default target attribute, if it exists. Can have multiple values, comma separated. |
None
|
ignore_attribute
|
str | list
|
Attributes that should be excluded in modelling, such as identifiers and indexes. |
None
|
citation
|
str
|
Reference(s) that should be cited when building on this data. |
None
|
row_id_attribute
|
str
|
The attribute that represents the row-id column, if present in the
dataset. If .. versionadded: 0.8
Inference of |
None
|
original_data_url
|
str
|
For derived data, the url to the original dataset. |
None
|
paper_url
|
str
|
Link to a paper describing the dataset. |
None
|
Returns:
Type | Description |
---|---|
Dataset id
|
|
Source code in openml/datasets/functions.py
915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 |
|
fork_dataset(data_id)
¶
Creates a new dataset version, with the authenticated user as the new owner. The forked dataset can have distinct dataset meta-data, but the actual data itself is shared with the original version.
This API is intended for use when a user is unable to edit the critical fields of a dataset through the edit_dataset API. (Critical fields are default_target_attribute, ignore_attribute, row_id_attribute.)
Specifically, this happens when the user is: 1. Not the owner of the dataset. 2. User is the owner of the dataset, but the dataset has tasks.
In these two cases the only way to edit critical fields is: 1. STEP 1: Fork the dataset using fork_dataset API 2. STEP 2: Call edit_dataset API on the forked version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_id
|
int
|
id of the dataset to be forked |
required |
Returns:
Type | Description |
---|---|
Dataset id of the forked dataset
|
|
Source code in openml/datasets/functions.py
get_dataset(dataset_id, download_data=None, version=None, error_if_multiple=False, cache_format='pickle', download_qualities=None, download_features_meta_data=None, download_all_files=False, force_refresh_cache=False)
¶
Download the OpenML dataset representation, optionally also download actual data file.
This function is by default NOT thread/multiprocessing safe, as this function uses caching. A check will be performed to determine if the information has previously been downloaded to a cache, and if so be loaded from disk instead of retrieved from the server.
To make this function thread safe, you can install the python package oslo.concurrency
.
If oslo.concurrency
is installed get_dataset
becomes thread safe.
Alternatively, to make this function thread/multiprocessing safe initialize the cache first by
calling get_dataset(args)
once before calling get_dataset(args)
many times in parallel.
This will initialize the cache and later calls will use the cache in a thread/multiprocessing
safe way.
If dataset is retrieved by name, a version may be specified.
If no version is specified and multiple versions of the dataset exist,
the earliest version of the dataset that is still active will be returned.
If no version is specified, multiple versions of the dataset exist and
exception_if_multiple
is set to True
, this function will raise an exception.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
int or str
|
Dataset ID of the dataset to download |
required |
download_data
|
bool(default=True)
|
If True, also download the data file. Beware that some datasets are large and it might
make the operation noticeably slower. Metadata is also still retrieved.
If False, create the OpenMLDataset and only populate it with the metadata.
The data may later be retrieved through the |
None
|
version
|
(int, optional(default=None))
|
Specifies the version if |
None
|
error_if_multiple
|
bool(default=False)
|
If |
False
|
cache_format
|
str(default='pickle') in {'pickle', 'feather'}
|
Format for caching the dataset - may be feather or pickle Note that the default 'pickle' option may load slower than feather when no.of.rows is very high. |
'pickle'
|
download_qualities
|
bool(default=True)
|
Option to download 'qualities' meta-data in addition to the minimal dataset description.
If True, download and cache the qualities file.
If False, create the OpenMLDataset without qualities metadata. The data may later be added
to the OpenMLDataset through the |
None
|
download_features_meta_data
|
bool(default=True)
|
Option to download 'features' meta-data in addition to the minimal dataset description.
If True, download and cache the features file.
If False, create the OpenMLDataset without features metadata. The data may later be added
to the OpenMLDataset through the |
None
|
download_all_files
|
bool
|
EXPERIMENTAL. Download all files related to the dataset that reside on the server. Useful for datasets which refer to auxiliary files (e.g., meta-album). |
False
|
force_refresh_cache
|
bool(default=False)
|
Force the cache to refreshed by deleting the cache directory and re-downloading the data.
Note, if |
False
|
Returns:
Name | Type | Description |
---|---|---|
dataset |
:class:`openml.OpenMLDataset`
|
The downloaded dataset. |
Source code in openml/datasets/functions.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
|
get_datasets(dataset_ids, download_data=True, download_qualities=True)
¶
Download datasets.
This function iterates :meth:openml.datasets.get_dataset
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_ids
|
iterable
|
Integers or strings representing dataset ids or dataset names. If dataset names are specified, the least recent still active dataset version is returned. |
required |
download_data
|
bool
|
If True, also download the data file. Beware that some datasets are large and it might
make the operation noticeably slower. Metadata is also still retrieved.
If False, create the OpenMLDataset and only populate it with the metadata.
The data may later be retrieved through the |
True
|
download_qualities
|
(bool, optional(default=True))
|
If True, also download qualities.xml file. If False it skip the qualities.xml. |
True
|
Returns:
Name | Type | Description |
---|---|---|
datasets |
list of datasets
|
A list of dataset objects. |
Source code in openml/datasets/functions.py
list_datasets(data_id=None, offset=None, size=None, status=None, tag=None, output_format='dict', **kwargs)
¶
Return a list of all dataset which are on OpenML. Supports large amount of results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_id
|
list
|
A list of data ids, to specify which datasets should be listed |
None
|
offset
|
int
|
The number of datasets to skip, starting from the first. |
None
|
size
|
int
|
The maximum number of datasets to show. |
None
|
status
|
str
|
Should be {active, in_preparation, deactivated}. By default active datasets are returned, but also datasets from another status can be requested. |
None
|
tag
|
str
|
|
None
|
output_format
|
Literal['dataframe', 'dict']
|
The parameter decides the format of the output. - If 'dict' the output is a dict of dict - If 'dataframe' the output is a pandas DataFrame |
'dict'
|
kwargs
|
dict
|
Legal filter operators (keys in the dict): data_name, data_version, number_instances, number_features, number_classes, number_missing_values. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
datasets |
dict of dicts, or dataframe
|
|
Source code in openml/datasets/functions.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
list_qualities()
¶
Return list of data qualities available.
The function performs an API call to retrieve the entire list of data qualities that are computed on the datasets uploaded.
Returns:
Type | Description |
---|---|
list
|
|
Source code in openml/datasets/functions.py
status_update(data_id, status)
¶
Updates the status of a dataset to either 'active' or 'deactivated'. Please see the OpenML API documentation for a description of the status and all legal status transitions: https://docs.openml.org/#dataset-status
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_id
|
int
|
The data id of the dataset |
required |
status
|
(str)
|
'active' or 'deactivated' |
required |