Create machine learning models that run inside FrameworX using Script Classes with ML.NET. The AI writes the C# code, connects it to live tags, creates output tags for predictions, and configures model persistence — all within the FrameworX scripting engine.
...
Architecture
| No Format |
|---|
Input Tags ???-> Script Class (ML.NET) ???-> Output Tags ?| ?| ?| Live data Train / Predict Predictions, scores, from UNS Model persisted to anomaly flags, forecasts solution folder ??? Alarms / Dashboard |
...
Category | Items |
|---|---|
Tools |
|
Tables |
|
...
...
User Goal | Suggested Algorithm |
|---|---|
Predictive maintenance — single sensor | Anomaly Detection (Spike) |
Predictive maintenance — multiple sensors | Binary Classification |
Detect sensor failures / outliers | Anomaly Detection (Spike) |
Detect gradual drift or process shift | Anomaly Detection (ChangePoint) |
Predict future values | Time-Series Forecasting (SSA) |
Energy / consumption modeling | Regression |
Quality control pass/fail | Binary Classification |
Fault prediction yes/no | Binary Classification |
Production / demand forecasting | Time-Series Forecasting (SSA) |
Process output from multiple inputs | Regression |
Information | Why |
|---|---|
Input tag path(s) | The model reads from these tags |
ML algorithm | Determines the ML.NET pipeline to generate |
Output semantics | What the predictions mean (anomaly score, forecast value, etc.) |
...
...
System.Math / CpuMath error. Instruct the user:Only proceed if the user confirms this is already set."Before starting the runtime, please confirm your solution is set to Multiplatform: Solution → Settings → Target Platform = Multiplatform, then Product → Modify."
designer_action('start_runtime') if the user explicitly requests it.MinTrainingSize data points before predictions beginLastPrediction timestamp is updating...
Mistake | Why It Happens | How to Avoid |
|---|---|---|
Missing ML.NET namespaces | Used | Always set |
| Called | Always use |
Tag reference without | Confusing with Expression syntax | Always |
Model lost on restart | SaveModel or LoadModel not wired up | Always include |
Training on every call | No guard for already-trained model | Use |
Wrong data types | ML.NET expects | Cast with |
Expression ObjectName missing | Confusing tag path vs expression binding | Expression ObjectName needs |
Non-empty | Expression tries to assign void return to a tag | Leave |
Used | Field does not exist — silently ignored, expression never fires | Use |
Class is document object | Partial write replaces entire class | Always read-modify-write for existing classes |
|
| Never assign a raw |
| Tasks and Classes compile in the same pass; if the Class isn't ordered first, Tasks that reference it fail | Set |
| Solution is targeting .NET 4.8 (Windows platform) — ML.NET CpuMath trainers (FastTree, SSA) are incompatible with .NET 4.8 | Go to Solution → Settings → Target Platform → Multiplatform, then Product → Modify to rebuild. This is required for all ML.NET solutions. |
Scenario | ML Task | Trigger | Notes |
|---|---|---|---|
Single sensor, detect outliers/spikes | Anomaly Detection (Spike) | Expression OnChange | Fast, one tag in / flags out |
Single sensor, detect gradual drift | Anomaly Detection (ChangePoint) | Expression OnChange | AI picks this variant when user mentions "drift" or "regime change" |
Single sensor, predict future values | Forecasting (SSA) | Expression OnChange or Periodic | Outputs forecast + confidence bounds |
Multiple sensors → one continuous value | Regression | Task Periodic | Energy prediction, process modeling |
Multiple sensors → yes/no | Binary Classification | Task Periodic | Fault prediction, quality pass/fail |
User says "predictive maintenance" + single sensor | Anomaly Detection | Expression OnChange | Most common PdM entry point |
User says "predictive maintenance" + multiple sensors | Binary Classification | Task Periodic | Predicts failure from combined inputs |
User says "quality control" | Binary Classification | Task Periodic | Pass/fail prediction |
User says "forecast" or "predict demand" | Forecasting (SSA) | Expression OnChange or Periodic | Time-series based |
User says "you decide" + single sensor | Anomaly Detection | Expression OnChange | Safest default for monitoring |
User says "you decide" + multiple sensors | Regression | Task Periodic | Most general multi-input approach |