Skip to content

Commit 1f520a2

Browse files
committed
clean up.
1 parent 6371e06 commit 1f520a2

File tree

5 files changed

+27
-21
lines changed

5 files changed

+27
-21
lines changed

ZBaselines/Common/EntryPoints/core_manifest.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@
13291329
"Label"
13301330
],
13311331
"Required": false,
1332-
"SortOrder": 6.0,
1332+
"SortOrder": 5.0,
13331333
"IsNullable": false,
13341334
"Default": "Label"
13351335
},
@@ -1349,7 +1349,7 @@
13491349
},
13501350
"Desc": "Specifies the trainer kind, which determines the evaluator to be used.",
13511351
"Required": true,
1352-
"SortOrder": 7.0,
1352+
"SortOrder": 6.0,
13531353
"IsNullable": false,
13541354
"Default": "SignatureBinaryClassifierTrainer"
13551355
}
@@ -1478,7 +1478,7 @@
14781478
"strat"
14791479
],
14801480
"Required": false,
1481-
"SortOrder": 7.0,
1481+
"SortOrder": 6.0,
14821482
"IsNullable": false,
14831483
"Default": null
14841484
},
@@ -1490,7 +1490,7 @@
14901490
"k"
14911491
],
14921492
"Required": false,
1493-
"SortOrder": 8.0,
1493+
"SortOrder": 7.0,
14941494
"IsNullable": false,
14951495
"Default": 2
14961496
},
@@ -1510,7 +1510,7 @@
15101510
},
15111511
"Desc": "Specifies the trainer kind, which determines the evaluator to be used.",
15121512
"Required": true,
1513-
"SortOrder": 9.0,
1513+
"SortOrder": 8.0,
15141514
"IsNullable": false,
15151515
"Default": "SignatureBinaryClassifierTrainer"
15161516
}

src/Microsoft.ML/Data/TextLoader.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public TextLoaderRange()
2121
/// <summary>
2222
/// Convenience constructor for the scalar case, when a given column
2323
/// in the schema spans only a single column in the dataset.
24+
/// <see cref="Min"/> and <see cref="Max"/> are set to the single value <paramref name="ordinal"/>.
2425
/// </summary>
2526
/// <param name="ordinal">Column index in the dataset.</param>
2627
public TextLoaderRange(int ordinal)

src/Microsoft.ML/Models/RegressionEvaluator.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.ML.Runtime.EntryPoints;
88
using Microsoft.ML.Transforms;
99
using System.Collections.Generic;
10+
using System.Linq;
1011

1112
namespace Microsoft.ML.Models
1213
{
@@ -24,7 +25,7 @@ public sealed partial class RegressionEvaluator
2425
/// <returns>
2526
/// A RegressionMetrics instance that describes how well the model performed against the test data.
2627
/// </returns>
27-
public List<RegressionMetrics> Evaluate(PredictionModel model, ILearningPipelineLoader testData)
28+
public RegressionMetrics Evaluate(PredictionModel model, ILearningPipelineLoader testData)
2829
{
2930
using (var environment = new TlcEnvironment())
3031
{
@@ -61,8 +62,12 @@ public List<RegressionMetrics> Evaluate(PredictionModel model, ILearningPipeline
6162
{
6263
throw environment.Except($"Could not find OverallMetrics in the results returned in {nameof(RegressionEvaluator)} Evaluate.");
6364
}
65+
66+
var metric = RegressionMetrics.FromOverallMetrics(environment, overallMetrics);
6467

65-
return RegressionMetrics.FromOverallMetrics(environment, overallMetrics);
68+
Contracts.Assert(metric.Count == 1);
69+
70+
return metric.First();
6671
}
6772
}
6873
}

src/Microsoft.ML/Runtime/EntryPoints/CrossValidationMacro.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ public sealed class Arguments
6969

7070
// For splitting the data into folds, this column is used for grouping rows and makes sure
7171
// that a group of rows is not split among folds.
72-
[Argument(ArgumentType.LastOccurenceWins, HelpText = "Column to use for stratification", ShortName = "strat", SortOrder = 7)]
72+
[Argument(ArgumentType.LastOccurenceWins, HelpText = "Column to use for stratification", ShortName = "strat", SortOrder = 6)]
7373
public string StratificationColumn;
7474

7575
// The number of folds to generate.
76-
[Argument(ArgumentType.LastOccurenceWins, HelpText = "Number of folds in k-fold cross-validation", ShortName = "k", SortOrder = 8)]
76+
[Argument(ArgumentType.LastOccurenceWins, HelpText = "Number of folds in k-fold cross-validation", ShortName = "k", SortOrder = 7)]
7777
public int NumFolds = 2;
7878

7979
// REVIEW: suggest moving to subcomponents for evaluators, to allow for different parameters on the evaluators
8080
// (and the same for the TrainTest macro). I currently do not know how to do this, so this should be revisited in the future.
81-
[Argument(ArgumentType.Required, HelpText = "Specifies the trainer kind, which determines the evaluator to be used.", SortOrder = 9)]
81+
[Argument(ArgumentType.Required, HelpText = "Specifies the trainer kind, which determines the evaluator to be used.", SortOrder = 8)]
8282
public MacroUtils.TrainerKinds Kind = MacroUtils.TrainerKinds.SignatureBinaryClassifierTrainer;
8383
}
8484

