class documentation

Base class for evaluation results that expose classification metrics like P/R/F1 and confusion matrices.

Parameters
samplesthe fiftyone.core.collections.SampleCollection used
configthe fiftyone.core.evaluation.EvaluationMethodConfig used
eval_keythe evaluation key
ytruea list of ground truth labels
ypreda list of predicted labels
confsan optional list of confidences for the predictions
weightsan optional list of sample weights
ytrue_idsa list of IDs for the ground truth labels
ypred_idsa list of IDs for the predicted labels
classesthe list of possible classes. If not provided, the observed ground truth/predicted labels are used
missinga missing label string. Any None-valued labels are given this label for evaluation purposes
custom_metricsan optional dict of custom metrics
backenda fiftyone.core.evaluation.EvaluationMethod backend
Method __init__ Undocumented
Method confusion_matrix Generates a confusion matrix for the results via sklearn:sklearn.metrics.confusion_matrix.
Method metrics Computes classification metrics for the results, including accuracy, precision, recall, and F-beta score.
Method plot_confusion_matrix Plots a confusion matrix for the evaluation results.
Method print_metrics Prints the metrics computed via metrics.
Method print_report Prints a classification report for the results via sklearn:sklearn.metrics.classification_report.
Method report Generates a classification report for the results via sklearn:sklearn.metrics.classification_report.
Instance Variable classes Undocumented
Instance Variable confs Undocumented
Instance Variable missing Undocumented
Instance Variable weights Undocumented
Instance Variable ypred Undocumented
Instance Variable ypred_ids Undocumented
Instance Variable ytrue Undocumented
Instance Variable ytrue_ids Undocumented
Class Method _from_dict Subclass implementation of from_dict.
Method _confusion_matrix Undocumented
Method _parse_classes Undocumented

Inherited from BaseEvaluationResults:

Method _get_custom_metrics Undocumented
Method _print_metrics Undocumented

Inherited from BaseRunResults (via BaseEvaluationResults, EvaluationResults):

Class Method from_dict Builds a BaseRunResults from a JSON dict representation of it.
Static Method base_results_cls Returns the results class for the given run type.
Method attributes Returns the list of class attributes that will be serialized by serialize.
Method save Saves the results to the database.
Method save_config Saves these results config to the database.
Property cls The fully-qualified name of this BaseRunResults class.
Property config The BaseRunConfig for these results.
Property key The run key for these results.
Property samples The fiftyone.core.collections.SampleCollection associated with these results.
Instance Variable _backend Undocumented
Instance Variable _config Undocumented
Instance Variable _key Undocumented
Instance Variable _samples Undocumented
def __init__(self, samples, config, eval_key, ytrue, ypred, confs=None, weights=None, ytrue_ids=None, ypred_ids=None, classes=None, missing=None, custom_metrics=None, backend=None): (source)
def confusion_matrix(self, classes=None, include_other=False, include_missing=False): (source)

Generates a confusion matrix for the results via sklearn:sklearn.metrics.confusion_matrix.

The rows of the confusion matrix represent ground truth and the columns represent predictions.

Parameters
classes:Nonean optional list of classes to include in the confusion matrix
include_other:Falsewhether to include an extra row/column at the end of the matrix for labels that do not appear in classes. Only applicable if classes are provided
include_missing:Falsewhether to include a row/column at the end of the matrix for unmatched labels. Only applicable if self.missing does not already appear in classes. If both "other" and "missing" rows/columns are requested, this one is last
Returns
a num_classes x num_classes confusion matrix
def metrics(self, classes=None, average='micro', beta=1.0): (source)

Computes classification metrics for the results, including accuracy, precision, recall, and F-beta score.

See sklearn:sklearn.metrics.precision_recall_fscore_support for details.

Also includes any custom metrics from custom_metrics.

Parameters
classes:Nonean optional list of classes to include in the calculations
average:"micro"the averaging strategy to use
beta:1.0the F-beta value to use
Returns
a dict
def plot_confusion_matrix(self, classes=None, include_other=None, include_missing=None, other_label='(other)', backend='plotly', **kwargs): (source)

Plots a confusion matrix for the evaluation results.

If you are working in a notebook environment with the default plotly backend, this method returns an interactive fiftyone.core.plots.plotly.InteractiveHeatmap that you can attach to an App session via its fiftyone.core.session.Session.plots attribute, which will automatically sync the session's view with the currently selected cells in the confusion matrix.

Parameters
classes:Nonean optional list of classes to include in the confusion matrix
include_other:None

whether to include a row/column for examples whose label is in classes but are matched to labels that do not appear in classes. Only applicable if classes are provided. The supported values are:

  • None (default): only include a row/column for other labels if there are any
  • True: do include a row/column for other labels
  • False: do not include a row/column for other labels
include_missing:None

whether to include a row/column for missing ground truth/predictions in the confusion matrix. The supported values are:

  • None (default): only include a row/column for missing labels if there are any
  • True: do include a row/column for missing labels
  • False: do not include a row/column for missing labels
other_label:"(other)"the label to use for "other" predictions
backend:"plotly"the plotting backend to use. Supported values are ("plotly", "matplotlib")
**kwargs

keyword arguments for the backend plotting method:

Returns
one of the following
def print_metrics(self, classes=None, average='micro', beta=1.0, digits=2): (source)

Prints the metrics computed via metrics.

Parameters
classes:Nonean optional list of classes to include in the calculations
average:"micro"the averaging strategy to use
beta:1.0the F-beta value to use
digits:2the number of digits of precision to print
def print_report(self, classes=None, digits=2): (source)

Prints a classification report for the results via sklearn:sklearn.metrics.classification_report.

Parameters
classes:Nonean optional list of classes to include in the report
digits:2the number of digits of precision to print
def report(self, classes=None): (source)

Generates a classification report for the results via sklearn:sklearn.metrics.classification_report.

Parameters
classes:Nonean optional list of classes to include in the report
Returns
a dict

Undocumented

Undocumented

@classmethod
def _from_dict(cls, d, samples, config, eval_key, **kwargs): (source)

Subclass implementation of from_dict.

Parameters
da JSON dict
samplesthe fiftyone.core.collections.SampleCollection for the run
configthe BaseRunConfig for the run
eval_keyUndocumented
keythe run key
**kwargsUndocumented
Returns
a BaseRunResults
def _confusion_matrix(self, classes=None, include_other=None, include_missing=None, other_label=None, tabulate_ids=False): (source)

Undocumented

def _parse_classes(self, classes): (source)