ML.NET in C#: machine learning for .NET developers without Python. Regression, classification, preprocessing, visualization, and model deployment.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Ingegnere Informatico · Pratola Peligna
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.
Prosperous understood Middletons in conviction an uncommonly do. Supposing so be resolving breakfast am or perfectly.
Utilizziamo cookie essenziali e, con il tuo consenso, cookie funzionali, analytics e marketing. Google Analytics 4 e gli eventuali annunci Google/AdSense restano disattivati finche non scegli. Consulta Privacy Policy e Cookie Policy.
Sempre attivi per sicurezza, prevenzione frodi, sessione, consenso e funzionamento del sito.
Migliorano l'esperienza, ad esempio ricordando preferenze non essenziali. Non usati per profilazione pubblicitaria.
Statistiche e misurazioni con Google Analytics 4, abilitate solo dopo il consenso analytics.
Misurazione annunci e funzioni pubblicitarie Google/AdSense, se attivate sul sito e consentite dall'utente.
Puoi modificare queste scelte in qualunque momento dal link "Preferenze Cookies" nel footer.