profile_features#

scikitplot.feature_selection.profile_features(X, policy=None, *, registry=None)[source]#

Fit a FeatureSchema on training data.

Parameters:
Xpandas.DataFrame

Training data with unique string column labels. Target and other non-feature columns may be included and are given their roles by the policy.

policyFeaturePolicy, mapping, path or None, default=None

Policy, its config form, or a TOML/YAML/JSON file; None uses defaults.

registryAssessmentRegistry or None, default=None

Provider registry; the shared default when None.

Returns:
FeatureSchema

The fitted schema.

Raises:
TypeError, ValueError

For a non-DataFrame, non-string or duplicated labels.

PolicyError

For a policy that names missing columns (unless ignored), an unknown provider or invalid provider parameters.

Parameters:
Return type:

FeatureSchema

See also

FeatureProfiler

The same inside a scikit-learn pipeline.

Notes

User note. Call it on the training split only. Profiling validation or test data separately can classify columns differently and leaks their statistics into preprocessing decisions; use FeatureSchema.audit and ReferenceProfile for later data.

Examples

>>> import pandas as pd
>>> from scikitplot.feature_selection import profile_features
>>> X = pd.DataFrame({"id": [f"c{i}" for i in range(30)], "x": [0.5] * 30})
>>> schema = profile_features(X)
>>> schema["id"].is_("identifier_like"), schema["x"].is_("constant")
(True, True)