Skip to content

Commit 0eb3e2b

Browse files
committed
Reverted back some spacing. Accidentally reverted some changes in Evaluation.cs so got those back
1 parent 35ad3c0 commit 0eb3e2b

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

test/Microsoft.ML.Functional.Tests/Evaluation.cs

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using Microsoft.ML.Data;
56
using Microsoft.ML.Functional.Tests.Datasets;
67
using Microsoft.ML.RunTests;
78
using Microsoft.ML.TestFramework;
89
using Microsoft.ML.TestFramework.Attributes;
10+
using Microsoft.ML.Tools;
911
using Microsoft.ML.Trainers;
1012
using Microsoft.ML.Trainers.FastTree;
1113
using Xunit;
@@ -165,14 +167,8 @@ public void TrainAndEvaluateMulticlassClassification()
165167
Common.AssertMetrics(metrics);
166168
}
167169

168-
/// <summary>
169-
/// Train and Evaluate: Ranking.
170-
/// </summary>
171-
[Fact]
172-
public void TrainAndEvaluateRanking()
170+
private IDataView GetScoredDataForRankingEvaluation(MLContext mlContext)
173171
{
174-
var mlContext = new MLContext(seed: 1);
175-
176172
var data = Iris.LoadAsRankingProblem(mlContext,
177173
GetDataPath(TestDatasets.iris.trainFilename),
178174
hasHeader: TestDatasets.iris.fileHasHeader,
@@ -187,12 +183,45 @@ public void TrainAndEvaluateRanking()
187183

188184
// Evaluate the model.
189185
var scoredData = model.Transform(data);
186+
187+
return scoredData;
188+
}
189+
190+
/// <summary>
191+
/// Train and Evaluate: Ranking.
192+
/// </summary>
193+
[Fact]
194+
public void TrainAndEvaluateRanking()
195+
{
196+
var mlContext = new MLContext(seed: 1);
197+
198+
var scoredData = GetScoredDataForRankingEvaluation(mlContext);
190199
var metrics = mlContext.Ranking.Evaluate(scoredData, labelColumnName: "Label", rowGroupColumnName: "GroupId");
191200

192201
// Check that the metrics returned are valid.
193202
Common.AssertMetrics(metrics);
194203
}
195204

205+
/// <summary>
206+
/// Train and Evaluate: Ranking with options.
207+
/// </summary>
208+
[Fact]
209+
public void TrainAndEvaluateRankingWithOptions()
210+
{
211+
var mlContext = new MLContext(seed: 1);
212+
int[] tlevels = { 50, 150, 100 };
213+
var options = new RankingEvaluatorOptions();
214+
foreach (int i in tlevels)
215+
{
216+
options.DcgTruncationLevel = i;
217+
var scoredData = GetScoredDataForRankingEvaluation(mlContext);
218+
var metrics = mlContext.Ranking.Evaluate(scoredData, options, labelColumnName: "Label", rowGroupColumnName: "GroupId");
219+
Common.AssertMetrics(metrics);
220+
}
221+
222+
223+
}
224+
196225
/// <summary>
197226
/// Train and Evaluate: Recommendation.
198227
/// </summary>

test/Microsoft.ML.TestFramework/Microsoft.ML.TestFramework.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
<NativeAssemblyReference Include="MklProxyNative" />
2424
<NativeAssemblyReference Include="MatrixFactorizationNative" />
2525
<NativeAssemblyReference Include="MklImports" />
26-
<NativeAssemblyReference Condition="'$(OS)' == 'Windows_NT'" Include="libiomp5md" />
26+
<NativeAssemblyReference Condition="'$(OS)' == 'Windows_NT'" Include="libiomp5md"/>
2727
</ItemGroup>
2828
</Project>

test/Microsoft.ML.TestFramework/TestCommandBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@ public void SaveMulticlassLrPredictorAsSummary()
846846
_step++;
847847
OutputPath summaryModel = CreateOutputPath("summary.txt");
848848
TestInCore("savepredictor", null, trainModel, null, summaryModel.Arg("sum"));
849+
849850
Done();
850851
}
851852

0 commit comments

Comments
 (0)