@@ -23,7 +23,7 @@ public static void Example()
23
23
24
24
// Step 1: Read the data as an IDataView.
25
25
// First, we define the reader: specify the data columns and where to find them in the text file.
26
- var reader = mlContext . Data . CreateTextLoader (
26
+ var loader = mlContext . Data . CreateTextLoader (
27
27
columns : new [ ]
28
28
{
29
29
new TextLoader . Column ( "Sentiment" , DataKind . Single , 0 ) ,
@@ -32,22 +32,22 @@ public static void Example()
32
32
hasHeader : true
33
33
) ;
34
34
35
- // Read the data
36
- var trainData = reader . Load ( trainFile ) ;
35
+ // Load the data
36
+ var trainData = loader . Load ( trainFile ) ;
37
37
38
38
// Step 2: Pipeline
39
39
// Featurize the text column through the FeaturizeText API.
40
40
// Then append a binary classifier, setting the "Label" column as the label of the dataset, and
41
41
// the "Features" column produced by FeaturizeText as the features column.
42
42
var pipeline = mlContext . Transforms . Text . FeaturizeText ( "Features" , "SentimentText" )
43
- . AppendCacheCheckpoint ( mlContext )
43
+ . AppendCacheCheckpoint ( mlContext ) // Add a data-cache step within a pipeline.
44
44
. Append ( mlContext . BinaryClassification . Trainers . Prior ( labelColumnName : "Sentiment" ) ) ;
45
45
46
46
// Step 3: Train the pipeline
47
47
var trainedPipeline = pipeline . Fit ( trainData ) ;
48
48
49
49
// Step 4: Evaluate on the test set
50
- var transformedData = trainedPipeline . Transform ( reader . Load ( testFile ) ) ;
50
+ var transformedData = trainedPipeline . Transform ( loader . Load ( testFile ) ) ;
51
51
var evalMetrics = mlContext . BinaryClassification . Evaluate ( transformedData , label : "Sentiment" ) ;
52
52
SamplesUtils . ConsoleUtils . PrintMetrics ( evalMetrics ) ;
53
53
0 commit comments