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