ML.NET Tutorial - Get started in 10 minutes

Download and install

Download and install Visual Studio 2022.

Download Visual Studio 2022

During installation, the .NET desktop development workload should be selected along with the optional ML.NET Model Builder component. Using the link above should preselect all the prerequisites correctly, as shown on the following image:

Model Builder component in Visual Studio Installer.

Already have Visual Studio 2022?

If you already have Visual Studio 2022, ensure it's up to date and has the required workload installed:

  • Select the Windows key, type Visual Studio Installer, and press Enter.
  • If prompted, allow the installer to update itself.
  • If an update for Visual Studio 2022 is available, an Update button will be shown. Select it to update before modifying the installation. We recommend using the latest Visual Studio 2022 version for this tutorial.
  • Find your Visual Studio 2022 installation and select Modify.
  • Select .NET desktop development and make sure ML.NET Model Builder is selected on the right pane. Select the Modify button.

Upgrade to the latest version of Model Builder

Once you've enabled ML.NET Model Builder in Visual Studio, download and install the latest version.

Download the latest version of Model Builder

After downloading, install the extension by double clicking the .vsix file.

Check for Visual Studio updates

This tutorial is optimized for the latest version of Visual Studio. If you already have Visual Studio 2022, you can check for updates:

  • Select the Windows key, type Visual Studio Installer, and press Enter.
  • If prompted, allow the installer to update itself.
  • If an update is available, your Visual Studio 2022 installation will have an Update button. Select it to update.

Install .NET SDK

To build .NET apps, you need to download and install the .NET 8 SDK (Software Development Kit).

Download .NET 8 SDK x64 (Intel)
Download .NET 8 SDK Arm64 (Apple Silicon)

If you're on a Mac with an Apple M1 or M2 chip, you need to install the Arm64 version of the SDK.

Install ML.NET CLI

The ML.NET command-line interface (CLI), provides tools for building machine learning models with ML.NET.

Note: Currently, ML.NET CLI is in Preview and only supports the latest LTS version of the .NET SDK (.NET 8).

For the installation steps, we recommend you use a Bash console. Since the default for macOS is a zsh console, you can create a singular instance by opening up a new terminal and running the command below.

Terminal
bash

FOR x64 MACHINES - Run the following command:

Terminal
dotnet tool install -g mlnet-linux-x64

FOR ARM64 CHIP ARCHITECTURES - Run the following command instead:

Terminal
dotnet tool install -g mlnet-linux-arm64

If the tool installs successfully, you should see the following output message where [arch] is the chip architecture:

Terminal
You can invoke the tool using the following command: mlnet
Tool 'mlnet-linux-[arch]' (version 'X.X.X') was successfully installed.
Terminal
dotnet tool install -g mlnet-osx-x64

FOR ARM64 CHIP ARCHITECTURES - Run the following command instead:

Terminal
dotnet tool install -g mlnet-osx-arm64

If the tool installs successfully, you should see an output message where [arch] is the chip architecture similar to the following:

Terminal
You can invoke the tool using the following command: mlnet
Tool 'mlnet-osx-[arch]' (version 'X.X.X') was successfully installed.

Note: If you're using a console other than Bash (for example, zsh, which is the new default for macOS), then you'll need to give mlnet executable permissions and include mlnet to the system path. Instructions on how to do this should appear in the terminal when you install mlnet (or any global tool). In general, the following command should work for most systems: chmod +x [PATH-TO-MLNET-CLI-EXECUTABLE]

If you see instructions similar to the one below, run them in your terminal.

Terminal
cat << \EOF >> ~/.zprofile
#Add .NET Core SDK tools
export  PATH="$PATH:~/.dotnet/tools"
EOF

Alternatively, you can try using the following command to run the mlnet tool:

Terminal
~/.dotnet/tools/mlnet

If the command still gives you an error, use the I ran into an issue button below to report the issue and get help fixing the problem.

Continue