xref: /aosp_15_r20/external/googleapis/google/cloud/datalabeling/v1beta1/evaluation.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2019 Google LLC.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15
16syntax = "proto3";
17
18package google.cloud.datalabeling.v1beta1;
19
20import "google/api/resource.proto";
21import "google/cloud/datalabeling/v1beta1/annotation.proto";
22import "google/cloud/datalabeling/v1beta1/annotation_spec_set.proto";
23import "google/protobuf/timestamp.proto";
24
25option csharp_namespace = "Google.Cloud.DataLabeling.V1Beta1";
26option go_package = "cloud.google.com/go/datalabeling/apiv1beta1/datalabelingpb;datalabelingpb";
27option java_multiple_files = true;
28option java_package = "com.google.cloud.datalabeling.v1beta1";
29option php_namespace = "Google\\Cloud\\DataLabeling\\V1beta1";
30option ruby_package = "Google::Cloud::DataLabeling::V1beta1";
31
32// Describes an evaluation between a machine learning model's predictions and
33// ground truth labels. Created when an [EvaluationJob][google.cloud.datalabeling.v1beta1.EvaluationJob] runs successfully.
34message Evaluation {
35  option (google.api.resource) = {
36    type: "datalabeling.googleapis.com/Evaluation"
37    pattern: "projects/{project}/datasets/{dataset}/evaluations/{evaluation}"
38  };
39
40  // Output only. Resource name of an evaluation. The name has the following
41  // format:
42  //
43  // "projects/<var>{project_id}</var>/datasets/<var>{dataset_id}</var>/evaluations/<var>{evaluation_id</var>}'
44  string name = 1;
45
46  // Output only. Options used in the evaluation job that created this
47  // evaluation.
48  EvaluationConfig config = 2;
49
50  // Output only. Timestamp for when the evaluation job that created this
51  // evaluation ran.
52  google.protobuf.Timestamp evaluation_job_run_time = 3;
53
54  // Output only. Timestamp for when this evaluation was created.
55  google.protobuf.Timestamp create_time = 4;
56
57  // Output only. Metrics comparing predictions to ground truth labels.
58  EvaluationMetrics evaluation_metrics = 5;
59
60  // Output only. Type of task that the model version being evaluated performs,
61  // as defined in the
62  //
63  // [evaluationJobConfig.inputConfig.annotationType][google.cloud.datalabeling.v1beta1.EvaluationJobConfig.input_config]
64  // field of the evaluation job that created this evaluation.
65  AnnotationType annotation_type = 6;
66
67  // Output only. The number of items in the ground truth dataset that were used
68  // for this evaluation. Only populated when the evaulation is for certain
69  // AnnotationTypes.
70  int64 evaluated_item_count = 7;
71}
72
73// Configuration details used for calculating evaluation metrics and creating an
74// [Evaluation][google.cloud.datalabeling.v1beta1.Evaluation].
75message EvaluationConfig {
76  // Vertical specific options for general metrics.
77  oneof vertical_option {
78    // Only specify this field if the related model performs image object
79    // detection (`IMAGE_BOUNDING_BOX_ANNOTATION`). Describes how to evaluate
80    // bounding boxes.
81    BoundingBoxEvaluationOptions bounding_box_evaluation_options = 1;
82  }
83}
84
85// Options regarding evaluation between bounding boxes.
86message BoundingBoxEvaluationOptions {
87  // Minimum
88  // [intersection-over-union
89  //
90  // (IOU)](/vision/automl/object-detection/docs/evaluate#intersection-over-union)
91  // required for 2 bounding boxes to be considered a match. This must be a
92  // number between 0 and 1.
93  float iou_threshold = 1;
94}
95
96message EvaluationMetrics {
97  // Common metrics covering most general cases.
98  oneof metrics {
99    ClassificationMetrics classification_metrics = 1;
100
101    ObjectDetectionMetrics object_detection_metrics = 2;
102  }
103}
104
105// Metrics calculated for a classification model.
106message ClassificationMetrics {
107  // Precision-recall curve based on ground truth labels, predicted labels, and
108  // scores for the predicted labels.
109  PrCurve pr_curve = 1;
110
111  // Confusion matrix of predicted labels vs. ground truth labels.
112  ConfusionMatrix confusion_matrix = 2;
113}
114
115// Metrics calculated for an image object detection (bounding box) model.
116message ObjectDetectionMetrics {
117  // Precision-recall curve.
118  PrCurve pr_curve = 1;
119}
120
121message PrCurve {
122  message ConfidenceMetricsEntry {
123    // Threshold used for this entry.
124    //
125    // For classification tasks, this is a classification threshold: a
126    // predicted label is categorized as positive or negative (in the context of
127    // this point on the PR curve) based on whether the label's score meets this
128    // threshold.
129    //
130    // For image object detection (bounding box) tasks, this is the
131    // [intersection-over-union
132    //
133    // (IOU)](/vision/automl/object-detection/docs/evaluate#intersection-over-union)
134    // threshold for the context of this point on the PR curve.
135    float confidence_threshold = 1;
136
137    // Recall value.
138    float recall = 2;
139
140    // Precision value.
141    float precision = 3;
142
143    // Harmonic mean of recall and precision.
144    float f1_score = 4;
145
146    // Recall value for entries with label that has highest score.
147    float recall_at1 = 5;
148
149    // Precision value for entries with label that has highest score.
150    float precision_at1 = 6;
151
152    // The harmonic mean of [recall_at1][google.cloud.datalabeling.v1beta1.PrCurve.ConfidenceMetricsEntry.recall_at1] and [precision_at1][google.cloud.datalabeling.v1beta1.PrCurve.ConfidenceMetricsEntry.precision_at1].
153    float f1_score_at1 = 7;
154
155    // Recall value for entries with label that has highest 5 scores.
156    float recall_at5 = 8;
157
158    // Precision value for entries with label that has highest 5 scores.
159    float precision_at5 = 9;
160
161    // The harmonic mean of [recall_at5][google.cloud.datalabeling.v1beta1.PrCurve.ConfidenceMetricsEntry.recall_at5] and [precision_at5][google.cloud.datalabeling.v1beta1.PrCurve.ConfidenceMetricsEntry.precision_at5].
162    float f1_score_at5 = 10;
163  }
164
165  // The annotation spec of the label for which the precision-recall curve
166  // calculated. If this field is empty, that means the precision-recall curve
167  // is an aggregate curve for all labels.
168  AnnotationSpec annotation_spec = 1;
169
170  // Area under the precision-recall curve. Not to be confused with area under
171  // a receiver operating characteristic (ROC) curve.
172  float area_under_curve = 2;
173
174  // Entries that make up the precision-recall graph. Each entry is a "point" on
175  // the graph drawn for a different `confidence_threshold`.
176  repeated ConfidenceMetricsEntry confidence_metrics_entries = 3;
177
178  // Mean average prcision of this curve.
179  float mean_average_precision = 4;
180}
181
182// Confusion matrix of the model running the classification. Only applicable
183// when the metrics entry aggregates multiple labels. Not applicable when the
184// entry is for a single label.
185message ConfusionMatrix {
186  message ConfusionMatrixEntry {
187    // The annotation spec of a predicted label.
188    AnnotationSpec annotation_spec = 1;
189
190    // Number of items predicted to have this label. (The ground truth label for
191    // these items is the `Row.annotationSpec` of this entry's parent.)
192    int32 item_count = 2;
193  }
194
195  // A row in the confusion matrix. Each entry in this row has the same
196  // ground truth label.
197  message Row {
198    // The annotation spec of the ground truth label for this row.
199    AnnotationSpec annotation_spec = 1;
200
201    // A list of the confusion matrix entries. One entry for each possible
202    // predicted label.
203    repeated ConfusionMatrixEntry entries = 2;
204  }
205
206  repeated Row row = 1;
207}
208