Categorize the severity of restaurant health violations using ML.NET Model Builder

ML.NET version Status App Type Data type Scenario ML Task Algorithms
v1.6.0 Up-to-date Console App Single data sample Issue Classification Multiclass classification Linear Classification

For a detailed explanation of how to build this application, see the accompanying tutorial on the Microsoft Docs site.

Goal

Create a C# .NET Core Console application that uses an ML.NET multiclass classification machine learning model trained using Model Builder to categorize the risk level of restaurant violations found during health inspections.

Application

  • RestaurantViolations: A C# .NET Core Console application that uses a multiclass classification model to assign risk to violations encountered during restaurant inspections.
  • RestaurantViolationsML.ConsoleApp: A .NET Core Console application that contains the model training and test prediction code.
  • RestaurantViolationsML.Model: A .NET Standard class library containing the data models that define the schema of input and output model data as well as the persisted version of the best performing model during training.

The data

The data set used to train and evaluate the machine learning model is originally from the San Francisco Department of Public Health Restaurant Safety Scores. For convenience, the dataset has been condensed to only include the columns relevant to train the model and make predictions. Visit the following website to learn more about the dataset.

inspection_type violation_description risk_category
Routine - Unscheduled Inadequately cleaned or sanitized food contact surfaces Moderate Risk
New Ownership High risk vermin infestation High Risk
Routine - Unscheduled Wiping cloths not clean or properly stored or inadequate sanitizer Low Risk

The model

The goal of the application is to predict whether an inspection violation belongs to one of several categories (low/moderate/high risk). The Machine Learning Task to use in this scenario is multiclass classification. The model in this application was trained using Model Builder.

Model Builder is an intuitive graphical Visual Studio extension to build, train, and deploy custom machine learning models.

Model Builder uses automated machine learning (AutoML) to explore different machine learning algorithms and settings to help you find the one that best suits your scenario.

You don't need machine learning expertise to use Model Builder. All you need is some data, and a problem to solve. Model Builder generates the code to add the model to your .NET application.

In this solution, both the RestaurantViolationsML.ConsoleApp and RestaurantViolationsML.Model projects are autogenerated by Model Builder.