1// Copyright 2020 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.automl.v1beta1;
18
19import "google/cloud/automl/v1beta1/temporal.proto";
20
21option go_package = "cloud.google.com/go/automl/apiv1beta1/automlpb;automlpb";
22option java_outer_classname = "ClassificationProto";
23option java_package = "com.google.cloud.automl.v1beta1";
24option php_namespace = "Google\\Cloud\\AutoMl\\V1beta1";
25option ruby_package = "Google::Cloud::AutoML::V1beta1";
26
27// Type of the classification problem.
28enum ClassificationType {
29  // An un-set value of this enum.
30  CLASSIFICATION_TYPE_UNSPECIFIED = 0;
31
32  // At most one label is allowed per example.
33  MULTICLASS = 1;
34
35  // Multiple labels are allowed for one example.
36  MULTILABEL = 2;
37}
38
39// Contains annotation details specific to classification.
40message ClassificationAnnotation {
41  // Output only. A confidence estimate between 0.0 and 1.0. A higher value
42  // means greater confidence that the annotation is positive. If a user
43  // approves an annotation as negative or positive, the score value remains
44  // unchanged. If a user creates an annotation, the score is 0 for negative or
45  // 1 for positive.
46  float score = 1;
47}
48
49// Contains annotation details specific to video classification.
50message VideoClassificationAnnotation {
51  // Output only. Expresses the type of video classification. Possible values:
52  //
53  // *  `segment` - Classification done on a specified by user
54  //        time segment of a video. AnnotationSpec is answered to be present
55  //        in that time segment, if it is present in any part of it. The video
56  //        ML model evaluations are done only for this type of classification.
57  //
58  // *  `shot`- Shot-level classification.
59  //        AutoML Video Intelligence determines the boundaries
60  //        for each camera shot in the entire segment of the video that user
61  //        specified in the request configuration. AutoML Video Intelligence
62  //        then returns labels and their confidence scores for each detected
63  //        shot, along with the start and end time of the shot.
64  //        WARNING: Model evaluation is not done for this classification type,
65  //        the quality of it depends on training data, but there are no
66  //        metrics provided to describe that quality.
67  //
68  // *  `1s_interval` - AutoML Video Intelligence returns labels and their
69  //        confidence scores for each second of the entire segment of the video
70  //        that user specified in the request configuration.
71  //        WARNING: Model evaluation is not done for this classification type,
72  //        the quality of it depends on training data, but there are no
73  //        metrics provided to describe that quality.
74  string type = 1;
75
76  // Output only . The classification details of this annotation.
77  ClassificationAnnotation classification_annotation = 2;
78
79  // Output only . The time segment of the video to which the
80  // annotation applies.
81  TimeSegment time_segment = 3;
82}
83
84// Model evaluation metrics for classification problems.
85// Note: For Video Classification this metrics only describe quality of the
86// Video Classification predictions of "segment_classification" type.
87message ClassificationEvaluationMetrics {
88  // Metrics for a single confidence threshold.
89  message ConfidenceMetricsEntry {
90    // Output only. Metrics are computed with an assumption that the model
91    // never returns predictions with score lower than this value.
92    float confidence_threshold = 1;
93
94    // Output only. Metrics are computed with an assumption that the model
95    // always returns at most this many predictions (ordered by their score,
96    // descendingly), but they all still need to meet the confidence_threshold.
97    int32 position_threshold = 14;
98
99    // Output only. Recall (True Positive Rate) for the given confidence
100    // threshold.
101    float recall = 2;
102
103    // Output only. Precision for the given confidence threshold.
104    float precision = 3;
105
106    // Output only. False Positive Rate for the given confidence threshold.
107    float false_positive_rate = 8;
108
109    // Output only. The harmonic mean of recall and precision.
110    float f1_score = 4;
111
112    // Output only. The Recall (True Positive Rate) when only considering the
113    // label that has the highest prediction score and not below the confidence
114    // threshold for each example.
115    float recall_at1 = 5;
116
117    // Output only. The precision when only considering the label that has the
118    // highest prediction score and not below the confidence threshold for each
119    // example.
120    float precision_at1 = 6;
121
122    // Output only. The False Positive Rate when only considering the label that
123    // has the highest prediction score and not below the confidence threshold
124    // for each example.
125    float false_positive_rate_at1 = 9;
126
127    // Output only. The harmonic mean of [recall_at1][google.cloud.automl.v1beta1.ClassificationEvaluationMetrics.ConfidenceMetricsEntry.recall_at1] and [precision_at1][google.cloud.automl.v1beta1.ClassificationEvaluationMetrics.ConfidenceMetricsEntry.precision_at1].
128    float f1_score_at1 = 7;
129
130    // Output only. The number of model created labels that match a ground truth
131    // label.
132    int64 true_positive_count = 10;
133
134    // Output only. The number of model created labels that do not match a
135    // ground truth label.
136    int64 false_positive_count = 11;
137
138    // Output only. The number of ground truth labels that are not matched
139    // by a model created label.
140    int64 false_negative_count = 12;
141
142    // Output only. The number of labels that were not created by the model,
143    // but if they would, they would not match a ground truth label.
144    int64 true_negative_count = 13;
145  }
146
147  // Confusion matrix of the model running the classification.
148  message ConfusionMatrix {
149    // Output only. A row in the confusion matrix.
150    message Row {
151      // Output only. Value of the specific cell in the confusion matrix.
152      // The number of values each row has (i.e. the length of the row) is equal
153      // to the length of the `annotation_spec_id` field or, if that one is not
154      // populated, length of the [display_name][google.cloud.automl.v1beta1.ClassificationEvaluationMetrics.ConfusionMatrix.display_name] field.
155      repeated int32 example_count = 1;
156    }
157
158    // Output only. IDs of the annotation specs used in the confusion matrix.
159    // For Tables CLASSIFICATION
160    //
161    // [prediction_type][google.cloud.automl.v1beta1.TablesModelMetadata.prediction_type]
162    // only list of [annotation_spec_display_name-s][] is populated.
163    repeated string annotation_spec_id = 1;
164
165    // Output only. Display name of the annotation specs used in the confusion
166    // matrix, as they were at the moment of the evaluation. For Tables
167    // CLASSIFICATION
168    //
169    // [prediction_type-s][google.cloud.automl.v1beta1.TablesModelMetadata.prediction_type],
170    // distinct values of the target column at the moment of the model
171    // evaluation are populated here.
172    repeated string display_name = 3;
173
174    // Output only. Rows in the confusion matrix. The number of rows is equal to
175    // the size of `annotation_spec_id`.
176    // `row[i].example_count[j]` is the number of examples that have ground
177    // truth of the `annotation_spec_id[i]` and are predicted as
178    // `annotation_spec_id[j]` by the model being evaluated.
179    repeated Row row = 2;
180  }
181
182  // Output only. The Area Under Precision-Recall Curve metric. Micro-averaged
183  // for the overall evaluation.
184  float au_prc = 1;
185
186  // Output only. The Area Under Precision-Recall Curve metric based on priors.
187  // Micro-averaged for the overall evaluation.
188  // Deprecated.
189  float base_au_prc = 2 [deprecated = true];
190
191  // Output only. The Area Under Receiver Operating Characteristic curve metric.
192  // Micro-averaged for the overall evaluation.
193  float au_roc = 6;
194
195  // Output only. The Log Loss metric.
196  float log_loss = 7;
197
198  // Output only. Metrics for each confidence_threshold in
199  // 0.00,0.05,0.10,...,0.95,0.96,0.97,0.98,0.99 and
200  // position_threshold = INT32_MAX_VALUE.
201  // ROC and precision-recall curves, and other aggregated metrics are derived
202  // from them. The confidence metrics entries may also be supplied for
203  // additional values of position_threshold, but from these no aggregated
204  // metrics are computed.
205  repeated ConfidenceMetricsEntry confidence_metrics_entry = 3;
206
207  // Output only. Confusion matrix of the evaluation.
208  // Only set for MULTICLASS classification problems where number
209  // of labels is no more than 10.
210  // Only set for model level evaluation, not for evaluation per label.
211  ConfusionMatrix confusion_matrix = 4;
212
213  // Output only. The annotation spec ids used for this evaluation.
214  repeated string annotation_spec_id = 5;
215}
216