xref: /aosp_15_r20/external/googleapis/google/cloud/aiplatform/v1/evaluated_annotation.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 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
15syntax = "proto3";
16
17package google.cloud.aiplatform.v1;
18
19import "google/api/field_behavior.proto";
20import "google/cloud/aiplatform/v1/explanation.proto";
21import "google/protobuf/struct.proto";
22
23option csharp_namespace = "Google.Cloud.AIPlatform.V1";
24option go_package = "cloud.google.com/go/aiplatform/apiv1/aiplatformpb;aiplatformpb";
25option java_multiple_files = true;
26option java_outer_classname = "EvaluatedAnnotationProto";
27option java_package = "com.google.cloud.aiplatform.v1";
28option php_namespace = "Google\\Cloud\\AIPlatform\\V1";
29option ruby_package = "Google::Cloud::AIPlatform::V1";
30
31// True positive, false positive, or false negative.
32//
33// EvaluatedAnnotation is only available under ModelEvaluationSlice with slice
34// of `annotationSpec` dimension.
35message EvaluatedAnnotation {
36  // Describes the type of the EvaluatedAnnotation. The type is determined
37  enum EvaluatedAnnotationType {
38    // Invalid value.
39    EVALUATED_ANNOTATION_TYPE_UNSPECIFIED = 0;
40
41    // The EvaluatedAnnotation is a true positive. It has a prediction created
42    // by the Model and a ground truth Annotation which the prediction matches.
43    TRUE_POSITIVE = 1;
44
45    // The EvaluatedAnnotation is false positive. It has a prediction created by
46    // the Model which does not match any ground truth annotation.
47    FALSE_POSITIVE = 2;
48
49    // The EvaluatedAnnotation is false negative. It has a ground truth
50    // annotation which is not matched by any of the model created predictions.
51    FALSE_NEGATIVE = 3;
52  }
53
54  // Output only. Type of the EvaluatedAnnotation.
55  EvaluatedAnnotationType type = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
56
57  // Output only. The model predicted annotations.
58  //
59  // For true positive, there is one and only one prediction, which matches the
60  // only one ground truth annotation in
61  // [ground_truths][google.cloud.aiplatform.v1.EvaluatedAnnotation.ground_truths].
62  //
63  // For false positive, there is one and only one prediction, which doesn't
64  // match any ground truth annotation of the corresponding
65  // [data_item_view_id][EvaluatedAnnotation.data_item_view_id].
66  //
67  // For false negative, there are zero or more predictions which are similar to
68  // the only ground truth annotation in
69  // [ground_truths][google.cloud.aiplatform.v1.EvaluatedAnnotation.ground_truths]
70  // but not enough for a match.
71  //
72  // The schema of the prediction is stored in
73  // [ModelEvaluation.annotation_schema_uri][google.cloud.aiplatform.v1.ModelEvaluation.annotation_schema_uri]
74  repeated google.protobuf.Value predictions = 2
75      [(google.api.field_behavior) = OUTPUT_ONLY];
76
77  // Output only. The ground truth Annotations, i.e. the Annotations that exist
78  // in the test data the Model is evaluated on.
79  //
80  // For true positive, there is one and only one ground truth annotation, which
81  // matches the only prediction in
82  // [predictions][google.cloud.aiplatform.v1.EvaluatedAnnotation.predictions].
83  //
84  // For false positive, there are zero or more ground truth annotations that
85  // are similar to the only prediction in
86  // [predictions][google.cloud.aiplatform.v1.EvaluatedAnnotation.predictions],
87  // but not enough for a match.
88  //
89  // For false negative, there is one and only one ground truth annotation,
90  // which doesn't match any predictions created by the model.
91  //
92  // The schema of the ground truth is stored in
93  // [ModelEvaluation.annotation_schema_uri][google.cloud.aiplatform.v1.ModelEvaluation.annotation_schema_uri]
94  repeated google.protobuf.Value ground_truths = 3
95      [(google.api.field_behavior) = OUTPUT_ONLY];
96
97  // Output only. The data item payload that the Model predicted this
98  // EvaluatedAnnotation on.
99  google.protobuf.Value data_item_payload = 5
100      [(google.api.field_behavior) = OUTPUT_ONLY];
101
102  // Output only. ID of the EvaluatedDataItemView under the same ancestor
103  // ModelEvaluation. The EvaluatedDataItemView consists of all ground truths
104  // and predictions on
105  // [data_item_payload][google.cloud.aiplatform.v1.EvaluatedAnnotation.data_item_payload].
106  string evaluated_data_item_view_id = 6
107      [(google.api.field_behavior) = OUTPUT_ONLY];
108
109  // Explanations of
110  // [predictions][google.cloud.aiplatform.v1.EvaluatedAnnotation.predictions].
111  // Each element of the explanations indicates the explanation for one
112  // explanation Method.
113  //
114  // The attributions list in the
115  // [EvaluatedAnnotationExplanation.explanation][google.cloud.aiplatform.v1.EvaluatedAnnotationExplanation.explanation]
116  // object corresponds to the
117  // [predictions][google.cloud.aiplatform.v1.EvaluatedAnnotation.predictions]
118  // list. For example, the second element in the attributions list explains the
119  // second element in the predictions list.
120  repeated EvaluatedAnnotationExplanation explanations = 8;
121
122  // Annotations of model error analysis results.
123  repeated ErrorAnalysisAnnotation error_analysis_annotations = 9;
124}
125
126// Explanation result of the prediction produced by the Model.
127message EvaluatedAnnotationExplanation {
128  // Explanation type.
129  //
130  // For AutoML Image Classification models, possible values are:
131  //
132  //   * `image-integrated-gradients`
133  //   * `image-xrai`
134  string explanation_type = 1;
135
136  // Explanation attribution response details.
137  Explanation explanation = 2;
138}
139
140// Model error analysis for each annotation.
141message ErrorAnalysisAnnotation {
142  // Attributed items for a given annotation, typically representing neighbors
143  // from the training sets constrained by the query type.
144  message AttributedItem {
145    // The unique ID for each annotation. Used by FE to allocate the annotation
146    // in DB.
147    string annotation_resource_name = 1;
148
149    // The distance of this item to the annotation.
150    double distance = 2;
151  }
152
153  // The query type used for finding the attributed items.
154  enum QueryType {
155    // Unspecified query type for model error analysis.
156    QUERY_TYPE_UNSPECIFIED = 0;
157
158    // Query similar samples across all classes in the dataset.
159    ALL_SIMILAR = 1;
160
161    // Query similar samples from the same class of the input sample.
162    SAME_CLASS_SIMILAR = 2;
163
164    // Query dissimilar samples from the same class of the input sample.
165    SAME_CLASS_DISSIMILAR = 3;
166  }
167
168  // Attributed items for a given annotation, typically representing neighbors
169  // from the training sets constrained by the query type.
170  repeated AttributedItem attributed_items = 1;
171
172  // The query type used for finding the attributed items.
173  QueryType query_type = 2;
174
175  // The outlier score of this annotated item. Usually defined as the min of all
176  // distances from attributed items.
177  double outlier_score = 3;
178
179  // The threshold used to determine if this annotation is an outlier or not.
180  double outlier_threshold = 4;
181}
182