Skip to content

Commit 674a2dd

Browse files
authored
XML documentation for GAM binary classifier trainer. (#3425)
* XML documentation for GAM binary classifer trainer. * PR feedback. * PR feedback.
1 parent 174e355 commit 674a2dd

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### Training Algorithm Details
2+
Generalized Additive Models, or GAMs, model the data as a set of linearly
3+
independent features similar to a linear model. For each feature, the GAM
4+
trainer learns a non-linear function, called a "shape function", that computes
5+
the response as a function of the feature's value. (In contrast, a linear model
6+
fits a linear response (e.g. a line) to each feature.) To score an input, the
7+
outputs of all the shape functions are summed and the score is the total value.
8+
9+
This GAM trainer is implemented using shallow gradient boosted trees (e.g. tree
10+
stumps) to learn nonparametric shape functions, and is based on the method
11+
described in Lou, Caruana, and Gehrke. ["Intelligible Models for Classification
12+
and Regression."](http://www.cs.cornell.edu/~yinlou/papers/lou-kdd12.pdf)
13+
KDD'12, Beijing, China. 2012. After training, an intercept is added to represent
14+
the average prediction over the training set, and the shape functions are
15+
normalized to represent the deviation from the average prediction. This results
16+
in models that are easily interpreted simply by inspecting the intercept and the
17+
shape functions. See the sample below for an example of how to train a GAM model
18+
and inspect and interpret the results.

src/Microsoft.ML.FastTree/GamClassification.cs

+24-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,36 @@ namespace Microsoft.ML.Trainers.FastTree
2929
/// <summary>
3030
/// The <see cref="IEstimator{TTransformer}"/> for training a binary classification model with generalized additive models (GAM).
3131
/// </summary>
32-
/// <include file='doc.xml' path='doc/members/member[@name="GAM_remarks"]/*' />
32+
/// <remarks>
33+
/// <format type="text/markdown"><![CDATA[
34+
/// To create this trainer, use [Gam](xref:Microsoft.ML.TreeExtensions.Gam(Microsoft.ML.BinaryClassificationCatalog.BinaryClassificationTrainers,System.String,System.String,System.String,System.Int32,System.Int32,System.Double))
35+
/// or [Gam(Options)](xref:Microsoft.ML.TreeExtensions.Gam(Microsoft.ML.BinaryClassificationCatalog.BinaryClassificationTrainers,Microsoft.ML.Trainers.FastTree.GamBinaryTrainer.Options)).
36+
///
37+
/// [!include[io](~/../docs/samples/docs/api-reference/io-columns-binary-classification.md)]
38+
///
39+
/// ### Trainer Characteristics
40+
/// | | |
41+
/// | -- | -- |
42+
/// | Machine learning task | Binary classification |
43+
/// | Is normalization required? | No |
44+
/// | Is caching required? | No |
45+
/// | Required NuGet in addition to Microsoft.ML | Microsoft.ML.FastTree |
46+
///
47+
/// [!include[algorithm](~/../docs/samples/docs/api-reference/algo-details-gam.md)]
48+
/// ]]>
49+
/// </format>
50+
/// </remarks>
51+
/// <seealso cref="TreeExtensions.Gam(BinaryClassificationCatalog.BinaryClassificationTrainers, string, string, string, int, int, double)"/>
52+
/// <seealso cref="TreeExtensions.Gam(BinaryClassificationCatalog.BinaryClassificationTrainers, GamBinaryTrainer.Options)"/>
53+
/// <seealso cref="Options"/>
3354
public sealed class GamBinaryTrainer :
3455
GamTrainerBase<GamBinaryTrainer.Options,
3556
BinaryPredictionTransformer<CalibratedModelParametersBase<GamBinaryModelParameters, PlattCalibrator>>,
3657
CalibratedModelParametersBase<GamBinaryModelParameters, PlattCalibrator>>
3758
{
3859
/// <summary>
39-
/// Options for the <see cref="GamBinaryTrainer"/>.
60+
/// Options for the <see cref="GamBinaryTrainer"/> as used in
61+
/// [Gam(Options)](xref:Microsoft.ML.TreeExtensions.Gam(Microsoft.ML.BinaryClassificationCatalog.BinaryClassificationTrainers,Microsoft.ML.Trainers.FastTree.GamBinaryTrainer.Options)).
4062
/// </summary>
4163
public sealed class Options : OptionsBase
4264
{

src/Microsoft.ML.FastTree/TreeTrainersCatalog.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ public static FastTreeRankingTrainer FastTree(this RankingCatalog.RankingTrainer
178178
}
179179

180180
/// <summary>
181-
/// Predict a target using generalized additive models (GAM) trained with the <see cref="GamBinaryTrainer"/>.
181+
/// Create <see cref="GamBinaryTrainer"/>, which predicts a target using generalized additive models (GAM).
182182
/// </summary>
183183
/// <param name="catalog">The <see cref="BinaryClassificationCatalog"/>.</param>
184-
/// <param name="labelColumnName">The name of the label column.</param>
185-
/// <param name="featureColumnName">The name of the feature column.</param>
184+
/// <param name="labelColumnName">The name of the label column. The column data must be <see cref="System.Boolean"/>.</param>
185+
/// <param name="featureColumnName">The name of the feature column. The column data must be a known-sized vector of <see cref="System.Single"/>.</param>
186186
/// <param name="exampleWeightColumnName">The name of the example weight column (optional).</param>
187187
/// <param name="numberOfIterations">The number of iterations to use in learning the features.</param>
188188
/// <param name="maximumBinCountPerFeature">The maximum number of bins to use to approximate features.</param>
@@ -208,7 +208,7 @@ public static GamBinaryTrainer Gam(this BinaryClassificationCatalog.BinaryClassi
208208
}
209209

210210
/// <summary>
211-
/// Predict a target using generalized additive models (GAM) trained with the <see cref="GamBinaryTrainer"/>.
211+
/// Create <see cref="GamBinaryTrainer"/> using advanced options, which predicts a target using generalized additive models (GAM).
212212
/// </summary>
213213
/// <param name="catalog">The <see cref="BinaryClassificationCatalog"/>.</param>
214214
/// <param name="options">Trainer options.</param>

0 commit comments

Comments
 (0)