Machine Learning with .NET

Getting Started with ML.NET (Regression Analysis)

1 Views Updated 5/4/2026

What is ML.NET?

ML.NET is an open-source, cross-platform machine learning framework for .NET developers. You can use your existing C# or F# skills to integrate ML into your apps locally, without needing Python!

Scenario: Predicting House Prices

We'll use standard regression to predict a value based on input features.


using Microsoft.ML;
using Microsoft.ML.Data;

// Define Data Structures
public class HouseData {
    public float Size { get; set; }
    public float Price { get; set; }
}

public class Prediction {
    [ColumnName("Score")]
    public float Price { get; set; }
}

// Training Logic
var mlContext = new MLContext();
var dataView = mlContext.Data.LoadFromEnumerable(new List { /* Load data */ });
var pipeline = mlContext.Transforms.Concatenate("Features", "Size")
                .Append(mlContext.Regression.Trainers.Sdca(labelColumnName: "Price"));

var model = pipeline.Fit(dataView);
                    
Machine Learning with .NET
1. ML.NET Basics
Getting Started with ML.NET (Regression Analysis)