- 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).
- Debian 7:System Administration Best Practices
- Docker進階與實戰
- R語言數據可視化之美:專業圖表繪制指南
- Unreal Engine 4 Shaders and Effects Cookbook
- Learning Python Design Patterns
- The Complete Coding Interview Guide in Java
- 精通Python自動化編程
- Webpack實戰:入門、進階與調優
- Microsoft 365 Certified Fundamentals MS-900 Exam Guide
- Mastering Adobe Captivate 7
- Visual Basic 程序設計實踐教程
- 川哥教你Spring Boot 2實戰
- 循序漸進Vue.js 3前端開發實戰
- 三步學Python
- 威脅建模:設計和交付更安全的軟件