Загрузка
Fetch dataset from openml by name or dataset id.
Datasets are uniquely identified by either an integer ID or by a combination of name and version (i.e. there might be multiple versions of the ‘iris’ dataset). Please give either name or data_id (not both). In case a name is given, a version can also be provided.
Read more in the User Guide.
String identifier of the dataset. Note that OpenML can have multiple datasets with the same name.
Version of the dataset. Can only be provided if also name is given.
If ‘active’ the oldest version that’s still active is used. Since
there may be more than one active version of a dataset, and those
versions may fundamentally be different from one another, setting an
exact version is highly recommended.
OpenML ID of the dataset. The most specific way of retrieving a dataset. If data_id is not given, name (and potential version) are used to obtain a dataset.
Specify another download and cache folder for the data sets. By default all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
Specify the column name in the data to use as target. If
‘default-target’, the standard target column a stored on the server
is used. If None, all columns are returned as data and the
target is None. If list (of strings), all columns with these names
are returned as multi-target (Note: not all scikit-learn classifiers
can handle all types of multi-output combinations).
Whether to cache the downloaded datasets into data_home.
If True, returns (data, target) instead of a Bunch object. See
below for more information about the data and target objects.
If True, the data is a pandas DataFrame including columns with
appropriate dtypes (numeric, string or categorical). The target is
a pandas DataFrame or Series depending on the number of target_columns.
The Bunch will contain a frame attribute with the target and the
data. If return_X_y is True, then (data, target) will be pandas
DataFrames or Series as describe above.
If as_frame is ‘auto’, the data and target will be converted to
DataFrame or Series as if as_frame is set to True, unless the dataset
is stored in sparse format.
If as_frame is False, the data and target will be NumPy arrays and
the data will only contain numerical values when parser="liac-arff"
where the categories are provided in the attribute categories of the
instance. When , no ordinal encoding is made.
Number of retries when HTTP errors or network timeouts are encountered. Error with status code 412 won’t be retried as they represent OpenML generic errors.
Number of seconds between retries.
Parser used to load the ARFF file. Two parsers are implemented:
"pandas": this is the most efficient parser. However, it requires
pandas to be installed and can only open dense datasets.
"liac-arff": this is a pure Python ARFF parser that is much less
memory- and CPU-efficient. It deals with sparse ARFF datasets.
If "auto", the parser is chosen automatically such that "liac-arff"
is selected for sparse ARFF datasets, otherwise "pandas" is selected.
Keyword arguments passed to pandas.read_csv when loading the data
from an ARFF file and using the pandas parser. It can allow to
overwrite some default parameters.
BunchDictionary-like object, with the following attributes.
The feature matrix. Categorical features are encoded as ordinals.
The regression target or classification labels, if applicable.
Dtype is float if numeric, and object if categorical. If
as_frame is True, target is a pandas object.
The full description of the dataset.
The "pandas" and "liac-arff" parsers can lead to different data types
in the output. The notable differences are the following:
The "liac-arff" parser always encodes categorical features as str objects.
To the contrary, the "pandas" parser instead infers the type while
reading and numerical categories will be casted into integers whenever
possible.
The "liac-arff" parser uses float64 to encode numerical features
tagged as ‘REAL’ and ‘NUMERICAL’ in the metadata. The "pandas"
parser instead infers if these numerical features corresponds
to integers and uses panda’s Integer extension dtype.
In particular, classification datasets with integer categories are
typically loaded as such (0, 1, ...) with the "pandas" parser while
"liac-arff" will force the use of string encoded class labels such as
"0", and so on.
In addition, when as_frame=False is used, the "liac-arff" parser
returns ordinally encoded data where the categories are provided in the
attribute categories of the Bunch instance. Instead, "pandas" returns
a NumPy array were the categories are not encoded.
>>> from sklearn.datasets import fetch_openml
>>> adult = fetch_openml("adult", version=2)
>>> adult.frame.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 48842 entries, 0 to 48841
Data columns (total 15 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 age 48842 non-null int64
1 workclass 46043 non-null category
2 fnlwgt 48842 non-null int64
Effect of transforming the targets in regression model
Forecasting of CO2 level on Mona Loa dataset using Gaussian process regression (GPR)
Common pitfalls in the interpretation of coefficients of linear models
Partial Dependence and Individual Conditional Expectation Plots
Permutation Importance vs Random Forest Feature Importance (MDI)
MNIST classification using multinomial logistic + L1
Post-tuning the decision threshold for cost-sensitive learning
Post-hoc tuning the cut-off point of decision function
Multilabel classification using a classifier chain
Bunchparser="pandas"Changed in version 1.4: The default value of parser changes from "liac-arff" to
"auto".
The names of the dataset columns.
The names of the target columns.
Maps each categorical feature name to a list of values, such
that the value encoded as i is ith in the list. If as_frame
is True, this is None.
More metadata from OpenML.
Only present when as_frame=True. DataFrame with data and
target.
return_X_y is TrueMissing values in the ‘data’ are represented as NaN’s. Missing values in ‘target’ are represented as NaN’s (numerical target) or None (categorical target).
"1"The "pandas" parser will not strip single quotes - i.e. ' - from
string columns. For instance, a string 'my string' will be kept as is
while the "liac-arff" parser will strip the single quotes. For
categorical columns, the single quotes are stripped from the values.