MLoop.Extensibility
0.51.0
dotnet add package MLoop.Extensibility --version 0.51.0
NuGet\Install-Package MLoop.Extensibility -Version 0.51.0
<PackageReference Include="MLoop.Extensibility" Version="0.51.0" />
<PackageVersion Include="MLoop.Extensibility" Version="0.51.0" />
<PackageReference Include="MLoop.Extensibility" />
paket add MLoop.Extensibility --version 0.51.0
#r "nuget: MLoop.Extensibility, 0.51.0"
#:package MLoop.Extensibility@0.51.0
#addin nuget:?package=MLoop.Extensibility&version=0.51.0
#tool nuget:?package=MLoop.Extensibility&version=0.51.0
MLoop.Extensibility
Optional extensibility API for MLoop - enables code-based customization of AutoML pipeline.
Overview
MLoop.Extensibility provides interfaces for extending MLoop's AutoML capabilities through:
- Hooks: Execute custom logic at lifecycle points (pre-train, post-train, etc.)
- Custom Metrics: Optimize for business outcomes instead of generic accuracy
Features
- ✅ Completely Optional: Works without any extensions
- ✅ Zero-Overhead: < 1ms impact when not used
- ✅ Type-Safe: Full C# type system with IDE support
- ✅ Auto-Discovery: Convention-based discovery from filesystem
Quick Start
Install Package
dotnet add package MLoop.Extensibility
Create a Hook
A hook lives in .mloop/scripts/hooks/<stage>/ (pre-train, post-train, pre-predict, post-evaluate).
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using MLoop.Extensibility.Hooks;
public class DataValidationHook : IMLoopHook
{
public string Name => "Data Validation";
public Task<HookResult> ExecuteAsync(HookContext ctx)
{
// The pre-train stage reads a file: its path is in the hook's metadata.
var dataFile = ctx.GetMetadata<string>("DataFile", "");
var rowCount = File.Exists(dataFile)
? File.ReadLines(dataFile).Count(line => !string.IsNullOrWhiteSpace(line)) - 1 // minus the header
: 0;
if (rowCount < 100)
return Task.FromResult(HookResult.Abort($"Insufficient data: {rowCount} rows, need at least 100"));
ctx.Logger.Info($"Data validation passed: {rowCount} rows");
return Task.FromResult(HookResult.Continue());
}
}
Create a Custom Metric
A metric lives in .mloop/scripts/metrics/. It is computed over the held-out rows after training and recorded with the run's metrics — a report, not an optimization target.
using System;
using System.Threading.Tasks;
using MLoop.Extensibility.Metrics;
public class ProfitMetric : IMLoopMetric
{
public string Name => "Expected Profit";
public string Description => "100 per true positive, -50 per false positive";
public Task<MetricResult> CalculateAsync(MetricContext ctx)
{
var predicted = (bool[])ctx.Predictions; // binary-classification: bool[]
var actual = (bool[])ctx.Labels;
double profit = 0;
for (var i = 0; i < predicted.Length; i++)
if (predicted[i]) profit += actual[i] ? 100 : -50;
return Task.FromResult(new MetricResult { Name = Name, Value = profit });
}
}
API Reference
Interfaces
IMLoopHook- Lifecycle hook interfaceIMLoopMetric- Custom metric interface
Context Classes
HookContext- Provides data and ML context to hooksMetricContext- Provides predictions for metric calculationHookResult- Return value for hooks (Continue or Abort)
Logger
ILogger- Logging interface for hook output
Documentation
For complete documentation, see:
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.ML (>= 5.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MLoop.Extensibility:
| Package | Downloads |
|---|---|
|
MLoop.Core
MLoop Core - training (a trainer search over ML.NET trainers), prediction and model management on ML.NET |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.51.0 | 44 | 11/16/2026 |
| 0.50.0 | 103 | 11/8/2026 |
| 0.49.1 | 106 | 11/6/2026 |
| 0.49.0 | 115 | 11/1/2026 |
| 0.48.0 | 111 | 10/30/2026 |
| 0.47.0 | 113 | 10/27/2026 |
| 0.46.0 | 111 | 10/26/2026 |
| 0.45.1 | 111 | 10/24/2026 |
| 0.45.0 | 116 | 10/23/2026 |
| 0.44.0 | 114 | 10/23/2026 |
| 0.43.0 | 112 | 10/23/2026 |
| 0.42.0 | 124 | 10/22/2026 |
| 0.41.0 | 131 | 10/21/2026 |
| 0.40.0 | 123 | 10/21/2026 |
| 0.39.0 | 123 | 10/21/2026 |
| 0.38.0 | 118 | 10/21/2026 |
| 0.37.1 | 120 | 10/21/2026 |
| 0.37.0 | 117 | 10/21/2026 |
| 0.36.0 | 116 | 10/20/2026 |
| 0.35.0 | 128 | 10/20/2026 |