# Prediction displays

# confidencePlot

marcelle.confidencePlot(
  predictionStream: Stream<Prediction>
): ConfidencePlot;

Plot prediction result in real-time from a reactive stream of predictions, where each event implements the following interface:

interface Prediction {
  id?: ObjectId;
  instanceId: ObjectId;
  label?: string;
  trueLabel?: string;
  confidences?: Record<string, number>;
  [key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any
}

# Parameters

Option Type Description Required
predictionStream Stream<Prediction> a stream of Prediction objects

# Screenshot

Screenshot of the classificationPlot component

# Example

const predictionStream = $features.map((feat) => classifier.predict(feat)).awaitPromises();

const plotResults = marcelle.confidencePlot(predictionStream);

# detectionBoxes

marcelle.detectionBoxes(
  imgStream: Stream<ImageData>,
  objDectectionRes: Stream<ObjectDetectorResults>
): DetectionBoxes;

Plot detection boxes on an image given by a segmentation algorithm. ObjectDetectorResults has the following interface:

interface ObjectDetectorResults {
  outputs: {
    bbox: [number, number, number, number];
    class: string;
    confidence: number;
  }[];
}

# Parameters

Option Type Description Required
imgStream Stream<ImageData> A stream of image
objDectectionRes Stream<ObjectDetectorResults> A stream of object detection results

# Example

const source = imageUpload();
const cocoClassifier = cocoSsd();

// prediction using cocoSsd algorithm
const cocoPredictionStream = source.$images
  .map(async (img) => cocoClassifier.predict(img))
  .awaitPromises();

// build predictions
const cocoBetterPredictions = cocoPredictionStream.map(({ outputs }) => ({
  label: outputs[0].class,
  confidences: outputs.reduce((x, y) => ({ ...x, [y.class]: y.confidence }), {}),
}));

const objDetectionVis = detectionBoxes(source.$images, cocoPredictionStream);

# ConfusionMatrix

marcelle.confusionMatrix(prediction: BatchPrediction): Confusion;

Displays a confusion matrix from a BatchPrediction component.

# Parameters

Option Type Description Required
prediction BatchPrediction A batch prediction component storing a set of predictions

# Screenshot

Screenshot of the confusion-matrix component

# Example

const batchMLP = marcelle.batchPrediction({ name: 'mlp', dataStore: store });
const confusionMatrix = marcelle.confusionMatrix(batchMLP);