Machine Learning with .NET – Haters Gonna Hate
This blog post is based on my talk at NET Meetup #2 – Exploring the Future of .NET.
The goal of the talk was to explain what machine learning really is and why it makes sense for .NET developers.
What this post covers
In this post I cover:
- A short overview of the AI landscape (Narrow AI, AGI, Super AI)
- What machine learning is and the main learning types
- ML.NET and why it is important for .NET developers
- How the ML.NET pipeline works
- Demo recap: a Patient Length of Stay (LoS) predictor
AI landscape in one slide
Most of what we call “AI” today is Narrow AI (also called Weak AI). These systems are trained to solve one specific task, like recommendations, image recognition, fraud detection, or chatbots.
Strong AI (AGI) and Super AI are still theoretical. AGI would be able to reason and generalize across many tasks like a human. Super AI would go even further and outperform human intelligence.
So when we talk about machine learning in real production systems, we are usually talking about narrow and practical solutions that solve a clear business problem.
What is machine learning?
Machine learning is a part of AI where systems learn from data instead of being fully hard-coded with rules. Based on data, the system can make predictions or decisions.
There are four main types of machine learning:
- Supervised learning — learns from labeled data
- Unsupervised learning — finds patterns in unlabeled data
- Semi-supervised learning — combines a small amount of labeled data with a large amount of unlabeled data
- Reinforcement learning — learns by interacting with an environment and receiving feedback
Meet ML.NET
ML.NET is Microsoft’s machine learning framework for .NET developers. It is open-source, cross-platform, and designed to run directly inside your applications.
You can use it in APIs, console apps, desktop apps, Blazor, MAUI, and more.
Some important points from the talk:
- Created by Microsoft in 2018
- Part of the official .NET ecosystem
- Runs on Windows, Linux, and macOS
- Works with .NET Core, .NET 6+, and .NET Framework
- Used inside Microsoft products like Bing, PowerPoint, Excel, and Azure
- Supports classic ML tasks: classification, regression, recommendations, clustering, anomaly detection, ranking, and NLP
- Can integrate with TensorFlow for image classification
Why machine learning in .NET?
Pros
- You are already using the .NET ecosystem
- The framework is production-ready and supported by Microsoft
- You can build ML features using pure C#
- Easy integration with web, desktop, and mobile apps
Cons
- Smaller community compared to Python ML tooling
- Limited deep learning support out of the box
- Advanced scenarios usually depend on external frameworks like TensorFlow or ONNX
How ML.NET works (pipeline overview)
ML.NET follows a clear and structured pipeline:
- Load data — from CSV files, JSON, databases, or in-memory collections
- Transform data — normalization, text processing, encoding categorical values, etc.
- Choose an algorithm — depending on the problem
- FastTree (regression)
- Matrix Factorization (recommendations)
- SDCA Logistic Regression (binary classification)
- Train the model — fit the model to training data
- Evaluate — measure model quality (accuracy, RMSE, and other metrics)
- Predict — use the trained model on new data
ML.NET also supports AutoML, which can automatically search for the best model and parameters. This is very useful when you are just getting started.
You can work with custom-trained models or pre-trained ONNX models, which means you can reuse models trained outside of .NET and still run them inside your application.
Demo recap: Patient LoS predictor
The demo in the talk was a Patient Length of Stay (LoS) predictor, implemented in C# using ML.NET.
Length of Stay is a regression problem, because we predict a continuous value (number of days). Regression is commonly used for forecasting and understanding how different variables influence the final result.
The main takeaway from the demo was simple: you don’t need Python to start using machine learning. You can build useful and practical ML features directly inside your existing .NET applications.
If you want, I can expand this into a step-by-step tutorial with code examples.
Just tell me which dataset you used and what features you trained the model on.