You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Microsoft.ML.Data/Transforms/ExplainabilityCatalog.cs
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -18,17 +18,17 @@ public static class ExplainabilityCatalog
18
18
/// <param name="catalog">The model explainability operations catalog.</param>
19
19
/// <param name="modelParameters">Trained model parameters that support Feature Contribution Calculation and which will be used for scoring.</param>
20
20
/// <param name="featureColumn">The name of the feature column that will be used as input.</param>
21
-
/// <param name="top">The number of features with highest positive contributions for each data sample that will be retained in the FeatureContribution column.
22
-
/// Note that if there are fewer features with positive contributions than <paramref name="top"/>, the rest will be returned as zeros.</param>
23
-
/// <param name="bottom">The number of features with least negative contributions for each data sample that will be retained in the FeatureContribution column.
24
-
/// Note that if there are fewer features with negative contributions than <paramref name="bottom"/>, the rest will be returned as zeros.</param>
21
+
/// <param name="numPositiveContributions">The number of positive contributions to report, sorted from highest magnitude to lowest magnitude.
22
+
/// Note that if there are fewer features with positive contributions than <paramref name="numPositiveContributions"/>, the rest will be returned as zeros.</param>
23
+
/// <param name="numNegativeContributions">The number of negative contributions to report, sorted from highest magnitude to lowest magnitude.
24
+
/// Note that if there are fewer features with negative contributions than <paramref name="numNegativeContributions"/>, the rest will be returned as zeros.</param>
25
25
/// <param name="normalize">Whether the feature contributions should be normalized to the [-1, 1] interval.</param>
Copy file name to clipboardExpand all lines: src/Microsoft.ML.Data/Transforms/FeatureContributionCalculationTransform.cs
+37-36Lines changed: 37 additions & 36 deletions
Original file line number
Diff line number
Diff line change
@@ -25,29 +25,17 @@
25
25
namespaceMicrosoft.ML.Data
26
26
{
27
27
/// <summary>
28
-
/// The FeatureContributionCalculationTransformer computes model-specific per-feature contributions to the score of each data point.
28
+
/// The FeatureContributionCalculationTransformer computes model-specific per-feature contributions to the score of each example.
29
29
/// See the list of currently supported models below.
30
30
/// </summary>
31
31
/// <remarks>
32
32
/// <para>
33
-
/// Scorind a data set with a trained model produces a score, or prediction, for each data sample. To understand and explain these predictions
33
+
/// Scoring a dataset with a trained model produces a score, or prediction, for each example. To understand and explain these predictions
34
34
/// it can be useful to inspect which features influenced them most significantly. FeatureContributionCalculationTransformer computes a model-specific
35
-
/// list of per-feature contributions to the score for each data sample. These contributions can be positive (they make the score higher) or negative
35
+
/// list of per-feature contributions to the score for each example. These contributions can be positive (they make the score higher) or negative
36
36
/// (they make the score lower).
37
37
/// </para>
38
38
/// <para>
39
-
/// For linear models, the contribution of a given feature is just equal to the product of feature times the corresponding weight. Similarly, for
40
-
/// Generalized Additive Models (GAM), the contrubution of a feature is equal to the shape function for the given feature evaluated at the feature value.
41
-
/// </para>
42
-
/// <para>
43
-
/// For tree based models, the contribution of a feature is equal to the change in score produced by exploring the opposite sub-tree every time a decision
44
-
/// node for the given feature is encountered. Consider a simple case with a singe decision tree that has a decision node for the binary feature F1.
45
-
/// Given a data sample that has feature F1 equal to true, we can calculate the score it would have obtained if we chose the subtree corresponding to
46
-
/// the feature F1 being equal to false while keeping the other features constant. The contribution of feature F1 for the given sample is the difference
47
-
/// between the original score and the score obtained by taking the opposite decision at the node corresponding to feature F1. This algorithm extendes
48
-
/// naturally to models with many decision trees.
49
-
/// </para>
50
-
/// <para>
51
39
/// Feature Contribution Calculation is currently supported for the following models:
/// For linear models, the contribution of a given feature is equal to the product of feature value times the corresponding weight. Similarly,
52
+
/// for Generalized Additive Models (GAM), the contribution of a feature is equal to the shape function for the given feature evaluated at
53
+
/// the feature value.
54
+
/// </para>
55
+
/// <para>
56
+
/// For tree-based models, the contribution of a feature is equal to the change in score produced by exploring the opposite sub-tree every time a decision
57
+
/// node for the given feature is encountered. Consider a simple case with a single decision tree that has a decision node for the binary feature F1.
58
+
/// Given an example that has feature F1 equal to true, we can calculate the score it would have obtained if we chose the subtree corresponding to
59
+
/// the feature F1 being equal to false while keeping the other features constant. The contribution of feature F1 for the given example is the difference
60
+
/// between the original score and the score obtained by taking the opposite decision at the node corresponding to feature F1. This algorithm extends
61
+
/// naturally to models with many decision trees.
62
+
/// </para>
63
+
/// <para>
63
64
/// See the sample below for an example of how to compute feature importance using the FeatureContributionCalculatingTransformer.
64
65
/// </para>
65
66
/// </remarks>
@@ -81,10 +82,10 @@ public sealed class Arguments : TransformInputBase
/// <param name="env">The environment to use.</param>
120
121
/// <param name="modelParameters">Trained model parameters that support Feature Contribution Calculation and which will be used for scoring.</param>
121
122
/// <param name="featureColumn">The name of the feature column that will be used as input.</param>
122
-
/// <param name="top">The number of features with highest positive contributions for each data sample that will be retained in the FeatureContribution column.
123
-
/// Note that if there are fewer features with positive contributions than <paramref name="top"/>, the rest will be returned as zeros.</param>
124
-
/// <param name="bottom">The number of features with least negative contributions for each data sample that will be retained in the FeatureContribution column.
125
-
/// Note that if there are fewer features with negative contributions than <paramref name="bottom"/>, the rest will be returned as zeros.</param>
123
+
/// <param name="numPositiveContributions">The number of positive contributions to report, sorted from highest magnitude to lowest magnitude.
124
+
/// Note that if there are fewer features with positive contributions than <paramref name="numPositiveContributions"/>, the rest will be returned as zeros.</param>
125
+
/// <param name="numNegativeContributions">The number of negative contributions to report, sorted from highest magnitude to lowest magnitude.
126
+
/// Note that if there are fewer features with negative contributions than <paramref name="numNegativeContributions"/>, the rest will be returned as zeros.</param>
126
127
/// <param name="normalize">Whether the feature contributions should be normalized to the [-1, 1] interval.</param>
@@ -279,8 +280,8 @@ public sealed class FeatureContributionCalculatingEstimator : TrivialEstimator<F
279
280
280
281
publicstaticclassDefaults
281
282
{
282
-
publicconstintTop=10;
283
-
publicconstintBottom=10;
283
+
publicconstintNumPositiveContributions=10;
284
+
publicconstintNumNegativeContributions=10;
284
285
publicconstboolNormalize=true;
285
286
}
286
287
@@ -291,18 +292,18 @@ public static class Defaults
291
292
/// <param name="env">The environment to use.</param>
292
293
/// <param name="modelParameters">Trained model parameters that support Feature Contribution Calculation and which will be used for scoring.</param>
293
294
/// <param name="featureColumn">The name of the feature column that will be used as input.</param>
294
-
/// <param name="top">The number of features with highest positive contributions for each data sample that will be retained in the FeatureContribution column.
295
-
/// Note that if there are fewer features with positive contributions than <paramref name="top"/>, the rest will be returned as zeros.</param>
296
-
/// <param name="bottom">The number of features with least negative contributions for each data sample that will be retained in the FeatureContribution column.
297
-
/// Note that if there are fewer features with negative contributions than <paramref name="bottom"/>, the rest will be returned as zeros.</param>
295
+
/// <param name="numPositiveContributions">The number of positive contributions to report, sorted from highest magnitude to lowest magnitude.
296
+
/// Note that if there are fewer features with positive contributions than <paramref name="numPositiveContributions"/>, the rest will be returned as zeros.</param>
297
+
/// <param name="numNegativeContributions">The number of negative contributions to report, sorted from highest magnitude to lowest magnitude.
298
+
/// Note that if there are fewer features with negative contributions than <paramref name="numNegativeContributions"/>, the rest will be returned as zeros.</param>
298
299
/// <param name="normalize">Whether the feature contributions should be normalized to the [-1, 1] interval.</param>
/// Used to determine the contribution of each feature to the score of an example by <see cref="FeatureContributionCalculatingTransformer"/>.
2843
+
/// For tree-based models, the contribution of a feature is equal to the change in score produced by exploring the opposite sub-tree every time a decision
2844
+
/// node for the given feature is encountered. Consider a simple case with a single decision tree that has a decision node for the binary feature F1.
2845
+
/// Given an example that has feature F1 equal to true, we can calculate the score it would have obtained if we chose the subtree corresponding to
2846
+
/// the feature F1 being equal to false while keeping the other features constant. The contribution of feature F1 for the given example is the difference
2847
+
/// between the original score and the score obtained by taking the opposite decision at the node corresponding to feature F1. This algorithm extends
0 commit comments