class BaseClassificationResults(BaseEvaluationResults): (source)
Known subclasses: fiftyone.utils.eval.classification.ClassificationResults
, fiftyone.utils.eval.detection.DetectionResults
, fiftyone.utils.eval.segmentation.SegmentationResults
Constructor: BaseClassificationResults(samples, config, eval_key, ytrue, ...)
Base class for evaluation results that expose classification metrics like P/R/F1 and confusion matrices.
Parameters | |
samples | the fiftyone.core.collections.SampleCollection used |
config | the fiftyone.core.evaluation.EvaluationMethodConfig
used |
eval | the evaluation key |
ytrue | a list of ground truth labels |
ypred | a list of predicted labels |
confs | an optional list of confidences for the predictions |
weights | an optional list of sample weights |
ytrue | a list of IDs for the ground truth labels |
ypred | a list of IDs for the predicted labels |
classes | the list of possible classes. If not provided, the observed ground truth/predicted labels are used |
missing | a missing label string. Any None-valued labels are given this label for evaluation purposes |
custom | an optional dict of custom metrics |
backend | a fiftyone.core.evaluation.EvaluationMethod
backend |
Method | __enter__ |
Undocumented |
Method | __exit__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | clear |
Clears the subset set by use_subset , if any. |
Method | confusion |
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 |
Plots a confusion matrix for the evaluation results. |
Method | print |
Prints the metrics computed via metrics . |
Method | print |
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 . |
Method | use |
Restricts the evaluation results to the specified subset. |
Instance Variable | classes |
Undocumented |
Instance Variable | confs |
Undocumented |
Instance Variable | missing |
Undocumented |
Instance Variable | weights |
Undocumented |
Instance Variable | ypred |
Undocumented |
Instance Variable | ypred |
Undocumented |
Instance Variable | ytrue |
Undocumented |
Instance Variable | ytrue |
Undocumented |
Property | has |
Whether these results are currently restricted to a subset via use_subset . |
Class Method | _from |
Subclass implementation of from_dict . |
Method | _confusion |
Undocumented |
Method | _parse |
Undocumented |
Instance Variable | _confs |
Undocumented |
Instance Variable | _has |
Undocumented |
Instance Variable | _samples |
Undocumented |
Instance Variable | _samples |
Undocumented |
Instance Variable | _weights |
Undocumented |
Instance Variable | _ypred |
Undocumented |
Instance Variable | _ypred |
Undocumented |
Instance Variable | _ytrue |
Undocumented |
Instance Variable | _ytrue |
Undocumented |
Inherited from BaseEvaluationResults
:
Method | add |
Computes the given custom metrics and adds them to these results. |
Method | _get |
Undocumented |
Method | _print |
Undocumented |
Inherited from BaseRunResults
(via BaseEvaluationResults
, EvaluationResults
):
Class Method | from |
Builds a BaseRunResults from a JSON dict representation of it. |
Static Method | base |
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 |
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 |
Clears the subset set by use_subset
, if any.
Subsequent operations will be performed on the full results.
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:None | an optional list of classes to include in the confusion matrix |
includeFalse | whether 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 |
includeFalse | whether 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 |
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:None | an optional list of classes to include in the calculations |
average:"micro" | the averaging strategy to use |
beta:1.0 | the F-beta value to use |
Returns | |
a dict |
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:None | an optional list of classes to include in the confusion matrix |
includeNone | 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:
|
includeNone | whether to include a row/column for missing ground truth/predictions in the confusion matrix. The supported values are:
|
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 |
|
Prints a classification report for the results via
sklearn:sklearn.metrics.classification_report
.
Parameters | |
classes:None | an optional list of classes to include in the report |
digits:2 | the number of digits of precision to print |
Generates a classification report for the results via
sklearn:sklearn.metrics.classification_report
.
Parameters | |
classes:None | an optional list of classes to include in the report |
Returns | |
a dict |
Restricts the evaluation results to the specified subset.
Subsequent calls to supported methods on this instance will only contain results from the specified subset rather than the full results.
Use clear_subset
to reset to the full results. Or,
equivalently, use the context manager interface as demonstrated below
to automatically reset the results when the context exits.
Example usage:
import fiftyone as fo import fiftyone.zoo as foz import fiftyone.utils.random as four from fiftyone import ViewField as F dataset = foz.load_zoo_dataset("quickstart") four.random_split(dataset, {"sunny": 0.7, "cloudy": 0.2, "rainy": 0.1}) results = dataset.evaluate_detections( "predictions", gt_field="ground_truth", eval_key="eval", ) counts = dataset.count_values("ground_truth.detections.label") classes = sorted(counts, key=counts.get, reverse=True)[:5] # Full results results.print_report(classes=classes) # Sunny samples subset_def = dict(type="field", field="tags", value="sunny") with results.use_subset(subset_def): results.print_report(classes=classes) # Small objects bbox_area = F("bounding_box")[2] * F("bounding_box")[3] small_objects = bbox_area <= 0.05 subset_def = dict(type="attribute", expr=small_objects) with results.use_subset(subset_def): results.print_report(classes=classes)
Parameters | |
subset | the subset definition, which can be:
|
Returns | |
self |
fiftyone.utils.eval.classification.ClassificationResults
, fiftyone.utils.eval.detection.DetectionResults
Undocumented
fiftyone.utils.eval.classification.BinaryClassificationResults
, fiftyone.utils.eval.detection.DetectionResults
, fiftyone.utils.eval.segmentation.SegmentationResults
Subclass implementation of from_dict
.
Parameters | |
d | a JSON dict |
samples | the fiftyone.core.collections.SampleCollection
for the run |
config | the BaseRunConfig for the run |
eval | Undocumented |
key | the run key |
**kwargs | Undocumented |
Returns | |
a BaseRunResults |
Undocumented