Flow
sklearn.preprocessing._encoders.OneHotEncoder

sklearn.preprocessing._encoders.OneHotEncoder

Visibility: public Uploaded 16-05-2023 by Eduardo Denadai sklearn==1.1.2 numpy>=1.17.3 scipy>=1.3.2 joblib>=1.0.0 threadpoolctl>=2.0.0 0 runs
0 likes downloaded by 0 people 0 issues 0 downvotes , 0 total downloads
  • openml-python python scikit-learn sklearn sklearn_1.1.2
Issue #Downvotes for this reason By


Loading wiki
Help us complete this description Edit
Encode categorical features as a one-hot numeric array. The input to this transformer should be an array-like of integers or strings, denoting the values taken on by categorical (discrete) features. The features are encoded using a one-hot (aka 'one-of-K' or 'dummy') encoding scheme. This creates a binary column for each category and returns a sparse matrix or dense array (depending on the ``sparse`` parameter) By default, the encoder derives the categories based on the unique values in each feature. Alternatively, you can also specify the `categories` manually. This encoding is needed for feeding categorical data to many scikit-learn estimators, notably linear models and SVMs with the standard kernels. Note: a one-hot encoding of y labels should use a LabelBinarizer instead.

Parameters

categoriesCategories (unique values) per feature: - 'auto' : Determine categories automatically from the training data - list : ``categories[i]`` holds the categories expected in the ith column. The passed categories should not mix strings and numeric values within a single feature, and should be sorted in case of numeric values The used categories can be found in the ``categories_`` attribute .. versionadded:: 0.20 drop : {'first', 'if_binary'} or an array-like of shape (n_features,), default=None Specifies a methodology to use to drop one of the categories per feature. This is useful in situations where perfectly collinear features cause problems, such as when feeding the resulting data into an unregularized linear regression model However, dropping one category breaks the symmetry of the original representation and can therefore induce a bias in downstream models, for instance for penalized linear classification or regression modelsdefault: "auto"
dropdefault: null
dtypeDesired dtype of output handle_unknown : {'error', 'ignore', 'infrequent_if_exist'}, default='error' Specifies the way unknown categories are handled during :meth:`transform` - 'error' : Raise an error if an unknown category is present during transform - 'ignore' : When an unknown category is encountered during transform, the resulting one-hot encoded columns for this feature will be all zeros. In the inverse transform, an unknown category will be denoted as None - 'infrequent_if_exist' : When an unknown category is encountered during transform, the resulting one-hot encoded columns for this feature will map to the infrequent category if it exists. The infrequent category will be mapped to the last position in the encoding. During inverse transform, an unknown category will be mapped to the category denoted `'infrequent'` if it exists. If the `'infrequent'` category does not exist, then :meth:`transform` and ...default: {"oml-python:serialized_object": "type", "value": "np.float64"}
handle_unknowndefault: "ignore"
max_categoriesSpecifies an upper limit to the number of output features for each input feature when considering infrequent categories. If there are infrequent categories, `max_categories` includes the category representing the infrequent categories along with the frequent categories. If `None`, there is no limit to the number of output features .. versionadded:: 1.1 Read more in the :ref:`User Guide `.default: null
min_frequencySpecifies the minimum frequency below which a category will be considered infrequent - If `int`, categories with a smaller cardinality will be considered infrequent - If `float`, categories with a smaller cardinality than `min_frequency * n_samples` will be considered infrequent .. versionadded:: 1.1 Read more in the :ref:`User Guide `default: null
sparseWill return sparse matrix if set True else will return an arraydefault: true

0
Runs

List all runs
Parameter:
Rendering chart
Rendering table