11
11
12
12
namespace Microsoft . ML . Benchmarks
13
13
{
14
- public class Ranking
14
+ [ Config ( typeof ( TrainConfig ) ) ]
15
+ public class RankingTrain
15
16
{
16
17
private string _mslrWeb10k_Validate ;
17
18
private string _mslrWeb10k_Train ;
18
- private string _mslrWeb10k_Test ;
19
- private string _modelPath_MSLR ;
20
19
21
- [ GlobalSetup ( Targets = new string [ ] {
22
- nameof ( TrainTest_Ranking_MSLRWeb10K_RawNumericFeatures_FastTreeRanking ) ,
23
- nameof ( TrainTest_Ranking_MSLRWeb10K_RawNumericFeatures_LightGBMRanking ) } ) ]
20
+ [ GlobalSetup ]
24
21
public void SetupTrainingSpeedTests ( )
25
22
{
26
23
_mslrWeb10k_Validate = Path . GetFullPath ( TestDatasets . MSLRWeb . validFilename ) ;
@@ -33,24 +30,15 @@ public void SetupTrainingSpeedTests()
33
30
throw new FileNotFoundException ( string . Format ( Helpers . DatasetNotFound , _mslrWeb10k_Train ) ) ;
34
31
}
35
32
36
- [ GlobalSetup ( Target = nameof ( Test_Ranking_MSLRWeb10K_RawNumericFeatures_FastTreeRanking ) ) ]
37
- public void SetupScoringSpeedTests ( )
33
+ [ Benchmark ]
34
+ public void TrainTest_Ranking_MSLRWeb10K_RawNumericFeatures_FastTreeRanking ( )
38
35
{
39
- _mslrWeb10k_Test = Path . GetFullPath ( TestDatasets . MSLRWeb . testFilename ) ;
40
- if ( ! File . Exists ( _mslrWeb10k_Test ) )
41
- throw new FileNotFoundException ( string . Format ( Helpers . DatasetNotFound , _mslrWeb10k_Test ) ) ;
42
-
43
- SetupTrainingSpeedTests ( ) ;
44
- _modelPath_MSLR = Path . Combine ( Directory . GetCurrentDirectory ( ) , @"FastTreeRankingModel.zip" ) ;
45
-
46
36
string cmd = @"TrainTest test=" + _mslrWeb10k_Validate +
47
37
" eval=RankingEvaluator{t=10}" +
48
38
" data=" + _mslrWeb10k_Train +
49
39
" loader=TextLoader{col=Label:R4:0 col=GroupId:TX:1 col=Features:R4:2-138}" +
50
- " xf=HashTransform{col=GroupId}" +
51
- " xf=NAHandleTransform{col=Features}" +
52
- " tr=FastTreeRanking{}" +
53
- " out={" + _modelPath_MSLR + "}" ;
40
+ " xf=HashTransform{col=GroupId} xf=NAHandleTransform{col=Features}" +
41
+ " tr=FastTreeRanking{}" ;
54
42
55
43
using ( var environment = new ConsoleEnvironment ( verbose : false , sensitivity : MessageSensitivity . None , outWriter : EmptyWriter . Instance ) )
56
44
{
@@ -59,31 +47,57 @@ public void SetupScoringSpeedTests()
59
47
}
60
48
61
49
[ Benchmark ]
62
- public void TrainTest_Ranking_MSLRWeb10K_RawNumericFeatures_FastTreeRanking ( )
50
+ public void TrainTest_Ranking_MSLRWeb10K_RawNumericFeatures_LightGBMRanking ( )
63
51
{
64
52
string cmd = @"TrainTest test=" + _mslrWeb10k_Validate +
65
53
" eval=RankingEvaluator{t=10}" +
66
54
" data=" + _mslrWeb10k_Train +
67
55
" loader=TextLoader{col=Label:R4:0 col=GroupId:TX:1 col=Features:R4:2-138}" +
68
- " xf=HashTransform{col=GroupId} xf=NAHandleTransform{col=Features}" +
69
- " tr=FastTreeRanking{}" ;
56
+ " xf=HashTransform{col=GroupId}" +
57
+ " xf=NAHandleTransform{col=Features}" +
58
+ " tr=LightGBMRanking{}" ;
70
59
71
60
using ( var environment = new ConsoleEnvironment ( verbose : false , sensitivity : MessageSensitivity . None , outWriter : EmptyWriter . Instance ) )
72
61
{
73
62
Maml . MainCore ( environment , cmd , alwaysPrintStacktrace : false ) ;
74
63
}
75
64
}
65
+ }
76
66
77
- [ Benchmark ]
78
- public void TrainTest_Ranking_MSLRWeb10K_RawNumericFeatures_LightGBMRanking ( )
67
+ [ Config ( typeof ( PredictConfig ) ) ]
68
+ public class RankingTest
69
+ {
70
+ private string _mslrWeb10k_Validate ;
71
+ private string _mslrWeb10k_Train ;
72
+ private string _mslrWeb10k_Test ;
73
+ private string _modelPath_MSLR ;
74
+
75
+ [ GlobalSetup ]
76
+ public void SetupScoringSpeedTests ( )
79
77
{
78
+ _mslrWeb10k_Test = Path . GetFullPath ( TestDatasets . MSLRWeb . testFilename ) ;
79
+ _mslrWeb10k_Validate = Path . GetFullPath ( TestDatasets . MSLRWeb . validFilename ) ;
80
+ _mslrWeb10k_Train = Path . GetFullPath ( TestDatasets . MSLRWeb . trainFilename ) ;
81
+
82
+ if ( ! File . Exists ( _mslrWeb10k_Test ) )
83
+ throw new FileNotFoundException ( string . Format ( Helpers . DatasetNotFound , _mslrWeb10k_Test ) ) ;
84
+
85
+ if ( ! File . Exists ( _mslrWeb10k_Validate ) )
86
+ throw new FileNotFoundException ( string . Format ( Helpers . DatasetNotFound , _mslrWeb10k_Validate ) ) ;
87
+
88
+ if ( ! File . Exists ( _mslrWeb10k_Train ) )
89
+ throw new FileNotFoundException ( string . Format ( Helpers . DatasetNotFound , _mslrWeb10k_Train ) ) ;
90
+
91
+ _modelPath_MSLR = Path . Combine ( Directory . GetCurrentDirectory ( ) , @"FastTreeRankingModel.zip" ) ;
92
+
80
93
string cmd = @"TrainTest test=" + _mslrWeb10k_Validate +
81
94
" eval=RankingEvaluator{t=10}" +
82
95
" data=" + _mslrWeb10k_Train +
83
96
" loader=TextLoader{col=Label:R4:0 col=GroupId:TX:1 col=Features:R4:2-138}" +
84
97
" xf=HashTransform{col=GroupId}" +
85
98
" xf=NAHandleTransform{col=Features}" +
86
- " tr=LightGBMRanking{}" ;
99
+ " tr=FastTreeRanking{}" +
100
+ " out={" + _modelPath_MSLR + "}" ;
87
101
88
102
using ( var environment = new ConsoleEnvironment ( verbose : false , sensitivity : MessageSensitivity . None , outWriter : EmptyWriter . Instance ) )
89
103
{
@@ -95,7 +109,7 @@ public void TrainTest_Ranking_MSLRWeb10K_RawNumericFeatures_LightGBMRanking()
95
109
public void Test_Ranking_MSLRWeb10K_RawNumericFeatures_FastTreeRanking ( )
96
110
{
97
111
// This benchmark is profiling bulk scoring speed and not training speed.
98
- string cmd = @"Test data=" + _mslrWeb10k_Test + " in=" + _modelPath_MSLR ;
112
+ string cmd = @"Test data=" + _mslrWeb10k_Test + " in=" + _modelPath_MSLR ;
99
113
using ( var environment = new ConsoleEnvironment ( verbose : false , sensitivity : MessageSensitivity . None , outWriter : EmptyWriter . Instance ) )
100
114
{
101
115
Maml . MainCore ( environment , cmd , alwaysPrintStacktrace : false ) ;
0 commit comments