@@ -45,17 +45,17 @@ protected TrainerEstimatorReconciler(PipelineColumn[] inputs, string[] outputNam
45
45
/// <summary>
46
46
/// Produce the training estimator.
47
47
/// </summary>
48
- /// <param name="env">The host environment to use to create the estimator</param>
48
+ /// <param name="env">The host environment to use to create the estimator. </param>
49
49
/// <param name="inputNames">The names of the inputs, which corresponds exactly to the input columns
50
- /// fed into the constructor</param>
50
+ /// fed into the constructor. </param>
51
51
/// <returns>An estimator, which should produce the additional columns indicated by the output names
52
- /// in the constructor</returns>
52
+ /// in the constructor. </returns>
53
53
protected abstract IEstimator < ITransformer > ReconcileCore ( IHostEnvironment env , string [ ] inputNames ) ;
54
54
55
55
/// <summary>
56
56
/// Produces the estimator. Note that this is made out of <see cref="ReconcileCore(IHostEnvironment, string[])"/>'s
57
57
/// return value, plus whatever usages of <see cref="CopyColumnsEstimator"/> are necessary to avoid collisions with
58
- /// the output names fed to the constructor. This class provides the implementation, and subclassses should instead
58
+ /// the output names fed to the constructor. This class provides the implementation, and subclasses should instead
59
59
/// override <see cref="ReconcileCore(IHostEnvironment, string[])"/>.
60
60
/// </summary>
61
61
public sealed override IEstimator < ITransformer > Reconcile ( IHostEnvironment env ,
@@ -138,16 +138,16 @@ public sealed override IEstimator<ITransformer> Reconcile(IHostEnvironment env,
138
138
public sealed class Regression : TrainerEstimatorReconciler
139
139
{
140
140
/// <summary>
141
- /// The delegate to parameterize the <see cref="Regression"/> instance.
141
+ /// The delegate to create the <see cref="Regression"/> instance.
142
142
/// </summary>
143
143
/// <param name="env">The environment with which to create the estimator</param>
144
144
/// <param name="label">The label column name</param>
145
145
/// <param name="features">The features column name</param>
146
146
/// <param name="weights">The weights column name, or <c>null</c> if the reconciler was constructed with <c>null</c> weights</param>
147
- /// <returns>Some sort of estimator producing columns with the fixed name <see cref="DefaultColumnNames.Score"/></returns>
148
- public delegate IEstimator < ITransformer > EstimatorMaker ( IHostEnvironment env , string label , string features , string weights ) ;
147
+ /// <returns>A estimator producing columns with the fixed name <see cref="DefaultColumnNames.Score"/>. </returns>
148
+ public delegate IEstimator < ITransformer > EstimatorFactory ( IHostEnvironment env , string label , string features , string weights ) ;
149
149
150
- private readonly EstimatorMaker _estMaker ;
150
+ private readonly EstimatorFactory _estFact ;
151
151
152
152
/// <summary>
153
153
/// The output score column for the regression. This will have this instance as its reconciler.
@@ -161,17 +161,17 @@ public sealed class Regression : TrainerEstimatorReconciler
161
161
/// <summary>
162
162
/// Constructs a new general regression reconciler.
163
163
/// </summary>
164
- /// <param name="estimatorMaker ">The delegate to create the training estimator. It is assumed that this estimator
164
+ /// <param name="estimatorFactory ">The delegate to create the training estimator. It is assumed that this estimator
165
165
/// will produce a single new scalar <see cref="float"/> column named <see cref="DefaultColumnNames.Score"/>.</param>
166
- /// <param name="label">The input label column</param>
167
- /// <param name="features">The input features column</param>
168
- /// <param name="weights">The input weights column, or <c>null</c> if there are no weights</param>
169
- public Regression ( EstimatorMaker estimatorMaker , Scalar < float > label , Vector < float > features , Scalar < float > weights )
166
+ /// <param name="label">The input label column. </param>
167
+ /// <param name="features">The input features column. </param>
168
+ /// <param name="weights">The input weights column, or <c>null</c> if there are no weights. </param>
169
+ public Regression ( EstimatorFactory estimatorFactory , Scalar < float > label , Vector < float > features , Scalar < float > weights )
170
170
: base ( MakeInputs ( Contracts . CheckRef ( label , nameof ( label ) ) , Contracts . CheckRef ( features , nameof ( features ) ) , weights ) ,
171
171
_fixedOutputNames )
172
172
{
173
- Contracts . CheckValue ( estimatorMaker , nameof ( estimatorMaker ) ) ;
174
- _estMaker = estimatorMaker ;
173
+ Contracts . CheckValue ( estimatorFactory , nameof ( estimatorFactory ) ) ;
174
+ _estFact = estimatorFactory ;
175
175
Contracts . Assert ( _inputs . Length == 2 || _inputs . Length == 3 ) ;
176
176
Score = new Impl ( this ) ;
177
177
}
@@ -183,7 +183,7 @@ protected override IEstimator<ITransformer> ReconcileCore(IHostEnvironment env,
183
183
{
184
184
Contracts . AssertValue ( env ) ;
185
185
env . Assert ( Utils . Size ( inputNames ) == _inputs . Length ) ;
186
- return _estMaker ( env , inputNames [ 0 ] , inputNames [ 1 ] , inputNames . Length > 2 ? inputNames [ 2 ] : null ) ;
186
+ return _estFact ( env , inputNames [ 0 ] , inputNames [ 1 ] , inputNames . Length > 2 ? inputNames [ 2 ] : null ) ;
187
187
}
188
188
189
189
private sealed class Impl : Scalar < float >
@@ -193,21 +193,21 @@ public Impl(Regression rec) : base(rec, rec._inputs) { }
193
193
}
194
194
195
195
/// <summary>
196
- /// A reconciler for regression capable of handling the most common cases for binary classifier with calibrated outputs.
196
+ /// A reconciler capable of handling the most common cases for binary classification with calibrated outputs.
197
197
/// </summary>
198
198
public sealed class BinaryClassifier : TrainerEstimatorReconciler
199
199
{
200
200
/// <summary>
201
- /// The delegate to parameterize the <see cref="BinaryClassifier"/> instance.
201
+ /// The delegate to create the <see cref="BinaryClassifier"/> instance.
202
202
/// </summary>
203
- /// <param name="env">The environment with which to create the estimator</param>
204
- /// <param name="label">The label column name</param>
205
- /// <param name="features">The features column name</param>
206
- /// <param name="weights">The weights column name, or <c>null</c> if the reconciler was constructed with <c>null</c> weights</param>
207
- /// <returns></returns>
208
- public delegate IEstimator < ITransformer > EstimatorMaker ( IHostEnvironment env , string label , string features , string weights ) ;
209
-
210
- private readonly EstimatorMaker _estMaker ;
203
+ /// <param name="env">The environment with which to create the estimator. </param>
204
+ /// <param name="label">The label column name. </param>
205
+ /// <param name="features">The features column name. </param>
206
+ /// <param name="weights">The weights column name, or <c>null</c> if the reconciler was constructed with <c>null</c> weights. </param>
207
+ /// <returns>A binary classification trainer estimator. </returns>
208
+ public delegate IEstimator < ITransformer > EstimatorFactory ( IHostEnvironment env , string label , string features , string weights ) ;
209
+
210
+ private readonly EstimatorFactory _estFact ;
211
211
private static readonly string [ ] _fixedOutputNames = new [ ] { DefaultColumnNames . Score , DefaultColumnNames . Probability , DefaultColumnNames . PredictedLabel } ;
212
212
213
213
/// <summary>
@@ -220,17 +220,17 @@ public sealed class BinaryClassifier : TrainerEstimatorReconciler
220
220
/// <summary>
221
221
/// Constructs a new general regression reconciler.
222
222
/// </summary>
223
- /// <param name="estimatorMaker ">The delegate to create the training estimator. It is assumed that this estimator
223
+ /// <param name="estimatorFactory ">The delegate to create the training estimator. It is assumed that this estimator
224
224
/// will produce a single new scalar <see cref="float"/> column named <see cref="DefaultColumnNames.Score"/>.</param>
225
- /// <param name="label">The input label column</param>
226
- /// <param name="features">The input features column</param>
227
- /// <param name="weights">The input weights column, or <c>null</c> if there are no weights</param>
228
- public BinaryClassifier ( EstimatorMaker estimatorMaker , Scalar < bool > label , Vector < float > features , Scalar < float > weights )
225
+ /// <param name="label">The input label column. </param>
226
+ /// <param name="features">The input features column. </param>
227
+ /// <param name="weights">The input weights column, or <c>null</c> if there are no weights. </param>
228
+ public BinaryClassifier ( EstimatorFactory estimatorFactory , Scalar < bool > label , Vector < float > features , Scalar < float > weights )
229
229
: base ( MakeInputs ( Contracts . CheckRef ( label , nameof ( label ) ) , Contracts . CheckRef ( features , nameof ( features ) ) , weights ) ,
230
230
_fixedOutputNames )
231
231
{
232
- Contracts . CheckValue ( estimatorMaker , nameof ( estimatorMaker ) ) ;
233
- _estMaker = estimatorMaker ;
232
+ Contracts . CheckValue ( estimatorFactory , nameof ( estimatorFactory ) ) ;
233
+ _estFact = estimatorFactory ;
234
234
Contracts . Assert ( _inputs . Length == 2 || _inputs . Length == 3 ) ;
235
235
236
236
Output = ( new Impl ( this ) , new Impl ( this ) , new ImplBool ( this ) ) ;
@@ -243,7 +243,7 @@ protected override IEstimator<ITransformer> ReconcileCore(IHostEnvironment env,
243
243
{
244
244
Contracts . AssertValue ( env ) ;
245
245
env . Assert ( Utils . Size ( inputNames ) == _inputs . Length ) ;
246
- return _estMaker ( env , inputNames [ 0 ] , inputNames [ 1 ] , inputNames . Length > 2 ? inputNames [ 2 ] : null ) ;
246
+ return _estFact ( env , inputNames [ 0 ] , inputNames [ 1 ] , inputNames . Length > 2 ? inputNames [ 2 ] : null ) ;
247
247
}
248
248
249
249
private sealed class Impl : Scalar < float >
@@ -258,22 +258,22 @@ public ImplBool(BinaryClassifier rec) : base(rec, rec._inputs) { }
258
258
}
259
259
260
260
/// <summary>
261
- /// A reconciler for regression capable of handling the most common cases for binary classification
262
- /// that does not necessarily have calibrated outputs.
261
+ /// A reconciler capable of handling the most common cases for binary classification that does not
262
+ /// necessarily have with calibrated outputs.
263
263
/// </summary>
264
264
public sealed class BinaryClassifierNoCalibration : TrainerEstimatorReconciler
265
265
{
266
266
/// <summary>
267
- /// The delegate to parameterize the <see cref="BinaryClassifier"/> instance.
267
+ /// The delegate to create the <see cref="BinaryClassifier"/> instance.
268
268
/// </summary>
269
269
/// <param name="env">The environment with which to create the estimator</param>
270
- /// <param name="label">The label column name</param>
271
- /// <param name="features">The features column name</param>
272
- /// <param name="weights">The weights column name, or <c>null</c> if the reconciler was constructed with <c>null</c> weights</param>
273
- /// <returns></returns>
274
- public delegate IEstimator < ITransformer > EstimatorMaker ( IHostEnvironment env , string label , string features , string weights ) ;
270
+ /// <param name="label">The label column name. </param>
271
+ /// <param name="features">The features column name. </param>
272
+ /// <param name="weights">The weights column name, or <c>null</c> if the reconciler was constructed with <c>null</c> weights. </param>
273
+ /// <returns>A binary classification trainer estimator. </returns>
274
+ public delegate IEstimator < ITransformer > EstimatorFactory ( IHostEnvironment env , string label , string features , string weights ) ;
275
275
276
- private readonly EstimatorMaker _estMaker ;
276
+ private readonly EstimatorFactory _estFact ;
277
277
private static readonly string [ ] _fixedOutputNamesProb = new [ ] { DefaultColumnNames . Score , DefaultColumnNames . Probability , DefaultColumnNames . PredictedLabel } ;
278
278
private static readonly string [ ] _fixedOutputNames = new [ ] { DefaultColumnNames . Score , DefaultColumnNames . PredictedLabel } ;
279
279
@@ -282,25 +282,30 @@ public sealed class BinaryClassifierNoCalibration : TrainerEstimatorReconciler
282
282
/// </summary>
283
283
public ( Scalar < float > score , Scalar < bool > predictedLabel ) Output { get ; }
284
284
285
+ /// <summary>
286
+ /// The output columns, which will contain at least the columns produced by <see cref="Output"/> and may contain an
287
+ /// additional <see cref="DefaultColumnNames.Probability"/> column if at runtime we determine the predictor actually
288
+ /// is calibrated.
289
+ /// </summary>
285
290
protected override IEnumerable < PipelineColumn > Outputs { get ; }
286
291
287
292
/// <summary>
288
293
/// Constructs a new general binary classifier reconciler.
289
294
/// </summary>
290
- /// <param name="estimatorMaker ">The delegate to create the training estimator. It is assumed that this estimator
295
+ /// <param name="estimatorFactory ">The delegate to create the training estimator. It is assumed that this estimator
291
296
/// will produce a single new scalar <see cref="float"/> column named <see cref="DefaultColumnNames.Score"/>.</param>
292
- /// <param name="label">The input label column</param>
293
- /// <param name="features">The input features column</param>
294
- /// <param name="weights">The input weights column, or <c>null</c> if there are no weights</param>
297
+ /// <param name="label">The input label column. </param>
298
+ /// <param name="features">The input features column. </param>
299
+ /// <param name="weights">The input weights column, or <c>null</c> if there are no weights. </param>
295
300
/// <param name="hasProbs">While this type is a compile time construct, it may be that at runtime we have determined that we will have probabilities,
296
301
/// and so ought to do the renaming of the <see cref="DefaultColumnNames.Probability"/> column anyway if appropriate. If this is so, then this should
297
302
/// be set to true.</param>
298
- public BinaryClassifierNoCalibration ( EstimatorMaker estimatorMaker , Scalar < bool > label , Vector < float > features , Scalar < float > weights , bool hasProbs )
303
+ public BinaryClassifierNoCalibration ( EstimatorFactory estimatorFactory , Scalar < bool > label , Vector < float > features , Scalar < float > weights , bool hasProbs )
299
304
: base ( MakeInputs ( Contracts . CheckRef ( label , nameof ( label ) ) , Contracts . CheckRef ( features , nameof ( features ) ) , weights ) ,
300
305
hasProbs ? _fixedOutputNamesProb : _fixedOutputNames )
301
306
{
302
- Contracts . CheckValue ( estimatorMaker , nameof ( estimatorMaker ) ) ;
303
- _estMaker = estimatorMaker ;
307
+ Contracts . CheckValue ( estimatorFactory , nameof ( estimatorFactory ) ) ;
308
+ _estFact = estimatorFactory ;
304
309
Contracts . Assert ( _inputs . Length == 2 || _inputs . Length == 3 ) ;
305
310
306
311
Output = ( new Impl ( this ) , new ImplBool ( this ) ) ;
@@ -318,7 +323,7 @@ protected override IEstimator<ITransformer> ReconcileCore(IHostEnvironment env,
318
323
{
319
324
Contracts . AssertValue ( env ) ;
320
325
env . Assert ( Utils . Size ( inputNames ) == _inputs . Length ) ;
321
- return _estMaker ( env , inputNames [ 0 ] , inputNames [ 1 ] , inputNames . Length > 2 ? inputNames [ 2 ] : null ) ;
326
+ return _estFact ( env , inputNames [ 0 ] , inputNames [ 1 ] , inputNames . Length > 2 ? inputNames [ 2 ] : null ) ;
322
327
}
323
328
324
329
private sealed class Impl : Scalar < float >
0 commit comments