Deploy deterministic machine learning models for industrial automation with ML.NET integration

  • Name: ML.NET
  • Version: 1.0.0.1
  • Runtime: .NET 2.0 (Multiplatform)
  • Configuration:
    • Scripts / Tasks


Overview

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.

Key Capabilities

  • Deterministic Predictions — Consistent outputs for identical inputs, essential for industrial processes
  • Real-time Anomaly Detection — Identify deviations in sensor data as they occur using SR-CNN
  • Predictive Maintenance — Forecast equipment failures before they happen
  • Quality Prediction — Anticipate product quality based on process parameters
  • Time-Series Analysis — Pattern recognition in historical and streaming data

Integration Architecture

Industrial Data → FrameworX Tags → ML Models → Predictions
                        ↓                ↑
                   [Historian]      [ML.NET Engine]
                        ↓                ↑
                   [Training]       [Inference]

Technical Specifications

PropertyValue
NameML.NET Integration
FrameworkML.NET 3.0+
Runtime.NET 8.0
Model TypesClassification, Regression, Anomaly Detection, Time-Series
ConfigurationScripts → Classes
ExecutionReal-time & Batch

Supported ML Algorithms

  • Anomaly Detection: SR-CNN (default in AnomalyML Library class), SSA, IsolationForest
  • Time-Series: SSA Forecasting, ARIMA
  • Regression: Linear, Poisson, FastTree
  • Classification: Binary & Multi-class
  • Clustering: K-Means, DBSCAN

The built-in AnomalyML Library class uses the SR-CNN algorithm. Other algorithms are available through custom ML.NET pipelines built in Visual Studio.



Which ML Pattern Should I Use?

FrameworX supports three ML integration patterns. Choose the one that fits your use case:

PatternBest ForML Expertise NeededPage
AnomalyML Library ClassReal-time anomaly detection on live sensor data. Auto-trains from incoming data — no Visual Studio required.NoneML.NET Tutorial
Pre-trained Models (.zip)Multi-variable regression, classification, or anomaly detection using models trained offline in Visual Studio.IntermediateML.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-IntermediateML.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.



Implementation Components

1. ML Script Classes

Create specialized script classes that implement ML.NET models for real-time inference and training.

Learn more: Scripts Classes Reference

2. AI-Ready Architecture

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

3. Solution Examples

Pre-built examples demonstrate ML integration for industrial scenarios.

Learn more: BottlingLine ML Demo


Configuration Workflow

Step A: Import or Create ML Script Class

  1. Navigate to Scripts → Classes
  2. Click New and select Import from Library
  3. Choose the desired ML class from the library
  4. Click OK

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.

Step B: Create ML Output Tags

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.

Step C: Configure Expressions or Scripts

Wire your ML class to the runtime using one of two approaches:

  • Expressions — Create expressions in Scripts → Expressions triggered by your source tags. Each expression calls a method on your ML class and writes the result to an output tag.
  • Script Tasks — Create a Script Task to call your ML class on a scheduled interval or in response to an event. This is useful when the ML logic involves multiple steps, stateful processing, or outputs that need to be computed together.

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.


Deployment Patterns

FrameworX ML integration supports all the ML.NET task types. These are the main onesl:

Anomaly Detection

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.

Forecasting

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.

Regression

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.

Classification

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.

Clustering

Group process observations by similarity without labeled training data. Useful for exploratory analysis, operating mode discovery, or segmenting process conditions. Supported via K-Means.


Complete Solution Example

BottlingLine ML Demo

A comprehensive example demonstrating ML integration in a bottling plant:

BottlingLine ML Demo — Complete IoT solution with:

  • Data collection from field devices
  • MQTT broker integration
  • SQLite historization
  • SR-CNN anomaly detection using AnomalyML Library class
  • Real-time dashboard visualization

Key Features Demonstrated

  • Value simulator for testing
  • MQTT publishing to cloud
  • ML anomaly detection on production metrics
  • Multi-platform displays (desktop/mobile/tablet)
  • Four-expression wiring pattern (Score, IsAnomaly, Baseline, ModelReady)

Getting Started

Quick Start Tutorial

Build your first ML model for anomaly detection:

ML.NET Tutorial — Step-by-step guide covering:

  • Value simulator setup
  • AnomalyML Library class import
  • ML output tag creation
  • Expression configuration (4-expression pattern)
  • Real-time testing and warmup behavior

Prerequisites

  1. Tags created in Unified Namespace
  2. Data source configured (simulator or real devices)
  3. Historian enabled (recommended for training data review, not required for AnomalyML auto-training)
  4. Script Classes module licensed

Best Practices

Model Training

  • AnomalyML auto-training — The Library class trains automatically from the first ~100 data points. No manual intervention needed.
  • Pre-trained models — Ensure sufficient historical data (minimum 1,000 samples). Use cross-validation on holdout datasets.
  • Feature Engineering — For multi-variable models, select relevant process variables that correlate with the target.
  • Regular Retraining — For pre-trained models, schedule periodic retraining to account for process drift. AnomalyML adapts continuously.

Performance Optimization

// 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.

Error Handling

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";
    }
}


Advanced Features

Model Versioning

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);
    }
}

Ensemble Methods

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.

Custom ML Pipelines

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.



Troubleshooting

Model not loading (pre-trained models)

  • Verify model .zip file path is correct and accessible at runtime
  • Check .NET runtime version compatibility
  • Ensure ML.NET NuGet assemblies are referenced in NamespaceDeclarations

AnomalyML not detecting anomalies

  • Check that ModelReady tag is true — if false, the model is still training (needs ~100 data points)
  • Verify sensor data is actually changing (flatline data won't trigger anomalies)
  • Adjust _threshold (lower = more sensitive) or _windowSize (lower = more reactive)
  • Confirm all four expressions are configured and the Score expression executes first

Poor prediction accuracy

  • Increase training data quantity (pre-trained models: minimum 1,000 samples)
  • Review feature selection — irrelevant variables add noise
  • Adjust model hyperparameters
  • Check for data drift (process has changed since training)

Performance issues

  • Cache trained models in memory (see Performance Optimization above)
  • Use batch predictions where possible for non-real-time analysis
  • Monitor memory usage with large models
  • The AnomalyML Library class is optimized for single-sensor real-time use

Integration errors

  • Verify Script Class build status (check for compile errors in Designer)
  • Check tag names and types match between expressions and UNS
  • Ensure expressions are configured with correct TriggerTag
  • Review runtime logs for exceptions: Monitor → Runtime Logs

ML.NET vs AI Runtime (LLM) Comparison

AspectML.NET IntegrationAI Runtime (LLM)
Output TypeDeterministicProbabilistic
Use CaseControl & MonitoringAssistance & Analysis
Response TimeMicrosecondsSeconds
TrainingRequired (auto or manual)Pre-trained
Consistency100% RepeatableVariable
Suitable for ControlYesNo
Runs OfflineYesRequires 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.


Related Documentation


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.


In this section...