Skip to content

Commit 437e367

Browse files
committed
Addressing the PR comments.
1 parent 1c44ea2 commit 437e367

File tree

10 files changed

+90
-52
lines changed

10 files changed

+90
-52
lines changed

docs/code/MlNetCookBook.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ var dynamicPipeline =
12971297
// Concatenate all the features together into one column 'Features'.
12981298
mlContext.Transforms.Concatenate("Features", "SepalLength", "SepalWidth", "PetalLength", "PetalWidth")
12991299
// Note that the label is text, so it needs to be converted to key.
1300-
.Append(mlContext.Transforms.Categorical.MapValueToKey("Label"), TransformerScope.TrainTest)
1300+
.Append(mlContext.Transforms.Conversions.MapValueToKey("Label"), TransformerScope.TrainTest)
13011301
// Use the multi-class SDCA model to predict the label using features.
13021302
.Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent());
13031303

src/Microsoft.ML.Data/Transforms/ConversionsExtensionsCatalog.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static KeyToVectorMappingEstimator MapKeyToVector(this TransformsCatalog.
9393
=> new KeyToVectorMappingEstimator(CatalogUtils.GetEnvironment(catalog), inputColumn, outputColumn, bag);
9494

9595
/// <summary>
96-
/// Initializes a new instance of <see cref="ValueToKeyMappingEstimator"/>.
96+
/// Converts value types into <see cref="KeyType"/>.
9797
/// </summary>
9898
/// <param name="catalog">The categorical transform's catalog.</param>
9999
/// <param name="inputColumn">Name of the column to be transformed.</param>
@@ -109,7 +109,7 @@ public static ValueToKeyMappingEstimator MapValueToKey(this TransformsCatalog.Co
109109
=> new ValueToKeyMappingEstimator(CatalogUtils.GetEnvironment(catalog), inputColumn, outputColumn, maxNumTerms, sort);
110110

111111
/// <summary>
112-
/// Initializes a new instance of <see cref="ValueToKeyMappingEstimator"/> loading the terms to use from <paramref name="file"/>.
112+
/// Converts value types into <see cref="KeyType"/> loading the keys to use from <paramref name="file"/>.
113113
/// </summary>
114114
/// <param name="catalog">The categorical transform's catalog.</param>
115115
/// <param name="columns">The data columns to map to keys.</param>

src/Microsoft.ML.PCA/PcaTransform.cs

-2
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,6 @@ internal static class Defaults
674674
private readonly IHost _host;
675675
private readonly PcaTransform.ColumnInfo[] _columns;
676676

677-
/// <summary>Initializes a new instance of <see cref="PrincipalComponentAnalysisEstimator"/>.</summary>
678677
/// <include file='doc.xml' path='doc/members/member[@name="PCA"]/*'/>
679678
/// <param name="env">The environment to use.</param>
680679
/// <param name="inputColumn">Input column to project to Principal Component.</param>
@@ -692,7 +691,6 @@ public PrincipalComponentAnalysisEstimator(IHostEnvironment env, string inputCol
692691
{
693692
}
694693

695-
/// <summary>Initializes a new instance of <see cref="PrincipalComponentAnalysisEstimator"/>.</summary>
696694
/// <include file='doc.xml' path='doc/members/member[@name="PCA"]/*'/>
697695
/// <param name="env">The environment to use.</param>
698696
/// <param name="columns">The dataset columns to use, and their specific settings.</param>

src/Microsoft.ML.Recommender/MatrixFactorizationTrainer.cs

+23-22
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@
2525
namespace Microsoft.ML.Trainers
2626
{
2727
/// <summary>
28-
/// Train a matrix factorization model. It factotizes the training matrix into the product of two low-rank matrices.
29-
/// <p>The basic idea of matrix factorization is finding two low-rank factor marcies to apporimate the training matrix.
28+
/// Train a matrix factorization model. It factorizes the training matrix into the product of two low-rank matrices.
29+
/// </summary>
30+
/// <remarks>
31+
/// <para>The basic idea of matrix factorization is finding two low-rank factor marcies to apporimate the training matrix.
3032
/// In this module, the expected training data is a list of tuples. Every tuple consists of a column index, a row index,
31-
/// and the value at the location specified by the two indexes. For an example data structure of a tuple, one can use
33+
/// and the value at the location specified by the two indexes. For an example data structure of a tuple, one can use:
34+
/// <para>
3235
/// <code language="csharp">
3336
/// // The following variables defines the shape of a m-by-n matrix. The variable firstRowIndex indicates the integer that
3437
/// // would be mapped to the first row index. If user data uses 0-based indices for rows, firstRowIndex can be set to 0.
@@ -53,39 +56,37 @@ namespace Microsoft.ML.Trainers
5356
/// public float Value;
5457
/// }
5558
/// </code>
56-
/// Notice that it's not necessary to specify all entries in the training matrix, so matrix factorization can be used to fill <i>missing values</i>.
57-
/// This behavior is very helpful when building recommender systems.</p>
58-
/// <p>To provide a better understanding on practical uses of matrix factorization, let's consider music recommendation as an example.
59+
/// <para> Notice that it's not necessary to specify all entries in the training matrix, so matrix factorization can be used to fill <i>missing values</i>.
60+
/// This behavior is very helpful when building recommender systems.</para>
61+
/// <para>To provide a better understanding on practical uses of matrix factorization, let's consider music recommendation as an example.
5962
/// Assume that user IDs and music IDs are used as row and column indexes, respectively, and matrix's values are ratings provided by those users. That is,
6063
/// rating <i>r</i> at row <i>r</i> and column <i>v</i> means that user <i>u</i> give <i>r</i> to item <i>v</i>.
6164
/// An imcomplete matrix is very common because not all users may provide their feedbacks to all products (for example, no one can rate ten million songs).
6265
/// Assume that<i>R</i> is a m-by-n rating matrix and the rank of the two factor matrices are<i>P</i> (m-by-k matrix) and <i>Q</i> (n-by-k matrix), where k is the approximation rank.
6366
/// The predicted rating at the u-th row and the v-th column in <i>R</i> would be the inner product of the u-th row of P and the v-th row of Q; that is,
6467
/// <i>R</i> is approximated by the product of <i>P</i>'s transpose and <i>Q</i>. This trainer implements
6568
/// <a href='https://www.csie.ntu.edu.tw/~cjlin/papers/libmf/mf_adaptive_pakdd.pdf'>a stochastic gradient method</a> for finding <i>P</i>
66-
/// and <i>Q</i> via minimizing the distance between<i> R</i> and the product of <i>P</i>'s transpose and Q.</p>.
67-
/// <p>For users interested in the mathematical details, please see the references below.
68-
/// <list type = 'bullet'>
69-
/// <item>
70-
/// <description><a href='https://www.csie.ntu.edu.tw/~cjlin/papers/libmf/libmf_journal.pdf' > A Fast Parallel Stochastic Gradient Method for Matrix Factorization in Shared Memory Systems</a></description>
71-
/// </item>
72-
/// <item>
73-
/// <description><a href='https://www.csie.ntu.edu.tw/~cjlin/papers/libmf/mf_adaptive_pakdd.pdf' > A Learning-rate Schedule for Stochastic Gradient Methods to Matrix Factorization</a></description>
74-
/// </item>
75-
/// <item>
76-
/// <description><a href='https://www.csie.ntu.edu.tw/~cjlin/papers/libmf/libmf_open_source.pdf' > LIBMF: A Library for Parallel Matrix Factorization in Shared-memory Systems</a></description>
77-
/// </item>
78-
/// </list>
79-
/// </p>
80-
/// <p>Example code can be found by searching for <i>MatrixFactorization</i> in <a href='https://github.com/dotnet/machinelearning'>ML.NET.</a></p>
69+
/// and <i>Q</i> via minimizing the distance between<i> R</i> and the product of <i>P</i>'s transpose and Q.</para>.
70+
/// <para>For users interested in the mathematical details, please see the references below.</para>
71+
/// <list type = 'bullet'>
72+
/// <item>
73+
/// <description><a href='https://www.csie.ntu.edu.tw/~cjlin/papers/libmf/libmf_journal.pdf' > A Fast Parallel Stochastic Gradient Method for Matrix Factorization in Shared Memory Systems</a></description>
74+
/// </item>
75+
/// <item>
76+
/// <description><a href='https://www.csie.ntu.edu.tw/~cjlin/papers/libmf/mf_adaptive_pakdd.pdf' > A Learning-rate Schedule for Stochastic Gradient Methods to Matrix Factorization</a></description>
77+
/// </item>
78+
/// <item>
79+
/// <description><a href='https://www.csie.ntu.edu.tw/~cjlin/papers/libmf/libmf_open_source.pdf' > LIBMF: A Library for Parallel Matrix Factorization in Shared-memory Systems</a></description>
80+
/// </item>
81+
/// </list>
82+
/// </remarks>
8183
/// <example>
8284
/// <format type="text/markdown">
8385
/// <![CDATA[
8486
/// [!code-csharp[MF](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/MatrixFactorization.cs)]
8587
/// ]]>
8688
/// </format>
8789
/// </example>
88-
/// </summary>
8990
public sealed class MatrixFactorizationTrainer : TrainerBase<MatrixFactorizationPredictor>,
9091
IEstimator<MatrixFactorizationPredictionTransformer>
9192
{

src/Microsoft.ML.Recommender/RecommenderCatalog.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ internal RecommendationTrainers(RecommendationContext ctx)
4545
}
4646

4747
/// <summary>
48-
/// Initializing a new instance of <see cref="MatrixFactorizationTrainer"/>.
48+
/// Train a matrix factorization model. It factorizes the training matrix into the product of two low-rank matrices.
4949
/// </summary>
50+
/// <remarks>
51+
/// <para>The basic idea of matrix factorization is finding two low-rank factor marcies to apporimate the training matrix.</para>
52+
/// <para>In this module, the expected training data is a list of tuples. Every tuple consists of a column index, a row index,
53+
/// and the value at the location specified by the two indexes.
54+
/// </para>
55+
/// </remarks>
5056
/// <param name="matrixColumnIndexColumnName">The name of the column hosting the matrix's column IDs.</param>
5157
/// <param name="matrixRowIndexColumnName">The name of the column hosting the matrix's row IDs.</param>
5258
/// <param name="labelColumn">The name of the label column.</param>
@@ -62,7 +68,7 @@ public MatrixFactorizationTrainer MatrixFactorization(
6268
}
6369

6470
/// <summary>
65-
/// Evaluates scored recommendation data.
71+
/// Evaluates the scored recommendation data.
6672
/// </summary>
6773
/// <param name="data">The scored data.</param>
6874
/// <param name="label">The name of the label column in <paramref name="data"/>.</param>

src/Microsoft.ML.StandardLearners/StandardLearnersCatalog.cs

+30-4
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ public static MulticlassLogisticRegression LogisticRegression(this MulticlassCla
314314
}
315315

316316
/// <summary>
317-
/// Initializes a new instance of <see cref="MultiClassNaiveBayesTrainer"/>
317+
/// Predicts a target using a linear multiclass classification model trained with the <see cref="MultiClassNaiveBayesTrainer"/>.
318+
/// The <see cref="MultiClassNaiveBayesTrainer"/> trains a multiclass Naive Bayes predictor that supports binary feature values.
318319
/// </summary>
319320
/// <param name="ctx">The <see cref="MulticlassClassificationContext.MulticlassClassificationTrainers"/>.</param>
320321
/// <param name="labelColumn">The name of the label column.</param>
@@ -328,8 +329,15 @@ public static MultiClassNaiveBayesTrainer NaiveBayes(this MulticlassClassificati
328329
}
329330

330331
/// <summary>
331-
/// Initializes a new instance of <see cref="Ova"/>.
332+
/// Predicts a target using a linear multiclass classification model trained with the <see cref="Ova"/>.
332333
/// </summary>
334+
/// <remarks>
335+
/// <para>
336+
/// In <see cref="Ova"/> In this strategy, a binary classification algorithm is used to train one classifier for each class,
337+
/// which distinguishes that class from all other classes. Prediction is then performed by running these binary classifiers,
338+
/// and choosing the prediction with the highest confidence score.
339+
/// </para>
340+
/// </remarks>
333341
/// <param name="ctx">The <see cref="MulticlassClassificationContext.MulticlassClassificationTrainers"/>.</param>
334342
/// <param name="binaryEstimator">An instance of a binary <see cref="ITrainerEstimator{TTransformer, TPredictor}"/> used as the base trainer.</param>
335343
/// <param name="calibrator">The calibrator. If a calibrator is not explicitely provided, it will default to <see cref="PlattCalibratorTrainer"/></param>
@@ -350,8 +358,15 @@ public static Ova OneVersusAll(this MulticlassClassificationContext.MulticlassCl
350358
}
351359

352360
/// <summary>
353-
/// Initializes a new instance of the <see cref="Pkpd"/>
361+
/// Predicts a target using a linear multiclass classification model trained with the <see cref="Pkpd"/>.
354362
/// </summary>
363+
/// <remarks>
364+
/// <para>
365+
/// In the Pairwise coupling (PKPD) strategy, a binary classification algorithm is used to train one classifier for each pair of classes.
366+
/// Prediction is then performed by running these binary classifiers, and computing a score for each class by counting how many of the binary
367+
/// classifiers predicted it. The prediction is the class with the highest score.
368+
/// </para>
369+
/// </remarks>
355370
/// <param name="ctx">The <see cref="MulticlassClassificationContext.MulticlassClassificationTrainers"/>.</param>
356371
/// <param name="binaryEstimator">An instance of a binary <see cref="ITrainerEstimator{TTransformer, TPredictor}"/> used as the base trainer.</param>
357372
/// <param name="calibrator">The calibrator. If a calibrator is not explicitely provided, it will default to <see cref="PlattCalibratorTrainer"/></param>
@@ -370,8 +385,19 @@ public static Pkpd PairwiseCoupling(this MulticlassClassificationContext.Multicl
370385
}
371386

372387
/// <summary>
373-
/// Initializes a new instance of <see cref="LinearSvm"/>.
388+
/// Predict a target using a linear binary classification model trained with the <see cref="LinearSvm"/> trainer.
374389
/// </summary>
390+
/// <remarks>
391+
/// <para>
392+
/// The idea behind support vector machines, is to map instances into a high dimensional space
393+
/// in which the two classes are linearly separable, i.e., there exists a hyperplane such that all the positive examples are on one side of it,
394+
/// and all the negative examples are on the other.
395+
/// </para>
396+
/// <para>
397+
/// After this mapping, quadratic programming is used to find the separating hyperplane that maximizes the
398+
/// margin, i.e., the minimal distance between it and the instances.
399+
/// </para>
400+
/// </remarks>
375401
/// <param name="ctx">The <see cref="BinaryClassificationContext"/>.</param>
376402
/// <param name="labelColumn">The name of the label column. </param>
377403
/// <param name="featureColumn">The name of the feature column.</param>

src/Microsoft.ML.TensorFlow/TensorflowCatalog.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static TensorFlowEstimator ScoreTensorFlowModel(this TransformsCatalog ca
2222
string modelLocation,
2323
string[] inputs,
2424
string[] outputs)
25-
=> new TensorFlowEstimator(CatalogUtils.GetEnvironment(catalog), modelLocation, inputs, outputs);
25+
=> new TensorFlowEstimator(CatalogUtils.GetEnvironment(catalog), modelLocation, inputs, outputs);
2626

2727
/// <summary>
2828
/// Scores a dataset using a pre-traiend TensorFlow model specified via <paramref name="tensorFlowModel"/>.
@@ -35,7 +35,7 @@ public static TensorFlowEstimator ScoreTensorFlowModel(this TransformsCatalog ca
3535
TensorFlowModelInfo tensorFlowModel,
3636
string[] inputs,
3737
string[] outputs)
38-
=> new TensorFlowEstimator(CatalogUtils.GetEnvironment(catalog), tensorFlowModel, inputs, outputs);
38+
=> new TensorFlowEstimator(CatalogUtils.GetEnvironment(catalog), tensorFlowModel, inputs, outputs);
3939

4040
/// <summary>
4141
/// Score or Retrain a tensorflow model (based on setting of the <see cref="TensorFlowTransform.Arguments.ReTrain"/>) setting.
@@ -52,7 +52,7 @@ public static TensorFlowEstimator TensorFlow(this TransformsCatalog catalog,
5252
/// </summary>
5353
/// <param name="catalog">The transform's catalog.</param>
5454
/// <param name="args">The <see cref="TensorFlowTransform.Arguments"/> specifying the inputs and the settings of the <see cref="TensorFlowEstimator"/>.</param>
55-
/// <param name="tensorFlowModel"></param>
55+
/// <param name="tensorFlowModel">The pre-trained TensorFlow model.</param>
5656
public static TensorFlowEstimator TensorFlow(this TransformsCatalog catalog,
5757
TensorFlowTransform.Arguments args,
5858
TensorFlowModelInfo tensorFlowModel)

src/Microsoft.ML.Transforms/ConversionsCatalog.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@ public static class ConversionsCatalog
1919
/// </summary>
2020
/// <param name="catalog">The categorical transform's catalog.</param>
2121
/// <param name="columns">The input column.</param>
22-
/// <returns></returns>
2322
public static KeyToBinaryVectorMappingEstimator MapKeyToBinaryVector(this TransformsCatalog.ConversionTransforms catalog,
2423
params KeyToBinaryVectorMappingTransformer.ColumnInfo[] columns)
25-
=> new KeyToBinaryVectorMappingEstimator(CatalogUtils.GetEnvironment(catalog), columns);
24+
=> new KeyToBinaryVectorMappingEstimator(CatalogUtils.GetEnvironment(catalog), columns);
2625

2726
/// <summary>
2827
/// Convert the key types back to binary verctor.
2928
/// </summary>
3029
/// <param name="catalog">The categorical transform's catalog.</param>
3130
/// <param name="inputColumn">The name of the input column of the transformation.</param>
3231
/// <param name="outputColumn">The name of the column produced by the transformation.</param>
33-
/// <returns></returns>
3432
public static KeyToBinaryVectorMappingEstimator MapKeyToBinaryVector(this TransformsCatalog.ConversionTransforms catalog,
3533
string inputColumn,
3634
string outputColumn = null)

0 commit comments

Comments
 (0)