ML.NET Tutorial - Get started in 10 minutes

Create your app

Open Visual Studio and create a new .NET console app:

  1. Select Create a new project from the Visual Studio 2022 start window.
  2. Select the C# Console App project template.
  3. Screenshot of Visual Studio start screen.

  4. Change the project name to myMLApp.
  5. Make sure Place solution and project in the same directory is unchecked.
  6. Screenshot of Visual Studio project configuration screen.

  7. Select the Next button.
  8. Select .NET 8.0 (Long Term support) as the Framework.
  9. Select the Create button. Visual Studio creates your project and loads the Program.cs file.

Add machine learning

  1. Right-click on the myMLApp project in Solution Explorer and select Add > Machine Learning Model.

    Screenshot of Visual Studio showing the Machine Learning Model selected.

  2. In the Add New Item dialog, make sure Machine Learning Model (ML.NET) is selected.
  3. Change the Name field to SentimentModel.mbconfig and select the Add button.

    Add New Item dialog showing Machine Learning Model (ML.NET) selected and SentimentModel.mbconfig as the file name.

A new file named SentimentModel.mbconfig is added to your solution and the Model Builder UI opens in a new docked tool window in Visual Studio. The mbconfig file is simply a JSON file that keeps track of the state of the UI.

Model Builder will guide you through the process of building a machine learning model in the following steps.

In your terminal, run the following commands:

Terminal
mkdir myMLApp
cd myMLApp

The mkdir command creates a new directory named myMLApp, and the cd myMLApp command puts you into the newly created app directory.

Your model training code will be generated in the upcoming steps.

Continue