FeatureLineage#
- class scikitplot.feature_selection.FeatureLineage(nodes, edges, stages, stage_inputs, input_ids, output_ids, estimator, final_estimator=None)[source]#
Traced feature graph of a fitted pipeline.
- Parameters:
- nodes, edges, stagestuples
Graph records (see
FeatureNode,LineageEdge,StageRecord).- stage_inputstuple of (str, tuple of int)
Input node ids of every stage, in the order of
stages.- input_ids, output_idstuple of int
Node ids of the raw inputs and of the final outputs (model inputs).
- estimatorstr
Class name of the traced object.
- final_estimatorstr or None
Class name of a pipeline’s final, non-transformer step.
- Parameters:
See also
trace_pipelineBuild a lineage.
- attribute(values, *, how='sum')[source]#
Aggregate per-output values (importances, SHAP values) onto raw inputs.
- Parameters:
- valuesarray-like, pandas.Series or mapping
1-D: one value per output (array aligned with
output_names, or a Series/mapping keyed by output name). 2-D array or DataFrame:n_samples x n_outputs(a DataFrame is aligned by column name).- how{“sum”, “abs_sum”, “mean”, “max”}, default=”sum”
Aggregation over the outputs of one input.
- Returns:
- Attribution
Attributed and unattributed parts.
- Raises:
- ValueError
If the values do not align with the outputs.
- Parameters:
- Return type:
Notes
An output is attributed only when it has exactly one raw origin and every edge on its paths is
exact. Polynomial interactions, PCA components and unknown steps are reported inAttribution.unattributedinstead of being split by a guess.
- descendants(name, stage='input', *, to='output')[source]#
Return the features at stage
tocomputed fromname.
- classmethod from_dict(data)[source]#
Rebuild a lineage from
to_dictoutput.- Parameters:
- datamapping
Stored form.
- Returns:
- FeatureLineage
The lineage.
- Raises:
- IncompatibleSchemaError
For another generation or artefact type.
- ValueError
For an off-contract record.
- Parameters:
- Return type:
- history(name)[source]#
Return every leaf stage that touched the descendants of input
name.- Parameters:
- namestr
Raw input name.
- Returns:
- pandas.DataFrame
Columns
stage,estimator,relation,qualityandfeatures(the names this input became at that stage), in pipeline order. Containers (pipelines, column transformers) are listed withestimatorset to their class.
- Parameters:
name (str)
- Return type:
- classmethod loads(text, format='json')[source]#
Parse a document written by
dumpswithjsonoryaml.- Parameters:
- textstr
The document.
- format{“json”, “yaml”}, default=”json”
Format.
- Returns:
- FeatureLineage
The lineage.
- Parameters:
- Return type:
- origins(name, stage='output', *, to='input')[source]#
Return the features at stage
tothatnameis computed from.
- property output_names: list[str]#
Final output names (what the model sees), in column order.
- Type:
List of str
- quality(name, stage='output')[source]#
Return the weakest lineage quality on any path from the inputs to
name.
- stage_summary()[source]#
Return one row per traced stage.
- Returns:
- pandas.DataFrame
Columns
path,estimator,container,relation,quality,n_in,n_out,delta,observed_width,note.
- Return type: