@@ -78,93 +78,5 @@ public void OneDalFastTreeBinaryEstimator()
7878
7979 Assert . True ( testingMetrics . Accuracy > 0.8 ) ;
8080 }
81-
82-
83- //[Fact]
84- //[NativeDependencyFact("MatrixFactorizationNative")]
85- [ NativeDependencyFact ( "OneDalNative" ) ]
86- public void TestDependency ( )
87- {
88- var currentDir = AppContext . BaseDirectory ;
89- Output . WriteLine ( $ "**** Running from directory { currentDir } .") ;
90-
91- var dllDir = AppContext . GetData ( "NATIVE_DLL_SEARCH_DIRECTORIES" ) . ToString ( ) ;
92- Output . WriteLine ( $ "**** The search dir is { dllDir } .") ;
93-
94- DependencyContext defaultContext = DependencyContext . Default ;
95- var currentRid = RuntimeEnvironment . GetRuntimeIdentifier ( ) ;
96- Output . WriteLine ( $ "**** the current RID is { currentRid } .") ;
97-
98- var runtimeLibs = defaultContext . RuntimeLibraries ;
99- try
100- {
101- // var candidates = runtimeLibs.Where(x => Regex.IsMatch(x.Name, ".*LightG.*", RegexOptions.IgnoreCase));
102- var candidates = runtimeLibs . Where ( x => Regex . IsMatch ( x . Name , ".*onedal.*" , RegexOptions . IgnoreCase ) ) ;
103- var possible = candidates . First ( ) ;
104- Output . WriteLine ( $ "**** [{ possible . Name } ] found of a count of [ { candidates . Count ( ) } ] .") ;
105- var nativeAssets = possible . GetRuntimeNativeAssets ( defaultContext , currentRid ) ;
106- Output . WriteLine ( $ "**** With [ { nativeAssets . Count ( ) } ] native assets") ;
107- foreach ( var na in nativeAssets )
108- {
109- Output . WriteLine ( $ "**** -- nativeAsset: [ { na } ]") ;
110- }
111- }
112- catch ( Exception ex )
113- {
114- Output . WriteLine ( $ "**** Had some trouble retrieving onedal: [ { ex . Message } ] .") ;
115- }
116-
117- Assert . True ( true ) ;
118- }
119-
120- //[Fact]
121- [ NativeDependencyFact ( "OneDalNative" ) ]
122- public void OneDalFastTreeBinaryEstimatorAtt ( )
123- {
124- Environment . SetEnvironmentVariable ( "MLNET_BACKEND" , "ONEDAL" ) ;
125- var trainDataPath = GetDataPath ( "binary_synth_data_train.csv" ) ;
126- var testDataPath = GetDataPath ( "binary_synth_data_test.csv" ) ;
127-
128- var loader = ML . Data . CreateTextLoader ( columns : new [ ] {
129- new TextLoader . Column ( "f0" , DataKind . Single , 0 ) ,
130- new TextLoader . Column ( "f1" , DataKind . Single , 1 ) ,
131- new TextLoader . Column ( "f2" , DataKind . Single , 2 ) ,
132- new TextLoader . Column ( "f3" , DataKind . Single , 3 ) ,
133- new TextLoader . Column ( "f4" , DataKind . Single , 4 ) ,
134- new TextLoader . Column ( "f5" , DataKind . Single , 5 ) ,
135- new TextLoader . Column ( "f6" , DataKind . Single , 6 ) ,
136- new TextLoader . Column ( "f7" , DataKind . Single , 7 ) ,
137- new TextLoader . Column ( "target" , DataKind . Boolean , 8 ) } ,
138- separatorChar : ',' ,
139- hasHeader : true ) ;
140-
141- var trainingData = loader . Load ( trainDataPath ) ;
142- var testingData = loader . Load ( testDataPath ) ;
143-
144- var preprocessingPipeline = ML . Transforms . Concatenate ( "Features" , new string [ ] { "f0" , "f1" , "f2" , "f3" , "f4" , "f5" , "f6" , "f7" } ) ;
145-
146- var preprocessedTrainingData = preprocessingPipeline . Fit ( trainingData ) . Transform ( trainingData ) ;
147- var preprocessedTestingData = preprocessingPipeline . Fit ( trainingData ) . Transform ( testingData ) ;
148-
149- // Output.WriteLine($"**** After preprocessing the data got {preprocessedTrainingData.Schema.Count} columns.");
150-
151- FastForestBinaryTrainer . Options options = new FastForestBinaryTrainer . Options ( ) ;
152- options . LabelColumnName = "target" ;
153- options . FeatureColumnName = "Features" ;
154- options . NumberOfTrees = 100 ;
155- options . NumberOfLeaves = 128 ;
156- options . MinimumExampleCountPerLeaf = 5 ;
157- options . FeatureFraction = 1.0 ;
158-
159- var trainer = ML . BinaryClassification . Trainers . FastForest ( options ) ;
160- var model = trainer . Fit ( preprocessedTrainingData ) ;
161- var trainingPredictions = model . Transform ( preprocessedTrainingData ) ;
162- var trainingMetrics = ML . BinaryClassification . EvaluateNonCalibrated ( trainingPredictions , labelColumnName : "target" ) ;
163- var testingPredictions = model . Transform ( preprocessedTestingData ) ;
164- var testingMetrics = ML . BinaryClassification . EvaluateNonCalibrated ( testingPredictions , labelColumnName : "target" ) ;
165-
166- Assert . True ( testingMetrics . Accuracy > 0.8 ) ;
167- }
168-
16981 }
17082}
0 commit comments