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

OptionTypeDescriptionRequired
predictionStreamStream<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

OptionTypeDescriptionRequired
imgStreamStream<ImageData>A stream of image
objDectectionResStream<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

OptionTypeDescriptionRequired
predictionBatchPredictionA batch prediction component storing a set of predictions

Streams

NameTypeDescriptionHold
$confusionStream<Array<{ x: string; y: string; v: number; }>>Current confusion matrix
$accuracyStream<number>Current accuracy
$labelsStream<string[]>current list of labels
$selectedStream<{ x: string; y: string; v: number }>Selected value
$progressStream<number | false>Progress of the computation

Screenshot

Screenshot of the confusion-matrix component

Example

const batchMLP = marcelle.batchPrediction('mlp', store);
const confusionMatrix = marcelle.confusionMatrix(batchMLP);