@@ -94,16 +94,16 @@ public sealed class Output
9494
"provided as the Input.TransformModel.", SortOrder = 2)]
9595
public ITransformModel[] TransformModel;
9696

97-
[TlcModule.Output(Desc = "Warning dataset", SortOrder = 2)]
97+
[TlcModule.Output(Desc = "Warning dataset", SortOrder = 3)]
9898
public IDataView Warnings;
9999

100-
[TlcModule.Output(Desc = "Overall metrics dataset", SortOrder = 3)]
100+
[TlcModule.Output(Desc = "Overall metrics dataset", SortOrder = 4)]
101101
public IDataView OverallMetrics;
102102

103-
[TlcModule.Output(Desc = "Per instance metrics dataset", SortOrder = 4)]
103+
[TlcModule.Output(Desc = "Per instance metrics dataset", SortOrder = 5)]
104104
public IDataView PerInstanceMetrics;
105105

106-
[TlcModule.Output(Desc = "Confusion matrix dataset", SortOrder = 5)]
106+
[TlcModule.Output(Desc = "Confusion matrix dataset", SortOrder = 6)]
107107
public IDataView ConfusionMatrix;
108108
}
109109

@@ -122,25 +122,25 @@ public sealed class CombineMetricsInput
122122
[Argument(ArgumentType.Multiple, HelpText = "Warning datasets", SortOrder = 4)]
123123
public IDataView[] Warnings;
124124

125-
[Argument(ArgumentType.AtMostOnce, HelpText = "The label column name", ShortName = "Label", SortOrder = 6)]
125+
[Argument(ArgumentType.AtMostOnce, HelpText = "The label column name", ShortName = "Label", SortOrder = 5)]
126126
public string LabelColumn = DefaultColumnNames.Label;
127127

128-
[Argument(ArgumentType.Required, HelpText = "Specifies the trainer kind, which determines the evaluator to be used.", SortOrder = 7)]
128+
[Argument(ArgumentType.Required, HelpText = "Specifies the trainer kind, which determines the evaluator to be used.", SortOrder = 6)]
129129
public MacroUtils.TrainerKinds Kind = MacroUtils.TrainerKinds.SignatureBinaryClassifierTrainer;
130130
}
131131

132132
public sealed class CombinedOutput
133133
{
134-
[TlcModule.Output(Desc = "Warning dataset", SortOrder = 2)]
134+
[TlcModule.Output(Desc = "Warning dataset", SortOrder = 1)]
135135
public IDataView Warnings;
136136

137-
[TlcModule.Output(Desc = "Overall metrics dataset", SortOrder = 3)]
137+
[TlcModule.Output(Desc = "Overall metrics dataset", SortOrder = 2)]
138138
public IDataView OverallMetrics;
139139

140-
[TlcModule.Output(Desc = "Per instance metrics dataset", SortOrder = 4)]
140+
[TlcModule.Output(Desc = "Per instance metrics dataset", SortOrder = 3)]
141141
public IDataView PerInstanceMetrics;
142142

143-
[TlcModule.Output(Desc = "Confusion matrix dataset", SortOrder = 5)]
143+
[TlcModule.Output(Desc = "Confusion matrix dataset", SortOrder = 4)]
144144
public IDataView ConfusionMatrix;
145145
}
146146

test/Microsoft.ML.Tests/Scenarios/HousePriceTrainAndPredictionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void TrainAndPredictHousePriceModelTest()
6666
var testData = new TextLoader(testDataPath).CreateFrom<HousePriceData>(useHeader: true, separator: ',');
6767

6868
var evaluator = new RegressionEvaluator();
69-
RegressionMetrics metrics = evaluator.Evaluate(model, testData).FirstOrDefault();
69+
RegressionMetrics metrics = evaluator.Evaluate(model, testData);
7070
Assert.InRange(metrics.L1, 85_000, 89_000);
7171
Assert.InRange(metrics.L2, 17_000_000_000, 19_000_000_000);
7272
Assert.InRange(metrics.Rms, 130_500, 135_000);

0 commit comments

Comments
 (0)