Charts
Machine learning
Evaluate classifiers and models: confusion matrix, ROC, calibration, training curves and embeddings.
Each chart below is drawn live from the data of its example. All kinds: Chart types.
Confusion Matrix
A Confusion Matrix chart drawn by the engine from the data of the example below.
Actual against predicted classes of a classifier: which classes it confuses with which.
Data. Two columns with the actual and the predicted class (text or numbers), one row per case.
Example
// Classifier.csv, 400 rows:
// actual,predicted
// Wear,Misalign
// Misalign,Misalign
// Normal,Normal
// …
await engine.datasets.addText(await file.text(), 'Classifier.csv')
const chart = engine.charts.add('confusion', {
title: 'Fault classifier',
settings: { cfActualCol: 'actual', cfPredictedCol: 'predicted', cfNormalize: true },
})
engine.charts.mount(chart, document.getElementById('chart')!)Settings
| Name | Type | Description |
|---|---|---|
cfActualCol | stringDefault: '' | The true class. |
cfPredictedCol | stringDefault: '' | The predicted class. |
cfNormalize | booleanDefault: false | Show each row as fractions of its actual class. |
ROC Curve
A ROC Curve chart drawn by the engine from the data of the example below.
How well a score separates two classes at every threshold: the ROC curve (with its AUC) or precision against recall.
Data. A score column and a 0/1 label column.
Example
// score, label: arrays of numbers, all the same length
engine.datasets.addColumns({
name: 'Detector',
columns: { score, label },
})
const chart = engine.charts.add('roc', {
title: 'Anomaly detector',
settings: { rocScoreCol: 'score', rocLabelCol: 'label', rocMode: 'roc', rocColor: '#f472b6' },
})
engine.charts.mount(chart, document.getElementById('chart')!)Settings
| Name | Type | Description |
|---|---|---|
rocScoreCol | stringDefault: '' | Classifier score (higher = more likely positive). |
rocLabelCol | stringDefault: '' | True label, 0 or 1. |
rocMode | 'roc' | 'pr'Default: 'roc' | ROC curve or precision-recall. |
rocColor | stringDefault: #f472b6 | Colour of the marks (hex). |
Calibration Curve
A Calibration Curve chart drawn by the engine from the data of the example below.
Whether predicted probabilities mean what they say: predicted probability against the observed frequency per bin. On the diagonal is well calibrated.
Data. A probability column (0 to 1) and a 0/1 label column.
Example
// score, label: arrays of numbers, all the same length
engine.datasets.addColumns({
name: 'Detector',
columns: { score, label },
})
const chart = engine.charts.add('calibration', {
title: 'Detector calibration',
settings: { cbScoreCol: 'score', cbLabelCol: 'label', cbBins: 10, cbColor: '#38bdf8' },
})
engine.charts.mount(chart, document.getElementById('chart')!)Settings
| Name | Type | Description |
|---|---|---|
cbScoreCol | stringDefault: '' | Predicted probability. |
cbLabelCol | stringDefault: '' | True label, 0 or 1. |
cbBins | numberDefault: 10 | Number of probability bins. |
cbColor | stringDefault: #38bdf8 | Colour of the marks (hex). |
Loss Curves
A Loss Curves chart drawn by the engine from the data of the example below.
Training curves on two Y axes: losses on the left, accuracy or learning rate on the right, against epochs or steps.
Data. An X column (epoch, step) and the columns of each axis.
Example
// epoch, train_loss, val_loss, accuracy: arrays of numbers, all the same length
engine.datasets.addColumns({
name: 'Training',
columns: { epoch, train_loss, val_loss, accuracy },
})
const chart = engine.charts.add('losscurve', {
title: 'Training run',
settings: {
lcXCol: 'epoch',
lcLeftCols: [{ column: 'train_loss', color: '#38bdf8' }, { column: 'val_loss', color: '#f5a524' }],
lcRightCols: [{ column: 'accuracy', color: '#22c55e' }],
},
})
engine.charts.mount(chart, document.getElementById('chart')!)Settings
| Name | Type | Description |
|---|---|---|
lcXCol | stringDefault: '' | Column along X. |
lcLeftCols | { column, color }[]Default: [] | Curves on the left axis. |
lcRightCols | { column, color }[]Default: [] | Curves on the right axis. |
lcAlarm | AlarmLine | nullDefault: null | Horizontal line on the left axis. |
Embedding
A Embedding chart drawn by the engine from the data of the example below.
A 2-D embedding (t-SNE, UMAP, PCA output) coloured by class or by value: clusters of similar cycles, states or parts.
Data. X and Y columns of the embedding; optionally a colour and a label column.
Example
// x, y, state: arrays of numbers, all the same length
engine.datasets.addColumns({
name: 'States',
columns: { x, y, state },
})
const chart = engine.charts.add('embedding', {
title: 'Operating states',
settings: { emXCol: 'x', emYCol: 'y', emColorCol: 'state', emColorMode: 'categorical', emPointSize: 3 },
})
engine.charts.mount(chart, document.getElementById('chart')!)Settings
| Name | Type | Description |
|---|---|---|
emXCol | stringDefault: '' | First embedding coordinate. |
emYCol | stringDefault: '' | Second embedding coordinate. |
emColorCol | stringDefault: '' | Colour points by this column; '' uses emColor. |
emColorMode | 'numeric' | 'categorical'Default: 'categorical' | A colour map or one colour per value. |
emLabelCol | stringDefault: '' | Label shown for each point; '' for none. |
emPointSize | numberDefault: 3 | Point radius in px. |
emColor | stringDefault: #a78bfa | Colour of the marks (hex). |