dotnet / dotnet/skills

[dotnet-ai] ML.NET training and deployment

Open
#229 0 comments 0 reactions 0 assignees View on GitHub
area-ai skill
Dominant language
C#
Stars
5.4k
Forks
415
Avg merge
1d 4h
Merged PRs (30d)
84

Description

## Parent Issue

Part of the `dotnet-ai` plugin proposal: #225

## Summary

Add the `mlnet` skill to the `dotnet-ai` plugin, including three reference files for advanced scenarios.

This skill covers the full ML.NET lifecycle — from data loading through training, evaluation, and deployment. It covers both **classical ML** on structured data (classification, regression, clustering, anomaly detection, recommendation, time-series forecasting) and **deep learning** tasks (image classification, object detection, NER, QA, text classification, sentence similarity) via ML.NET's TorchSharp integration.

## What This Skill Covers

### Classical ML (Built-in Trainers)
- Binary/multiclass classification (SDCA, FastTree, LightGBM)
- Regression
- Clustering (KMeans)
- Anomaly detection (RandomizedPca)
- Recommendation (MatrixFactorization)
- Time-series forecasting (SSA)

### Deep Learning (TorchSharp-Backed, ML.NET 3.0+)
- Image classification
- Object detection
- Text classification
- Named entity recognition (NER)
- Question answering (QA)
- Sentence similarity

### Pipeline & Deployment
- Data loading (CSV, in-memory, DataFrame)
- Feature engineering (text featurization, one-hot encoding, concatenation, normalization)
- Train/test split and evaluation metrics
- Model serialization (`model.zip`)
- `PredictionEnginePool` for thread-safe inference in ASP.NET Core

### Pre-trained Model Consumption
- TensorFlow model scoring via `Microsoft.ML.TensorFlow` (⚠️ pinned to TF 2.3.1)
- ONNX model scoring via `Microsoft.ML.OnnxTransformer`

### AutoML
- Automated model and hyperparameter selection

## Reference Files

| File | Purpose |
|---|---|
| `references/custom-transforms.md` | Four approaches to custom ML.NET pipeline steps: CustomMapping, Facade pattern, Direct ITransformer, Source Contribution |
| `references/dataframe.md` | Using `Microsoft.Data.Analysis.DataFrame` for data preparation before ML.NET training |
| `references/torchsharp.md` | TorchSharp for custom neural network architectures in .NET — standalone from ML.NET. Covers `torch.nn.Module`, training loops, TorchScript loading, relationship to ML.NET's TorchSharp-backed trainers |

## What This Skill Does NOT Cover

- Natural language generation with LLMs (use `meai-chat-integration`)
- Running pre-trained ONNX models standalone without ML.NET (use `onnx-runtime-inference`)
- Custom neural network architectures beyond what ML.NET's built-in trainers provide → `references/torchsharp.md` covers using TorchSharp directly

## Files

```
plugins/dotnet-ai/skills/mlnet/
SKILL.md
references/
custom-transforms.md
dataframe.md
torchsharp.md
tests/dotnet-ai/mlnet/eval.yaml
```

## Eval Scenarios

1. **Binary classification on structured data** — prompt asks to predict customer churn from CSV; expects ML.NET pipeline with SDCA, train/test split, evaluation metrics
2. **Reject LLM for structured classification** — prompt suggests using an LLM for tabular classification; expects redirect to ML.NET with explanation of why it's the better tool

## Key Packages

- `Microsoft.ML` (core)
- `Microsoft.ML.TorchSharp` (deep learning)
- `Microsoft.ML.Recommender` (recommendation)
- `Microsoft.ML.TimeSeries` (time-series)
- `Microsoft.ML.TensorFlow` (TF model scoring — legacy)
- `Microsoft.ML.OnnxTransformer` (ONNX model scoring)

## Dependencies

Requires the plugin scaffold (sub-issue #1) to be merged first.

## Acceptance Criteria

- [ ] SKILL.md covers both classical ML and deep learning tasks
- [ ] TorchSharp-backed trainers are listed with correct API calls
- [ ] TensorFlow support caveat (pinned to TF 2.3.1) is present
- [ ] All three reference files provide actionable guidance
- [ ] `references/torchsharp.md` covers standalone TorchSharp usage for custom architectures
- [ ] eval.yaml has scenarios for classification and LLM redirect

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.