/// <summary> /// Feature Contribution Calculation computes model-specific contribution scores for each feature. /// Note that this functionality is not supported by all the models. See <see cref="FeatureContributionCalculatingTransformer"/> for a list of the suported models. /// </summary> /// <param name="env">The environment to use.</param> /// <param name="modelParameters">Trained model parameters that support Feature Contribution Calculation and which will be used for scoring.</param> /// <param name="featureColumnName">The name of the feature column that will be used as input.</param> /// <param name="numberOfPositiveContributions">The number of positive contributions to report, sorted from highest magnitude to lowest magnitude. /// Note that if there are fewer features with positive contributions than <paramref name="numberOfPositiveContributions"/>, the rest will be returned as zeros.</param> /// <param name="numberOfNegativeContributions">The number of negative contributions to report, sorted from highest magnitude to lowest magnitude. /// Note that if there are fewer features with negative contributions than <paramref name="numberOfNegativeContributions"/>, the rest will be returned as zeros.</param> /// <param name="normalize">Whether the feature contributions should be normalized to the [-1, 1] interval.</param> internal FeatureContributionCalculatingTransformer(IHostEnvironment env, ICalculateFeatureContribution modelParameters, string featureColumnName = DefaultColumnNames.Features, int numberOfPositiveContributions = FeatureContributionCalculatingEstimator.Defaults.NumberOfPositiveContributions, int numberOfNegativeContributions = FeatureContributionCalculatingEstimator.Defaults.NumberOfNegativeContributions, bool normalize = FeatureContributionCalculatingEstimator.Defaults.Normalize) : base(Contracts.CheckRef(env, nameof(env)).Register(nameof(FeatureContributionCalculatingTransformer)), new[] { (name: DefaultColumnNames.FeatureContributions, source: featureColumnName) })
/// <summary> /// Feature Contribution Calculation computes model-specific contribution scores for each feature. /// Note that this functionality is not supported by all the models. See <see cref="FeatureContributionCalculatingTransformer"/> for a list of the suported models. /// </summary> /// <param name="env">The environment to use.</param> /// <param name="modelParameters">Trained model parameters that support Feature Contribution Calculation and which will be used for scoring.</param> /// <param name="featureColumn">The name of the feature column that will be used as input.</param> /// <param name="numPositiveContributions">The number of positive contributions to report, sorted from highest magnitude to lowest magnitude. /// Note that if there are fewer features with positive contributions than <paramref name="numPositiveContributions"/>, the rest will be returned as zeros.</param> /// <param name="numNegativeContributions">The number of negative contributions to report, sorted from highest magnitude to lowest magnitude. /// Note that if there are fewer features with negative contributions than <paramref name="numNegativeContributions"/>, the rest will be returned as zeros.</param> /// <param name="normalize">Whether the feature contributions should be normalized to the [-1, 1] interval.</param> public FeatureContributionCalculatingTransformer(IHostEnvironment env, ICalculateFeatureContribution modelParameters, string featureColumn = DefaultColumnNames.Features, int numPositiveContributions = FeatureContributionCalculatingEstimator.Defaults.NumPositiveContributions, int numNegativeContributions = FeatureContributionCalculatingEstimator.Defaults.NumNegativeContributions, bool normalize = FeatureContributionCalculatingEstimator.Defaults.Normalize) : base(Contracts.CheckRef(env, nameof(env)).Register(nameof(FeatureContributionCalculatingTransformer)), new[] { (input: featureColumn, output: DefaultColumnNames.FeatureContributions) })
/// <summary> /// Feature Contribution Calculation computes model-specific contribution scores for each feature. /// Note that this functionality is not supported by all the models. See <see cref="FeatureContributionCalculatingTransformer"/> for a list of the suported models. /// </summary> /// <param name="catalog">The model explainability operations catalog.</param> /// <param name="modelParameters">Trained model parameters that support Feature Contribution Calculation and which will be used for scoring.</param> /// <param name="featureColumn">The name of the feature column that will be used as input.</param> /// <param name="top">The number of features with highest positive contributions for each data sample that will be retained in the FeatureContribution column. /// Note that if there are fewer features with positive contributions than <paramref name="top"/>, the rest will be returned as zeros.</param> /// <param name="bottom">The number of features with least negative contributions for each data sample that will be retained in the FeatureContribution column. /// Note that if there are fewer features with negative contributions than <paramref name="bottom"/>, the rest will be returned as zeros.</param> /// <param name="normalize">Whether the feature contributions should be normalized to the [-1, 1] interval.</param> public static FeatureContributionCalculatingEstimator FeatureContributionCalculation(this ModelOperationsCatalog.ExplainabilityTransforms catalog, ICalculateFeatureContribution modelParameters, string featureColumn = DefaultColumnNames.Features, int top = FeatureContributionDefaults.Top, int bottom = FeatureContributionDefaults.Bottom, bool normalize = FeatureContributionDefaults.Normalize) => new FeatureContributionCalculatingEstimator(CatalogUtils.GetEnvironment(catalog), modelParameters, featureColumn, top, bottom, normalize);