You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You need to create some classes for your input data and predictions. Add a new class to your project:
@@ -122,8 +122,9 @@ Add the following code, which has two classes `SentimentData` and `SentimentPred
122
122
```csharp
123
123
publicclassSentimentData
124
124
{
125
+
[Column(ordinal:"0")]
125
126
publicstringSentimentText;
126
-
[ColumnName("Label")]
127
+
[Column(ordinal:"1", name:"Label")]
127
128
publicfloatSentiment;
128
129
}
129
130
@@ -134,7 +135,7 @@ public class SentimentPrediction
134
135
}
135
136
```
136
137
137
-
`SentimentData` is the input dataset class and has a string for the comment (`SentimentText`), a boolean (`Sentiment`) that has a value for sentiment of either positive or negative, and a `Label``ColumnName` attribute. `SentimentPrediction` is the class used for prediction after the model has been trained. It has a single boolean (`Sentiment`) and a `PredictedLabel``ColumnName` attribute. The `Label` is used to create and train the model, and it's also used with a second dataset to evaluate the model. The `PredictedLabel` is used during prediction and evaluation. For evaluation, an input with training data, the predicted values, and the model are used.
138
+
`SentimentData` is the input dataset class and has a string for the comment (`SentimentText`), a `float` (`Sentiment`) that has a value for sentiment of either positive or negative. Both fields have `Column` attributes attached to them. This attribute describes the order of each field in the data file, and which is the `Label`field. `SentimentPrediction` is the class used for prediction after the model has been trained. It has a single boolean (`Sentiment`) and a `PredictedLabel``ColumnName` attribute. The `Label` is used to create and train the model, and it's also used with a second dataset to evaluate the model. The `PredictedLabel` is used during prediction and evaluation. For evaluation, an input with training data, the predicted values, and the model are used.
138
139
139
140
In the *Program.cs* file, replace the `Console.WriteLine("Hello World!")` line with the following code in the `Main` method:
140
141
@@ -169,7 +170,7 @@ var pipeline = new LearningPipeline();
169
170
The <xref:Microsoft.ML.TextLoader%601> object is the first part of the pipeline, and loads the training file data.
The <xref:Microsoft.ML.TextLoader%601> class loads the new test dataset with the same schema. You can evaluate the model using this dataset as a quality check. Add that next to the `Evaluate` method call, using the following code:
The <xref:Microsoft.ML.Models.BinaryClassificationEvaluator> object computes the quality metrics for the `PredictionModel` using the specified dataset. To see those metrics, add the evaluator as the next line in the `Evaluate` method, with the following code:
Copy file name to clipboardExpand all lines: docs/machine-learning/tutorials/taxi-fare.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,21 +105,25 @@ Next, create classes for the input data and the predictions:
105
105
usingMicrosoft.ML.Runtime.Api;
106
106
```
107
107
108
-
Add two classes into this file. `TaxiTrip`, the input data set class, has definitions for each of the columns discovered above and a `Label``ColumnName`attribute. Add the following code to the file:
108
+
Add two classes into this file. `TaxiTrip`, the input data set class, has definitions for each of the columns discovered above and a `Label` attribute for the fare_amount column that you are predicting. Add the following code to the file:
0 commit comments