FeatureSpec#

class scikitplot.feature_selection.FeatureSpec(name, position, role, family, kind, kind_origin, stats, assessments=(), tags=(), binning=None, aliases=())[source]#

Everything a fitted schema knows about one column.

Parameters:
namestr

Current column name.

positionint

Column position in the training frame.

rolestr

FeatureRole value.

familystr

DtypeFamily value.

kindstr

FeatureKind value.

kind_origin{“inferred”, “declared”}

Where the kind came from.

statsFeatureStats

Training statistics.

assessmentstuple of Assessment

Sorted by name.

tagstuple of str, default=()

User tags.

binningBinningRecommendation or None, default=None

Bin recommendation, when binning is enabled.

aliasestuple of str, default=()

Earlier names, oldest first (see FeatureSchema.rename).

Parameters:

See also

FeatureSchema

The collection of specs.

aliases: tuple[str, ...] = ()#
assess(name)[source]#

Return the recorded answer to assessment name.

Parameters:
namestr

Assessment name ("skewed", "discrete" …).

Returns:
Assessment

State, reasons, evidence and provenance.

Raises:
KeyError

If the schema’s policy did not run that assessment; the message lists the available names.

Parameters:

name (str)

Return type:

Assessment

property assessment_names: tuple[str, ...]#

Names of the recorded assessments.

Type:

Tuple of str

assessments: tuple[Assessment, ...] = ()#
binning: BinningRecommendation | None = None#
explain()[source]#

Return a short, human-readable description of the feature.

Returns:
str

Several lines: role, kind, key statistics, true assessments, and the binning recommendation.

Return type:

str

family: str[source]#
classmethod from_dict(data)[source]#

Rebuild a spec from to_dict output, checking every field.

Parameters:
datamapping

Stored form.

Returns:
FeatureSpec

The spec.

Raises:
ValueError

For an off-contract record.

Parameters:

data (Mapping[str, Any])

Return type:

FeatureSpec

is_(name)[source]#

Answer “am I name?” strictly.

Parameters:
namestr

Assessment name.

Returns:
bool

True only when the state is "true"; unknown and not_applicable give False. Use state to tell them apart.

Parameters:

name (str)

Return type:

bool

property is_model_input: bool#

The role is "feature".

Type:

bool

kind: str[source]#
kind_origin: str[source]#
name: str[source]#
position: int[source]#
role: str[source]#
state(name)[source]#

Return the state of assessment name.

Parameters:
namestr

Assessment name.

Returns:
str

"true", "false", "unknown" or "not_applicable".

Parameters:

name (str)

Return type:

str

stats: FeatureStats[source]#
tags: tuple[str, ...] = ()#
to_dict()[source]#

Return the shared-data-model form.

Return type:

dict[str, Any]