|
26 | 26 | namespace Microsoft.ML.Transforms
|
27 | 27 | {
|
28 | 28 | /// <summary>
|
29 |
| - /// The FeatureContributionCalculationTransformer computes model-specific per-feature contributions to the score of each example. |
30 |
| - /// See the list of currently supported models below. |
| 29 | + /// <see cref="ITransformer"/> resulting from fitting a <see cref="FeatureContributionCalculatingEstimator"/>. |
31 | 30 | /// </summary>
|
32 |
| - /// <remarks> |
33 |
| - /// <para> |
34 |
| - /// Scoring a dataset with a trained model produces a score, or prediction, for each example. To understand and explain these predictions |
35 |
| - /// it can be useful to inspect which features influenced them most significantly. FeatureContributionCalculationTransformer computes a model-specific |
36 |
| - /// list of per-feature contributions to the score for each example. These contributions can be positive (they make the score higher) or negative |
37 |
| - /// (they make the score lower). |
38 |
| - /// </para> |
39 |
| - /// <para> |
40 |
| - /// Feature Contribution Calculation is currently supported for the following models: |
41 |
| - /// Regression: |
42 |
| - /// OrdinaryLeastSquares, StochasticDualCoordinateAscent (SDCA), OnlineGradientDescent, PoissonRegression, |
43 |
| - /// GeneralizedAdditiveModels (GAM), LightGbm, FastTree, FastForest, FastTreeTweedie |
44 |
| - /// Binary Classification: |
45 |
| - /// AveragedPerceptron, LinearSupportVectorMachines, LogisticRegression, StochasticDualCoordinateAscent (SDCA), |
46 |
| - /// StochasticGradientDescent (SGD), SymbolicStochasticGradientDescent, GeneralizedAdditiveModels (GAM), |
47 |
| - /// FastForest, FastTree, LightGbm |
48 |
| - /// Ranking: |
49 |
| - /// FastTree, LightGbm |
50 |
| - /// </para> |
51 |
| - /// <para> |
52 |
| - /// For linear models, the contribution of a given feature is equal to the product of feature value times the corresponding weight. Similarly, |
53 |
| - /// for Generalized Additive Models (GAM), the contribution of a feature is equal to the shape function for the given feature evaluated at |
54 |
| - /// the feature value. |
55 |
| - /// </para> |
56 |
| - /// <para> |
57 |
| - /// For tree-based models, the calculation of feature contribution essentially consists in determining which splits in the tree have the most impact |
58 |
| - /// on the final score and assigning the value of the impact to the features determining the split. More precisely, the contribution of a feature |
59 |
| - /// is equal to the change in score produced by exploring the opposite sub-tree every time a decision node for the given feature is encountered. |
60 |
| - /// Consider a simple case with a single decision tree that has a decision node for the binary feature F1. Given an example that has feature F1 |
61 |
| - /// equal to true, we can calculate the score it would have obtained if we chose the subtree corresponding to the feature F1 being equal to false |
62 |
| - /// while keeping the other features constant. The contribution of feature F1 for the given example is the difference between the original score |
63 |
| - /// and the score obtained by taking the opposite decision at the node corresponding to feature F1. This algorithm extends naturally to models with |
64 |
| - /// many decision trees. |
65 |
| - /// </para> |
66 |
| - /// <para> |
67 |
| - /// See the sample below for an example of how to compute feature importance using the FeatureContributionCalculatingTransformer. |
68 |
| - /// </para> |
69 |
| - /// </remarks> |
70 | 31 | public sealed class FeatureContributionCalculatingTransformer : OneToOneTransformerBase
|
71 | 32 | {
|
72 | 33 | internal sealed class Options : TransformInputBase
|
@@ -266,9 +227,67 @@ private Delegate GetValueGetter<TSrc>(DataViewRow input, int colSrc)
|
266 | 227 | }
|
267 | 228 |
|
268 | 229 | /// <summary>
|
269 |
| - /// Estimator producing a FeatureContributionCalculatingTransformer which scores the model on an input dataset and |
270 |
| - /// computes model-specific contribution scores for each feature. |
| 230 | + /// Computes model-specific per-feature contributions to the score of each input vector. |
271 | 231 | /// </summary>
|
| 232 | + /// <remarks> |
| 233 | + /// <format type="text/markdown"><![CDATA[ |
| 234 | + /// |
| 235 | + /// ### Estimator Characteristics |
| 236 | + /// | | | |
| 237 | + /// | -- | -- | |
| 238 | + /// | Does this estimator need to look at the data to train its parameters? | No | |
| 239 | + /// | Input column data type | Known-sized vector of <xref:System.Single> | |
| 240 | + /// | Output column data type | Known-sized vector of <xref:System.Single> | |
| 241 | + /// |
| 242 | + /// Scoring a dataset with a trained model produces a score, or prediction, for each example. To understand and explain these predictions |
| 243 | + /// it can be useful to inspect which features influenced them most significantly. This transformer computes a model-specific |
| 244 | + /// list of per-feature contributions to the score for each example. These contributions can be positive (they make the score higher) or negative |
| 245 | + /// (they make the score lower). |
| 246 | + /// |
| 247 | + /// Feature Contribution Calculation is currently supported for the following models: |
| 248 | + /// - Regression: |
| 249 | + /// - OlsTrainer |
| 250 | + /// - SdcaRegressionTrainer |
| 251 | + /// - OnlineGradientDescentTrainer |
| 252 | + /// - LbfgsPoissonRegressionTrainer |
| 253 | + /// - GamRegressionTrainer |
| 254 | + /// - LightGbmRegressionTrainer |
| 255 | + /// - FastTreeRegressionTrainer |
| 256 | + /// - FastForestRegressionTrainer |
| 257 | + /// - FastTreeTweedieTrainer |
| 258 | + /// - Binary Classification: |
| 259 | + /// - AveragedPerceptronTrainer |
| 260 | + /// - LinearSvmTrainer |
| 261 | + /// - LbfgsLogisticRegressionBinaryTrainer |
| 262 | + /// - SdcaNonCalibratedBinaryTrainer |
| 263 | + /// - SdcaLogisticRegressionBinaryTrainer |
| 264 | + /// - SgdCalibratedTrainer |
| 265 | + /// - SgdNonCalibratedTrainer |
| 266 | + /// - SymbolicSgdLogisticRegressionBinaryTrainer |
| 267 | + /// - GamBinaryTrainer |
| 268 | + /// - FastForestBinaryTrainer |
| 269 | + /// - FastTreeBinaryTrainer |
| 270 | + /// - LightGbmBinaryTrainer |
| 271 | + /// - Ranking: |
| 272 | + /// - FastTreeRankingTrainer |
| 273 | + /// - LightGbmRankingTrainer |
| 274 | + /// |
| 275 | + /// For linear models, the contribution of a given feature is equal to the product of feature value times the corresponding weight. Similarly, |
| 276 | + /// for Generalized Additive Models (GAM), the contribution of a feature is equal to the shape function for the given feature evaluated at |
| 277 | + /// the feature value. |
| 278 | + /// |
| 279 | + /// For tree-based models, the calculation of feature contribution essentially consists in determining which splits in the tree have the most impact |
| 280 | + /// on the final score and assigning the value of the impact to the features determining the split. More precisely, the contribution of a feature |
| 281 | + /// is equal to the change in score produced by exploring the opposite sub-tree every time a decision node for the given feature is encountered. |
| 282 | + /// Consider a simple case with a single decision tree that has a decision node for the binary feature F1. Given an example that has feature F1 |
| 283 | + /// equal to true, we can calculate the score it would have obtained if we chose the subtree corresponding to the feature F1 being equal to false |
| 284 | + /// while keeping the other features constant. The contribution of feature F1 for the given example is the difference between the original score |
| 285 | + /// and the score obtained by taking the opposite decision at the node corresponding to feature F1. This algorithm extends naturally to models with |
| 286 | + /// many decision trees. |
| 287 | + /// ]]></format> |
| 288 | + /// </remarks> |
| 289 | + /// <seealso cref="ExplainabilityCatalog.CalculateFeatureContribution(TransformsCatalog, ISingleFeaturePredictionTransformer{ICalculateFeatureContribution}, int, int, bool)"/> |
| 290 | + /// <seealso cref="ExplainabilityCatalog.CalculateFeatureContribution{TModelParameters, TCalibrator}(TransformsCatalog, ISingleFeaturePredictionTransformer{Calibrators.CalibratedModelParametersBase{TModelParameters, TCalibrator}}, int, int, bool)"/> |
272 | 291 | public sealed class FeatureContributionCalculatingEstimator : TrivialEstimator<FeatureContributionCalculatingTransformer>
|
273 | 292 | {
|
274 | 293 | private readonly string _featureColumn;
|
|
0 commit comments