- Hands-On Machine Learning with ML.NET
- Jarred Capellman
- 321字
- 2021-06-24 16:43:29
The RestaurantFeedback class
The RestaurantFeedback class provides the input class for our model. In ML.NET (and other frameworks), the traditional approach is to have a structured input to feed into your data pipeline, which, in turn, is passed into the training phase and eventually your trained model.
The following class defines our container class to hold our prediction values. This is the approach that we will use throughout the rest of the book:
using Microsoft.ML.Data;
namespace chapter02.ML.Objects
{
public class RestaurantFeedback
{
[LoadColumn(0)]
public bool Label { get; set; }
[LoadColumn(1)]
public string Text { get; set; }
}
}
You might be wondering what the correlation between the Label and Text properties in the RestarauntFeedback class and the source data is at first glance. Contained within the Data folder, there is a file named sampledata.csv. This file contains the following:
0 "Great Pizza"
0 "Awesome customer service"
1 "Dirty floors"
1 "Very expensive"
0 "Toppings are good"
1 "Parking is terrible"
0 "Bathrooms are clean"
1 "Management is unhelpful"
0 "Lighting and atmosphere are romantic"
1 "Crust was burnt"
0 "Pineapple was fresh"
1 "Lack of garlic cloves is upsetting"
0 "Good experience, would come back"
0 "Friendly staff"
1 "Rude customer service"
1 "Waiters never came back"
1 "Could not believe the napkins were $10!"
0 "Supersized Pizza is a great deal"
0 "$5 all you can eat deal is good"
1 "Overpriced and was shocked that utensils were an upcharge"
The first column maps to the Label property. As you might recall in Chapter 1, Getting Started with Machine Learning and ML.NET, supervised learning such as that being performed in this sample requires labeling. In this project, our label is a Boolean. False (0) in the dataset indicates positive feedback, while True (1) indicates negative feedback.
The second column maps to the Text property to propagate the sentiment (which is, the sentence to feed into the model).
- JavaScript從入門到精通(微視頻精編版)
- Debian 7:System Administration Best Practices
- AWS Serverless架構:使用AWS從傳統部署方式向Serverless架構遷移
- Python語言程序設計
- SQL for Data Analytics
- Mastering Articulate Storyline
- Git高手之路
- Processing互動編程藝術
- Unity 5.x By Example
- Oracle Exadata專家手冊
- Flutter跨平臺開發入門與實戰
- 51單片機C語言開發教程
- C++ Fundamentals
- uni-app跨平臺開發與應用從入門到實踐
- Java程序設計與項目案例教程