# ML - Predict Object Class

This is an experimental module from the Xtra Library: https://www.thermofisher.com/software-em-3d-vis/xtra-library/.

Given a binary or label image of segmented objects, this module assigns to each object the class (Material) it most likely belongs to, according to the selected pretrained classification model (generated from the module ML - Train Object Classifier).

## Known Limitations

- The trained model is stored on the disk, relying on the pickle python package. It is unlikely that a model trained with a version of the Software will work with a future version.
- The set of measures the model relies on is specified in this module, and must remain the same when using the module for Prediction (i.e. if the measure group is modified between Training and Prediction, the prediction will fail).
- As a consequence, if you need to transfer the model to a different computer, you will need to ensure the Measure Group is defined on that computer (see "Export Custom Measure Groups")

## Connections

Input | Description
--- | ---
Data: [required] | A binary or label image representing objects, as a set of connected components, that need classification
Intensity Image: [required] | Grayscale image, the same size and shape as the Data, from which intensity features will be computed. Required if the selected model relies on intensity features.

## Parameters (Ports)

Parameter | Description
--- | ---
Console | Opens the Python Script Object console of the module as the active console window.
Model Filename | Path to the pretrained classification model, that was trained with ML - Train Object Classifier module
Class Names | Information about the selected pretrained classification model
Feature Info | Information about the selected pretrained classification model
Apply | Execute the prediction

## Outputs

This module generates 3 outputs:

- .classified: a Label Image where each object is given an ID corresponding to the estimated Class/Materials it belongs to – according to the selected classifier.
- .instances: generated only if the input was a binary image, this output is a label field were all objects are uniquely labeled
- .analysis: the Label Analysis spreadsheet with the set of Measures that the model is relying on, and additional columns to indicate the predicted Class Name and ID, as well as the relative probabilities of all classes.

## See also

ML - Train Object Classifier

ObjectClassification_Tuto.pdf