FeaturePolicy#
- class scikitplot.feature_selection.FeaturePolicy(roles=(), kinds=(), tags=(), assessments=(), overrides=(), binning=<factory>, drift=<factory>, on_missing_column='raise')[source]#
Complete, declarative description of how to profile a table.
- Parameters:
- rolesmapping of role to ColumnRule-like, default=()
Columns with a role other than
"feature"(target,drop,identifier,weight,group,time). A column matched by two roles is an error.- kindsmapping of column to kind, default=()
Explicit semantic kinds that replace inference (for example a numeric
zip_codedeclared"categorical_nominal", or"text").- tagsmapping of tag to ColumnRule-like, default=()
Free user labels (
"one_hot","engineered","sensitive"); a column can carry many tags. Tags never change inference.- assessmentsmapping of name to AssessmentSpec-like, default=()
Merged over
DEFAULT_ASSESSMENTSby name.- overridesmapping of column to mapping of assessment to bool, default=()
Manual answers. The inferred answer is kept next to the override.
- binningBinningPolicy or mapping, default=BinningPolicy()
Bin recommendation settings.
- driftDriftPolicy or mapping, default=DriftPolicy()
Drift reference settings.
- on_missing_column{“raise”, “ignore”}, default=”raise”
What to do when
roles,kinds,tagsoroverridesname a column that is not in the data.
- Parameters:
roles (tuple[tuple[str, ColumnRule], ...])
tags (tuple[tuple[str, ColumnRule], ...])
assessments (tuple[tuple[str, AssessmentSpec], ...])
overrides (tuple[tuple[str, tuple[tuple[str, bool], ...]], ...])
binning (BinningPolicy)
drift (DriftPolicy)
on_missing_column (str)
See also
load_policyRead a policy from TOML, YAML or JSON.
dump_policyWrite a policy, verified by reading it back.
profile_featuresFit a schema from a DataFrame and a policy.
Notes
User note. Keep one policy per project in version control. Its
digestis recorded in every fitted schema, so you can tell which configuration produced a result.Developer note. Stored containers are sorted tuples of pairs; the
*_mapproperties return fresh dictionaries.Examples
>>> from scikitplot.feature_selection import FeaturePolicy >>> policy = FeaturePolicy( ... roles={"target": ["churn"]}, ... assessments={ ... "skewed": {"provider": "skewed", "params": {"threshold": 0.75}} ... }, ... ) >>> policy.assessments_map["skewed"].params_dict["threshold"] 0.75 >>> FeaturePolicy.from_dict(policy.to_dict()) == policy True
- assessments: tuple[tuple[str, AssessmentSpec], ...] = ()#
- property assessments_map: dict[str, AssessmentSpec]#
Assessment name to spec, defaults included.
- Type:
- binning: BinningPolicy[source]#
- drift: DriftPolicy[source]#
- classmethod from_dict(data)[source]#
Build a policy from its config form, checking every field first.
- Parameters:
- datamapping
A document as produced by
to_dictor written by hand; every key is optional except thatschema_version, when given, must be the supported generation.
- Returns:
- FeaturePolicy
The policy.
- Raises:
- PolicyError
For an unknown key, a wrong type or an out-of-range value.
- IncompatibleSchemaError
For another
schema_version.
- Parameters:
- Return type:
- classmethod loads(text, format='toml')[source]#
Parse a policy document.
- Parameters:
- textstr
The document.
- format{“toml”, “yaml”, “json”}, default=”toml”
Input format.
- Returns:
- FeaturePolicy
The policy.
- Parameters:
- Return type:
- roles: tuple[tuple[str, ColumnRule], ...] = ()#
- property roles_map: dict[str, ColumnRule]#
Role name to column rule.
- Type:
- tags: tuple[tuple[str, ColumnRule], ...] = ()#
- property tags_map: dict[str, ColumnRule]#
Tag to column rule.
- Type: