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
Fix zero based key input from C# classes for matrix factorization (#1507)
This PR makes 0-based key types loaded properly by modifying the getter for C# classes. The previous framework doesn't map raw key value to the actual ordinal number; for example, 0/1/2 in 0-based key should be mapped to 1/2/3 in ML.NET's type system while the previous system maps 0/1/2 to just 0/1/2 if they are read from C# classes. Note that out-of-range values should be mapped to 0. In addition, matrix factorization module is improved for a better code quality.
[Argument(ArgumentType.AtMostOnce,HelpText="Training iterations; that is, the times that the training algorithm iterates through the whole training data once.",ShortName="iter")]
[Argument(ArgumentType.AtMostOnce,HelpText="Initial learning rate. It specifies the speed of the training algorithm. "+
112
+
"Small value may increase the number of iterations needed to achieve a reasonable result. Large value may lead to numerical difficulty such as a infinity value.")]
[Argument(ArgumentType.AtMostOnce,HelpText="Number of threads",ShortName="t")]
117
+
[Argument(ArgumentType.AtMostOnce,HelpText="Number of threads can be used in the training procedure.",ShortName="t")]
113
118
publicint?NumThreads;
114
119
115
-
[Argument(ArgumentType.AtMostOnce,HelpText="Suppress writing additional information to output")]
120
+
[Argument(ArgumentType.AtMostOnce,HelpText="Suppress writing additional information to output.")]
116
121
publicboolQuiet;
117
122
118
-
[Argument(ArgumentType.AtMostOnce,HelpText="Force the matrix factorization P and Q to be non-negative",ShortName="nn")]
123
+
[Argument(ArgumentType.AtMostOnce,HelpText="Force the factor matrices to be non-negative.",ShortName="nn")]
119
124
publicboolNonNegative;
120
125
};
121
126
122
127
internalconststringSummary="From pairs of row/column indices and a value of a matrix, this trains a predictor capable of filling in unknown entries of the matrix, "
123
-
+"utilizing a low-rank matrix factorization. This technique is often used in recommender system, where the row and column indices indicate users and items, "
124
-
+"and the value of the matrix is some rating. ";
128
+
+"using a low-rank matrix factorization. This technique is often used in recommender system, where the row and column indices indicate users and items, "
129
+
+"and the values of the matrix are ratings. ";
125
130
126
-
privatereadonlyDouble_lambda;
131
+
// LIBMF's parameter
132
+
privatereadonlydouble_lambda;
127
133
privatereadonlyint_k;
128
134
privatereadonlyint_iter;
129
-
privatereadonlyDouble_eta;
135
+
privatereadonlydouble_eta;
130
136
privatereadonlyint_threads;
131
137
privatereadonlybool_quiet;
132
138
privatereadonlybool_doNmf;
@@ -135,16 +141,28 @@ public sealed class Arguments
/// The row, column, and label columns that the trainer expects. This module uses tuples of (row index, column index, label value) to specify a matrix.
144
+
/// The row index, column index, and label columns needed to specify the training matrix. This trainer uses tuples of (row index, column index, label value) to specify a matrix.
139
145
/// For example, a 2-by-2 matrix
140
146
/// [9, 4]
141
147
/// [8, 7]
142
148
/// can be encoded as tuples (0, 0, 9), (0, 1, 4), (1, 0, 8), and (1, 1, 7). It means that the row/column/label column contains [0, 0, 1, 1]/
143
149
/// [0, 1, 0, 1]/[9, 4, 8, 7].
144
150
/// </summary>
145
-
publicreadonlySchemaShape.ColumnMatrixColumnIndexColumn;// column indices of the training matrix
146
-
publicreadonlySchemaShape.ColumnMatrixRowIndexColumn;// row indices of the training matrix
147
-
publicreadonlySchemaShape.ColumnLabelColumn;
151
+
152
+
/// <summary>
153
+
/// The name of variable (i.e., Column in a <see cref="IDataView"/> type system) used be as matrix's column index.
154
+
/// </summary>
155
+
publicreadonlystringMatrixColumnIndexName;
156
+
157
+
/// <summary>
158
+
/// The name of variable (i.e., column in a <see cref="IDataView"/> type system) used as matrix's row index.
159
+
/// </summary>
160
+
publicreadonlystringMatrixRowIndexName;
161
+
162
+
/// <summary>
163
+
/// The name variable (i.e., column in a <see cref="IDataView"/> type system) used as matrix's element value.
164
+
/// </summary>
165
+
publicreadonlystringLabelName;
148
166
149
167
/// <summary>
150
168
/// The <see cref="TrainerInfo"/> contains general parameters for this trainer.
@@ -155,7 +173,7 @@ public sealed class Arguments
155
173
/// Extra information the trainer can use. For example, its validation set (if not null) can be use to evaluate the
156
174
/// training progress made at each training iteration.
157
175
/// </summary>
158
-
publicreadonlyTrainerEstimatorContextContext;
176
+
privatereadonlyTrainerEstimatorContext_context;
159
177
160
178
/// <summary>
161
179
/// Legacy constructor initializing a new instance of <see cref="MatrixFactorizationTrainer"/> through the legacy
@@ -209,11 +227,11 @@ public MatrixFactorizationTrainer(IHostEnvironment env, string labelColumn, stri
0 commit comments