ML Workflow Overview
The ML Workflow widget provides interactive machine learning directly in WhiskerToolbox. It supports two workflows:
- Classification — train a supervised model to predict frame labels from features, then apply predictions to unlabeled data
- Clustering — group frames by similarity without labels using unsupervised algorithms
Opening the Widget
Open the ML Workflow widget from the menu: View → Analysis → ML Workflow.
The widget appears as a tabbed panel in the right dock area. The Classification tab is shown by default; switch to the Clustering tab for unsupervised workflows.
General Workflow
Classification
- Prepare features: Build a feature tensor using the TensorDesigner widget. Features are columns of numerical values (e.g., curvature, distance, angle) computed from your data.
- Select features: Choose the feature tensor in the ML Workflow’s Feature panel.
- Define training region (optional): Select a
DigitalIntervalSeriesthat marks which frames to use for training. - Configure labels: Choose how frames are labeled — from interval annotations, entity groups, or data-entity groups.
- Select model: Choose a classification algorithm (Random Forest, Naive Bayes, or Logistic Regression) and configure its parameters.
- Train: Click “Train Model” to run the full pipeline. Training runs in the background and progress is shown in the status bar.
- Review results: Accuracy, sensitivity, specificity, and a confusion matrix are displayed in the Results panel.
- Predict: Predictions are written as
DigitalIntervalSeriesand optional probabilityAnalogTimeSeries. Output appears in the DataManager and can be viewed in the DataViewer.
Clustering
- Prepare features: Build a feature tensor as above.
- Select data: Choose the tensor and optionally enable z-score normalization.
- Select algorithm: Choose K-Means, DBSCAN, or Gaussian Mixture and set parameters.
- Fit & Assign: Click “Fit & Assign” to run clustering. Results appear as putative entity groups with auto-assigned colors.
- Review output: Cluster sizes, interval series, and optional probability series are created in the DataManager.
Putative Group Output
Predictions and cluster assignments never overwrite your original labels. All outputs are written to new data keys and entity groups with a configurable prefix (e.g., "Predicted:Contact", "Cluster:0"). This lets you compare ML results against your manual annotations.
Prediction Regions
You can restrict predictions to a specific frame range by selecting a DigitalIntervalSeries in the Prediction panel. This is especially useful when you have labeled some parts of a recording and want to predict just the unlabeled sections.
For the HMM, the pipeline automatically extends the prediction range to include training labels (for temporal context), then filters output back to your selected frames. A constrained decoding option (HMM only) uses the last known label at region boundaries to warm-start predictions.
Available Models
Supervised (Classification Tab)
| Model | Best For |
|---|---|
| Random Forest | General-purpose classification with many features |
| Naive Bayes | Fast training, works well with independent features |
| Logistic Regression | Binary classification with well-calibrated probabilities |
| Hidden Markov Model | Sequence-aware classification exploiting temporal continuity |
Unsupervised (Clustering Tab)
| Model | Best For |
|---|---|
| K-Means | Known number of clusters, spherical groups |
| DBSCAN | Unknown number of clusters, arbitrary shapes, noise detection |
| Gaussian Mixture | Soft cluster assignments, overlapping groups |