1
- // This is an auto generated file by ML.NET CLI
1
+ //*****************************************************************************************
2
+ //* *
3
+ //* This is an auto-generated file by Microsoft ML.NET CLI (Command-Line Interface) tool. *
4
+ //* *
5
+ //*****************************************************************************************
2
6
3
7
using System;
4
8
using System.IO;
5
9
using System.Linq;
6
10
using Microsoft.ML;
7
- using Microsoft.ML.Core.Data;
8
11
using Microsoft.ML.Data;
9
12
using Microsoft.Data.DataView;
10
13
using Microsoft.ML.LightGBM;
@@ -49,26 +52,24 @@ namespace MyNamespace
49
52
private static ITransformer BuildTrainEvaluateAndSaveModel(MLContext mlContext)
50
53
{
51
54
// Data loading
52
- IDataView trainingDataView = mlContext.Data.ReadFromTextFile <SampleObservation>(
55
+ IDataView trainingDataView = mlContext.Data.LoadFromTextFile <SampleObservation>(
53
56
path: TrainDataPath,
54
57
hasHeader: true,
55
58
separatorChar: ',',
56
- allowQuotedStrings: true,
57
- trimWhitespace: false,
58
- supportSparse: true);
59
- IDataView testDataView = mlContext.Data.ReadFromTextFile<SampleObservation>(
59
+ allowQuoting: true,
60
+ allowSparse: true);
61
+ IDataView testDataView = mlContext.Data.LoadFromTextFile<SampleObservation>(
60
62
path: TestDataPath,
61
63
hasHeader: true,
62
64
separatorChar: ',',
63
- allowQuotedStrings: true,
64
- trimWhitespace: false,
65
- supportSparse: true);
65
+ allowQuoting: true,
66
+ allowSparse: true);
66
67
67
68
// Common data process configuration with pipeline data transformations
68
69
var dataProcessPipeline = mlContext.Transforms.Concatenate("Out", new[] { "In" });
69
70
70
71
// Set the training algorithm, then create and config the modelBuilder
71
- var trainer = mlContext.BinaryClassification.Trainers.LightGbm(new Options() { NumLeaves = 2, Booster = new Options.TreeBooster.Arguments () { }, LabelColumn = "Label", FeatureColumn = "Features" });
72
+ var trainer = mlContext.BinaryClassification.Trainers.LightGbm(new Options() { NumLeaves = 2, Booster = new Options.TreeBooster.Options () { }, LabelColumn = "Label", FeatureColumn = "Features" });
72
73
var trainingPipeline = dataProcessPipeline.Append(trainer);
73
74
74
75
// Train the model fitting to the DataSet
@@ -95,15 +96,14 @@ namespace MyNamespace
95
96
private static void TestSinglePrediction(MLContext mlContext)
96
97
{
97
98
//Load data to test. Could be any test data. For demonstration purpose train data is used here.
98
- IDataView trainingDataView = mlContext.Data.ReadFromTextFile <SampleObservation>(
99
+ IDataView trainingDataView = mlContext.Data.LoadFromTextFile <SampleObservation>(
99
100
path: TrainDataPath,
100
101
hasHeader: true,
101
102
separatorChar: ',',
102
- allowQuotedStrings: true,
103
- trimWhitespace: false,
104
- supportSparse: true);
103
+ allowQuoting: true,
104
+ allowSparse: true);
105
105
106
- var sample = mlContext.CreateEnumerable<SampleObservation>(trainingDataView, false).First();
106
+ var sample = mlContext.Data. CreateEnumerable<SampleObservation>(trainingDataView, false).First();
107
107
108
108
ITransformer trainedModel;
109
109
using (var stream = new FileStream(ModelPath, FileMode.Open, FileAccess.Read, FileShare.Read))
@@ -131,23 +131,23 @@ namespace MyNamespace
131
131
132
132
133
133
[ColumnName("col1"), LoadColumn(1)]
134
- public float Col1 { get; set; }
134
+ public float col1 { get; set; }
135
135
136
136
137
137
[ColumnName("col2"), LoadColumn(0)]
138
- public float Col2 { get; set; }
138
+ public float col2 { get; set; }
139
139
140
140
141
141
[ColumnName("col3"), LoadColumn(0)]
142
- public string Col3 { get; set; }
142
+ public string col3 { get; set; }
143
143
144
144
145
145
[ColumnName("col4"), LoadColumn(0)]
146
- public int Col4 { get; set; }
146
+ public int col4 { get; set; }
147
147
148
148
149
149
[ColumnName("col5"), LoadColumn(0)]
150
- public uint Col5 { get; set; }
150
+ public uint col5 { get; set; }
151
151
152
152
153
153
}
0 commit comments