Skip to content

Commit eb60021

Browse files
authored
Reorder MatrixFactorizationTrainer parameters (#2561)
* Reorder MatrixFactorizationTrainer parameters * nit * PR feedback
1 parent fb6ce54 commit eb60021

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Recommendation/MatrixFactorization.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public static void Example()
2626
// Create a matrix factorization trainer which may consume "Value" as the training label, "MatrixColumnIndex" as the
2727
// matrix's column index, and "MatrixRowIndex" as the matrix's row index. Here nameof(...) is used to extract field
2828
// names' in MatrixElement class.
29-
var pipeline = mlContext.Recommendation().Trainers.MatrixFactorization(nameof(MatrixElement.MatrixColumnIndex),
30-
nameof(MatrixElement.MatrixRowIndex), nameof(MatrixElement.Value), 10, 0.2, 10);
29+
var pipeline = mlContext.Recommendation().Trainers.MatrixFactorization(nameof(MatrixElement.Value), nameof(MatrixElement.MatrixColumnIndex),
30+
nameof(MatrixElement.MatrixRowIndex), 10, 0.2, 10);
3131

3232
// Train a matrix factorization model.
3333
var model = pipeline.Fit(dataView);

src/Microsoft.ML.Recommender/MatrixFactorizationTrainer.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,17 @@ internal MatrixFactorizationTrainer(IHostEnvironment env, Options options)
350350
/// Initializes a new instance of <see cref="MatrixFactorizationTrainer"/>.
351351
/// </summary>
352352
/// <param name="env">The private instance of <see cref="IHostEnvironment"/>.</param>
353+
/// <param name="labelColumnName">The name of the label column.</param>
353354
/// <param name="matrixColumnIndexColumnName">The name of the column hosting the matrix's column IDs.</param>
354355
/// <param name="matrixRowIndexColumnName">The name of the column hosting the matrix's row IDs.</param>
355-
/// <param name="labelColumn">The name of the label column.</param>
356356
/// <param name="approximationRank">Rank of approximation matrixes.</param>
357357
/// <param name="learningRate">Initial learning rate. It specifies the speed of the training algorithm.</param>
358358
/// <param name="numIterations">Number of training iterations.</param>
359359
[BestFriend]
360360
internal MatrixFactorizationTrainer(IHostEnvironment env,
361+
string labelColumnName,
361362
string matrixColumnIndexColumnName,
362363
string matrixRowIndexColumnName,
363-
string labelColumn = DefaultColumnNames.Label,
364364
int approximationRank = Defaults.ApproximationRank,
365365
double learningRate = Defaults.LearningRate,
366366
int numIterations = Defaults.NumIterations)
@@ -383,7 +383,7 @@ internal MatrixFactorizationTrainer(IHostEnvironment env,
383383

384384
_info = new TrainerInfo(normalization: false, caching: false);
385385

386-
LabelName = labelColumn;
386+
LabelName = labelColumnName;
387387
MatrixColumnIndexName = matrixColumnIndexColumnName;
388388
MatrixRowIndexName = matrixRowIndexColumnName;
389389
}

src/Microsoft.ML.Recommender/RecommenderCatalog.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ internal RecommendationTrainers(RecommendationCatalog catalog)
5050
/// and the value at the location specified by the two indexes.
5151
/// </para>
5252
/// </remarks>
53+
/// <param name="labelColumn">The name of the label column.</param>
5354
/// <param name="matrixColumnIndexColumnName">The name of the column hosting the matrix's column IDs.</param>
5455
/// <param name="matrixRowIndexColumnName">The name of the column hosting the matrix's row IDs.</param>
55-
/// <param name="labelColumn">The name of the label column.</param>
5656
/// <param name="approximationRank">Rank of approximation matrixes.</param>
5757
/// <param name="learningRate">Initial learning rate. It specifies the speed of the training algorithm.</param>
5858
/// <param name="numberOfIterations">Number of training iterations.</param>
@@ -63,13 +63,13 @@ internal RecommendationTrainers(RecommendationCatalog catalog)
6363
/// ]]></format>
6464
/// </example>
6565
public MatrixFactorizationTrainer MatrixFactorization(
66+
string labelColumn,
6667
string matrixColumnIndexColumnName,
6768
string matrixRowIndexColumnName,
68-
string labelColumn = DefaultColumnNames.Label,
6969
int approximationRank = MatrixFactorizationTrainer.Defaults.ApproximationRank,
7070
double learningRate = MatrixFactorizationTrainer.Defaults.LearningRate,
7171
int numberOfIterations = MatrixFactorizationTrainer.Defaults.NumIterations)
72-
=> new MatrixFactorizationTrainer(Owner.Environment, matrixColumnIndexColumnName, matrixRowIndexColumnName, labelColumn,
72+
=> new MatrixFactorizationTrainer(Owner.Environment, labelColumn, matrixColumnIndexColumnName, matrixRowIndexColumnName,
7373
approximationRank, learningRate, numberOfIterations);
7474

7575
/// <summary>

0 commit comments

Comments
 (0)