Scoring new data
You score your own data, on your own machine. The service trains models; it does not run them for you, and your operational data never has to leave your network a second time.
What you need
The model archive from your dashboard, and a Python environment. Not TensorFlow — the model ships as ONNX, so scoring needs a runtime rather than the framework that trained it.
unzip your-model.zip -d model/
pip install -r requirements.txt # numpy, pandas, onnxruntime
python score_anomalies.py model/ new_data.csv
Two arguments: the unpacked model directory, and the CSV to score.
The example bundle has a pretrained model and a data file with faults already in it, so you can watch the whole thing work before pointing it at your own data.
The script that comes with a model always matches it. Each model records a
format_version in its meta.json, and the copy of the script packaged beside
it is the one that reads that version. Run a newer script against an older model
and it refuses rather than misreading — it names both versions and stops.
If that happens, every published version of the script stays downloadable from
the tutorial page, listed by format version. Take the one matching your
model's format_version, not the newest.
The input file
The same shape as the file you trained on: a timestamp first, the same columns, all numeric. The script resamples and transforms it exactly as training did — that is why the two must agree. A column missing, renamed or in a different unit produces confident output that means nothing.
What the script actually does
Scoring is not a call to predict(). The full path is:
- load the CSV and resample to the 15-minute grid
- difference any counter columns to per-interval change
- add the four sin/cos time features
- scale using the arrays in
meta.json - build 16-step windows
- run the ONNX model
- take a weighted mean absolute error on the last step of each window
- compare against the threshold, and each channel against its own bound
- apply the persistence filter and group what remains
- run the model-free flatline check
Every constant in that path comes from meta.json rather than from the script,
so a model trained today scores correctly with a script shipped next year.
Why meta.json matters
It is the contract, and it is plain JSON you can read: each column's kind, role and transform, the scaler as two arrays of numbers, the window size, the threshold and how it was calibrated, and the per-channel weights.
Deliberately no pickled objects. A pickle is executable content, and asking users to deserialise one from a web service is asking them to run whatever it contains. It would also break across library versions, which is a poor trade for a file meant to last.
Do not skip the cleaning
The script does not drop rows the way training does. Dropping rows here would silently discard the very intervals you are investigating and shift every subsequent window — so gaps are filled rather than removed, and the output lines up with your input.
Infinite values are treated as missing and filled the same way, as training did. The script prints a warning naming the columns and the count, because a filled interval is one the model did not actually observe.
Using it in your own context
The script prints what it finds. To act on it, import the two functions rather than parsing the output:
import pandas as pd
from score_anomalies import score, find_anomalies, find_flatlines
frame = pd.read_csv("new_data.csv", index_col=0, parse_dates=True)
scores, meta = score("model/", frame)
periods = find_anomalies(scores, meta)
flatlines = find_flatlines(frame, meta)
Each period carries its start, end, peak score and the channel responsible. That is enough to raise a ticket, write a row to a database, or post to whatever your site already uses — which is the point of shipping the model rather than a dashboard.
Run the flatline check too, not instead: it finds what the model cannot, and the model finds what it cannot.