Machine Learning C# .NET

ML.NET (Microsoft.ML) in C# – Machine Learning for .NET Developers

ML.NET in C#: machine learning for .NET developers without Python. Regression, classification, preprocessing, visualization, and model deployment.

Course description

ML.NET in C#: machine learning integrated into your .NET stack

Want to integrate machine learning into your .NET applications without having to learn Python, TensorFlow, or scikit-learn? ML.NET is Microsoft's answer: a native C# library that lets you train, evaluate, and deploy predictive models directly in your project. In this course we build everything step by step — from the first linear regression through binary classification, advanced preprocessing, and result visualization.

What You'll Learn

  • What linear regression is and when to use it in real-world contexts
  • Create a C# project with ML.NET and prepare data with the right classes
  • Train a model and use the Prediction Engine for real-time predictions
  • Measure training times with Stopwatch and optimize performance
  • Apply everything in a complete exercise: predicting solar panel revenue
  • Save a trained model as a ZIP file and reload it without retraining
  • Visualize data and regression line with ScottPlot (scatter plot + regression)
  • Build a binary classifier for automatic yes/no decisions
  • Apply binary classification to predictive maintenance with probability calculation
  • Extend to multivariate regression with multiple independent variables
  • Clean and transform data with Transforms: missing value handling, custom mapping, one-hot encoding
  • Apply Min-Max normalization and convert data types in the pipeline
  • Evaluate the model with fundamental metrics: R², MAE, and RMSE

ML Without Changing Your Stack

The advantage of ML.NET is not just technical — it is strategic. If your team already works in C# and .NET, adding ML.NET means no new language, no separate environment, no complex integration. Models live inside your applications, with the same conventions and tooling you already know.

Who This Course Is For

Designed for .NET developers who want to explore machine learning without leaving the C# ecosystem. No prior ML experience is required, but a solid grasp of C# and .NET is needed.

Lessons list

Let's discover what ML.NET is — Microsoft's machine learning library for C# — and understand when to use linear regression in real-world scenarios: predicting continuous values, economic estimates, and trend analysis.

Guarda lezione

Let's configure a C# project with the Microsoft.ML package and structure the input and output classes to correctly represent the data we'll pass to the training pipeline.

Guarda lezione

Let's train our first linear regression model with ML.NET: I'll build the pipeline using the SDCA algorithm, load the dataset, and start the training in C#, observing what the process produces.

Guarda lezione

Let's see how to use ML.NET's Prediction Engine to get a real-time prediction from new input data: we'll create the engine, build the input object, and read the predicted value.

Guarda lezione

I'll show you how to measure ML.NET model training time using C#'s Stopwatch class, so you can compare different algorithms and understand the impact of preprocessing on overall performance.

Guarda lezione

Let's work through a complete end-to-end exercise: applying linear regression with ML.NET to predict the economic revenue generated by solar panels, from data loading to final predictions on new values.

Guarda lezione

I'll show you how to save a trained ML.NET model to disk as a ZIP file using DataOperationsCatalog, and how to reload it later — avoiding the need to retrain every time the application starts.

Guarda lezione

I'll explain how to check at startup whether an ML.NET model already exists on disk: if it does, we reload it; otherwise we train and save it. A foundational pattern for production .NET applications.

Guarda lezione

Let's visualise training data with the ScottPlot library in C#: I'll create a scatter plot to visually analyse the distribution of data points and relationships between variables before evaluating the model.

Guarda lezione

Let's add the linear regression line to the ScottPlot chart by computing predicted values across the full input range, comparing it with real data to visually validate the quality of the approximation.

Guarda lezione

Let's build a binary classifier with ML.NET in C# to automate simple yes/no decisions: I'll choose the algorithm, define the classes, train the model, and verify the predictions.

Guarda lezione

Let's apply ML.NET binary classification to a real predictive maintenance case: the model predicts whether a component will fail and also returns the probability associated with the prediction.

Guarda lezione

Let's extend the model to multiple independent variables with ML.NET multivariate regression: I'll add features to the pipeline, retrain the model, and compare the quality of the estimates obtained.

Guarda lezione

Let's clean and transform data with ML.NET Transforms in the Bus project: handling missing values with ReplaceMissingValues, custom mapping for derived columns, and one-hot encoding for categorical variables.

Guarda lezione

Let's apply ML.NET's custom mapping to create personalised data transformations, generating new derived columns with arbitrary C# logic inserted directly into the preprocessing pipeline.

Guarda lezione

I'll explain one-hot encoding in ML.NET and how to convert categorical variables — both textual and numeric — into sparse binary vectors that machine learning algorithms can process correctly.

Guarda lezione

Let's look at Min-Max normalisation in ML.NET to bring all numeric features into the same range, and how to convert data types within the pipeline before passing to training.

Guarda lezione

Let's train the final ML.NET linear regression model on the already-cleaned, normalised, and transformed bus dataset, verifying that the entire pipeline works correctly from CSV reading to prediction.

Guarda lezione

Let's learn how to evaluate ML.NET model quality with three fundamental metrics: R² (explained variance), MAE (mean absolute error), and RMSE (root mean squared error), and understand how to interpret them.

Guarda lezione
Giovanni Pace

Giovanni Pace

Ingegnere Informatico · Pratola Peligna

  • 107 Courses
About the teacher

Sono un ingegnere informatico con oltre 15 anni di esperienza nel settore ICT. Mi occupo di sviluppo software, cybersecurity, data science e intelligenza artificiale, con particolare attenzione all’innovazione e all’automazione dei processi aziendali. Da anni svolgo anche attività di docenza e formazione, creando percorsi pratici e coinvolgenti su programmazione, DevOps, AI e sicurezza informatica.

This course includes

  • Lessons 19
  • Duration 3h 53m
  • Difficulty intermedio
  • Language it
  • Certificate No

Recently viewed