Skip to content

Feature Contribution Calculation should become Transformer #1791

@artidoro

Description

@artidoro

We should make the FeatureContributionCalculationTransform a transfomrer, and add a related estimator that produces it so that it can become part of a pipeline. Below I show how it could look like with the new API:

// Define a pipeline for feature extraction with a trainer at the end
var pipeline_1 = mlContext.BinaryClassification.Trainers.trainerEstimator(arguments);
// Train model and cast it to IPredictor
var predictor = pipeline.Fit(data).Model;

Two ways of applying FeatureContributionCalculation:

// 1 First Way: Define another pipeline with FeatureContributionCalculation and possibly more 
// estimators appended to it
var pipeline_2 = mlContext.Model.Explainability.FeatureContributionCalculatingEstimator(arguments, predictor);
var outputData = pipeline_2.Fit(data).Transform(data);
// 2 Second Way: Use the transformer directly, as it is not a trainable transformer
var transformer = new FeatureContributionCalculatingTransformer(mlContext, arguments, predictor);
var outputData = transformer.Transform(data);

In either cases the output data will contain a score column along with a FeatureContribution column.

cc: @rogancarr, @TomFinley, @Zruty0, @Ivanidzo4ka

Metadata

Metadata

Assignees

Labels

APIIssues pertaining the friendly API

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions