Deploy deterministic machine learning models for industrial automation with ML.NET integration
The AI ML Integration Connector brings deterministic machine learning capabilities to FrameworX solutions through ML.NET, Microsoft's cross-platform machine learning framework. Unlike probabilistic LLMs, this connector provides consistent, repeatable results suitable for real-time industrial control and monitoring applications.
Industrial Data → FrameworX Tags → ML Models → Predictions
↓ ↑
[Historian] [ML.NET Engine]
↓ ↑
[Training] [Inference]
| Property | Value |
|---|---|
| Name | ML.NET Integration |
| Framework | ML.NET 3.0+ |
| Runtime | .NET 8.0 |
| Model Types | Classification, Regression, Anomaly Detection, Time-Series |
| Configuration | Scripts → Classes |
| Execution | Real-time & Batch |
The built-in AnomalyML Library class uses the SR-CNN algorithm. Other algorithms are available through custom ML.NET pipelines built in Visual Studio.
FrameworX supports three ML integration patterns. Choose the one that fits your use case:
| Pattern | Best For | ML Expertise Needed | Page |
|---|---|---|---|
| AnomalyML Library Class | Real-time anomaly detection on live sensor data. Auto-trains from incoming data — no Visual Studio required. | None | ML.NET Tutorial |
| Pre-trained Models (.zip) | Multi-variable regression, classification, or anomaly detection using models trained offline in Visual Studio. | Intermediate | ML.NET Pre-trained Models Example |
| Model Builder (VS Extension) | Visual Studio Model Builder extension generates ML code and trained models automatically from a dataset. | Beginner-Intermediate | ML.NET Model Builder Example |
Starting out? Use the AnomalyML Library Class. Import it in one click, wire it to your sensor tags, and anomaly detection starts working automatically after ~100 data points.
Create specialized script classes that implement ML.NET models for real-time inference and training.
Learn more: Scripts Classes Reference
FrameworX's event-driven architecture and consistent namespace provide the foundation for ML integration. The Unified Namespace, expression engine, and historian work together to feed sensor data into ML models and deliver predictions back to alarms and displays.
Learn more: AI-Ready by Design
Pre-built examples demonstrate ML integration for industrial scenarios.
Learn more: BottlingLine ML Demo
Alternatively, click New to create a new class manually. Select the Add ML.NET Namespaces checkbox to automatically import all required ML.NET libraries into your class.
Before wiring your ML class to the runtime, create tags in your Unified Namespace to receive the model's outputs. The tags you need depend on the ML task being implemented — a regression model may output a single predicted value, while an anomaly detection model may output a score, a boolean flag, and a baseline. Plan your tag structure to match what your ML class will return.
Follow your UNS folder structure to keep ML outputs organized alongside their source signals.
Wire your ML class to the runtime using one of two approaches:
Multiple data streams: If your ML class tracks state per signal (as with most time-series models), use a separate class instance per stream. Import or create the class multiple times with different names.
For the complete step-by-step pipeline, see the ML.NET Tutorial.
FrameworX ML integration supports all the ML.NET task types. These are the main onesl:
Identify unexpected deviations in sensor data in real time. Implemented using SR-CNN (point anomalies / spikes) or SSA Change Point Detection (gradual shifts, level changes). The AnomalyML Library class uses SR-CNN and is the recommended starting point.
Predict future values of a time-series signal based on historical patterns. Implemented using SSA Forecasting. Useful for anticipating demand, production output, or gradual process trends before they occur. See ProveIt 2026 Expo Example.
Predict a continuous numeric output from one or more input variables. Useful for soft sensors, quality metrics estimation, or remaining useful life prediction. Supported trainers include Linear, Poisson, and FastTree regression.
Categorize process states or outcomes into discrete classes. Supports binary (e.g., pass/fail) and multi-class (e.g., fault type A/B/C) scenarios. Useful for event detection, mode identification, or quality grading.
Group process observations by similarity without labeled training data. Useful for exploratory analysis, operating mode discovery, or segmenting process conditions. Supported via K-Means.
A comprehensive example demonstrating ML integration in a bottling plant:
BottlingLine ML Demo — Complete IoT solution with:
Build your first ML model for anomaly detection:
ML.NET Tutorial — Step-by-step guide covering:
// Cache models in memory (pre-trained model pattern)
private static readonly Dictionary<string, ITransformer> ModelCache = new();
public ITransformer GetModel(string name)
{
if (!ModelCache.TryGetValue(name, out var model))
{
model = mlContext.Model.Load($"Models/{name}.zip", out _);
ModelCache[name] = model;
}
return model;
}
// Batch predictions when possible (pre-trained model pattern)
public double[] BatchPredict(double[][] featureSets)
{
return model.Transform(featureSets).GetColumn<double>("Score");
}
The AnomalyML Library class handles its own model caching internally. These patterns apply to custom pre-trained model implementations.
public string SafePredict(double value)
{
try
{
if (double.IsNaN(value) || double.IsInfinity(value))
return "Invalid Input";
var prediction = model.Predict(value);
@Info.Trace($"ML Prediction: {prediction}");
return prediction.ToString();
}
catch (Exception ex)
{
@Alarm.Create("ML_Error", ex.Message);
return "Prediction Error";
}
}
Track and manage multiple model versions (pre-trained model pattern):
public class ModelManager
{
private readonly MLContext mlContext = new();
public ITransformer LoadModel(string version)
{
var path = $"Models/model_v{version}.zip";
return mlContext.Model.Load(path, out var schema);
}
}
Combine multiple models for improved accuracy (advanced custom pattern):
public double EnsemblePredict(double value)
{
var predictions = new[]
{
anomalyModel.Predict(value),
spikeModel.Predict(value),
changePointModel.Predict(value)
};
// Voting or averaging strategy
return predictions.Average();
}
Ensemble methods require building custom ML pipelines in Visual Studio. This is an advanced pattern not covered by the AnomalyML Library class.
Create domain-specific ML workflows using the ML.NET API directly in Script Classes:
public ITransformer BuildCustomPipeline(IDataView trainingData)
{
var mlContext = new MLContext();
return mlContext.Transforms
.NormalizeMinMax("Temperature")
.Append(mlContext.Regression.Trainers.Sdca())
.Fit(trainingData);
}
Custom pipelines give full control over the ML.NET API but require ML expertise. For most anomaly detection use cases, the AnomalyML Library class is the recommended starting point.
Model not loading (pre-trained models)
.zip file path is correct and accessible at runtimeAnomalyML not detecting anomalies
ModelReady tag is true — if false, the model is still training (needs ~100 data points)_threshold (lower = more sensitive) or _windowSize (lower = more reactive)Poor prediction accuracy
Performance issues
Integration errors
| Aspect | ML.NET Integration | AI Runtime (LLM) |
|---|---|---|
| Output Type | Deterministic | Probabilistic |
| Use Case | Control & Monitoring | Assistance & Analysis |
| Response Time | Microseconds | Seconds |
| Training | Required (auto or manual) | Pre-trained |
| Consistency | 100% Repeatable | Variable |
| Suitable for Control | Yes | No |
| Runs Offline | Yes | Requires cloud/API |
Both approaches complement each other. Use ML.NET for real-time control loops and alarms. Use AI Runtime for operator assistance, natural language queries, and solution analysis. See [AI Integration](AI Integration) for the full AI feature overview.
The AI ML Integration Connector provides industrial-grade machine learning capabilities that maintain the determinism and reliability required for automation systems, while enabling advanced analytics and predictive capabilities that improve operational efficiency.