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

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

主站蜘蛛池模板: 教育| 郸城县| 邯郸市| 济源市| 渑池县| 锦州市| 浪卡子县| 兖州市| 灌阳县| 沿河| 太和县| 加查县| 嵊泗县| 拉孜县| 浦江县| 太仆寺旗| 孟村| 克山县| 宜良县| 汾阳市| 临夏县| 湘潭县| 股票| 交城县| 丰县| 武平县| 临潭县| 澜沧| 逊克县| 维西| 萨迦县| 杨浦区| 元谋县| 饶平县| 武威市| 镇雄县| 西藏| 长葛市| 黄浦区| 涡阳县| 板桥市|