ML.NET is a cross-platform open-source machine learning framework which makes machine learning accessible to .NET developers.
ML.NET allows .NET developers to develop their own models and infuse custom machine learning into their applications, using .NET, even without prior expertise in developing or tuning machine learning models.
Automated machine learning (automated ML) builds high quality machine learning models for you by automating feature engineering, model, and hyperparameter selection. Bring a dataset that you want to build a model for, automated ML will give you a high quality machine learning model that you can use for predictions.
If you are new to Data Science, AutoML will help you get jumpstarted by simplifying machine learning model building. It abstracts you from needing to perform feature engineering, model selection, hyperparameter selection and in one step creates a high quality trained model for you to use.
If you are an experienced data scientist, AutoML will help increase your productivity by intelligently performing the feature engineering, model, and hyperparameter selection for your training and generates high quality models much more quickly than manually specifying several combinations of the parameters and running training jobs. AutoML provides visibility and access to all the training jobs and the performance characteristics of the models to help you further tune the pipeline if you desire.
ML.NET runs on Windows, Linux, and macOS using .NET Core, or Windows using .NET Framework. 64 bit is supported on all platforms. 32 bit is supported on Windows, except for TensorFlow, LightGBM, and ONNX related functionality.
First, ensure you have installed .NET Core 2.1 or later. ML.NET also works on the .NET Framework 4.6.1 or later, but 4.7.2 or later is recommended.
Once you have an app, you can install the ML.NET AutoML NuGet package from the .NET Core CLI using:
dotnet add package Microsoft.ML.AutoML
or from the NuGet package manager:
Install-Package Microsoft.ML.AutoML
Or alternatively, you can add the Microsoft.ML.AutoML package from within Visual Studio's NuGet package manager or via Paket.
Daily NuGet builds of the project are also available in our MyGet feed:
To build ML.NET AutoML from source please visit our developers guide.
Debug | Release | |
---|---|---|
Linux | ||
macOS | ||
Windows x64 | ||
Windows x86 | ||
Core 3.0 |
We welcome contributions! Please review our contribution guide.
Please join our community on Gitter
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the .NET Foundation Code of Conduct.
Here's an example of code to automatically train a model to predict sentiment from text samples.
(Caution: The example that follows is very much a work in progress. Our API is in flux at the moment.)
using System;
using Microsoft.ML;
using Microsoft.ML.Auto;
namespace Samples
{
public static class Benchmarking
{
const string DatasetName = "DatasetName";
const string Label = "Label";
const string DatasetPathPrefix = @"C:\Datasets\";
static readonly string TrainDataPath = $"{DatasetPathPrefix}{DatasetName}_train.csv";
static readonly string ValidationDataPath = $"{DatasetPathPrefix}{DatasetName}_valid.csv";
static readonly string TestDataPath = $"{DatasetPathPrefix}{DatasetName}_test.csv";
public static void Run()
{
var context = new MLContext();
var columnInference = context.Data.InferColumns(TrainDataPath, Label, true);
var textLoader = context.Data.CreateTextReader(columnInference);
var trainData = textLoader.Read(TrainDataPath);
var validationData = textLoader.Read(ValidationDataPath);
var testData = textLoader.Read(TestDataPath);
var autoFitResult = context.BinaryClassification.AutoFit(trainData, Label, validationData, settings:
new AutoFitSettings()
{
StoppingCriteria = new ExperimentStoppingCriteria()
{
MaxIterations = 100,
TimeOutInMinutes = 24 * 60
}
});
var model = autoFitResult.BestPipeline.Model;
var scoredTestData = model.Transform(testData);
var testDataMetrics = context.BinaryClassification.EvaluateNonCalibrated(scoredTestData);
Console.WriteLine(testDataMetrics.Accuracy);
Console.ReadLine();
}
}
}
Now from the model we can make inferences (predictions):
var predictionEngine = model.CreatePredictionEngine<SentimentData, SentimentPrediction>(mlContext);
var prediction = predictionEngine.Predict(new SentimentData
{
SentimentText = "Today is a great day!"
});
Console.WriteLine("prediction: " + prediction.Prediction);
A cookbook that shows how to use these APIs for a variety of existing and new scenarios can be found here.
We have a repo of samples that you can look at.
ML.NET is licensed under the MIT license.
ML.NET is a .NET Foundation project.
There are many .NET related projects on GitHub.
- .NET home repo - links to 100s of .NET projects, from Microsoft and the community.