官术网_书友最值得收藏!

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).

主站蜘蛛池模板: 天长市| 浦县| 桐城市| 景谷| 湖南省| 漾濞| 玉屏| 凤城市| 文登市| 蓬安县| 金昌市| 大荔县| 宜兰市| 泰宁县| 门源| 墨玉县| 西吉县| 沈丘县| 拉孜县| 丹阳市| 宾川县| 赣州市| 临泽县| 宾阳县| 巴彦淖尔市| 安陆市| 高邑县| 大石桥市| 聂荣县| 桐乡市| 泸溪县| 象州县| 乌拉特中旗| 黑河市| 松溪县| 简阳市| 保德县| 晋中市| 敖汉旗| 科技| 法库县|