/
metric.proto
360 lines (301 loc) · 12.1 KB
/
metric.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
// Copyright 2017 The TensorFlow Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================
syntax = "proto3";
package tensorflow.metadata.v0;
import "google/protobuf/any.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/descriptor.proto";
import "tensorflow_metadata/proto/v0/path.proto";
option cc_enable_arenas = true;
option java_package = "org.tensorflow.metadata.v0";
option java_multiple_files = true;
// Metric type indicates which direction of a real-valued metric is "better".
// For most message types, this is invariant. For custom message types,
// is_maximized == true is like MAXIMIZE, and otherwise MINIMIZE.
enum MetricType {
UNKNOWN = 0;
// Maximize the metric (i.e. a utility).
MAXIMIZE = 1;
// Minimize the metric (i.e. a loss).
MINIMIZE = 2;
// Look for a field is_maximized.
CUSTOM = 3;
}
extend google.protobuf.MessageOptions {
MetricType metric_type = 227673489;
}
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/binary_accuracy
message BinaryAccuracy {
option (metric_type) = MAXIMIZE;
}
// categorical_accuracy(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/categorical_accuracy
message CategoricalAccuracy {
option (metric_type) = MAXIMIZE;
}
// categorical_crossentropy(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/categorical_crossentropy
message CategoricalCrossEntropy {
option (metric_type) = MINIMIZE;
}
// cosine(...)
// cosine_proximity(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/cosine_proximity
// DEPRECATED
message Cosine {
option (metric_type) = MINIMIZE;
}
// Linear Hinge Loss
// hinge(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/hinge
// DEPRECATED
message Hinge {
option (metric_type) = MINIMIZE;
}
// kld(...)
// kullback_leibler_divergence(...)
// KLD(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/kullback_leibler_divergence
// DEPRECATED
message KullbackLeiblerDivergence {
option (metric_type) = MINIMIZE;
}
// MAE(...)
// mae(...)
// mean_absolute_error(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/mean_absolute_error
message MeanAbsoluteError {
option (metric_type) = MINIMIZE;
}
// MAPE(...)
// mape(...)
// mean_absolute_percentage_error(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/mean_absolute_percentage_error
message MeanAbsolutePercentageError {
option (metric_type) = MINIMIZE;
}
// MSE(...)
// mse(...)
// mean_squared_error(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/mean_squared_error
message MeanSquaredError {
option (metric_type) = MINIMIZE;
}
// msle(...)
// MSLE(...)
// mean_squared_logarithmic_error(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/mean_squared_logarithmic_error
message MeanSquaredLogarithmicError {
option (metric_type) = MINIMIZE;
}
// poisson(...)
// DEPRECATED
message Poisson {
option (metric_type) = MINIMIZE;
}
// squared_hinge(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/squared_hinge
// DEPRECATED
message SquaredHinge {
option (metric_type) = MINIMIZE;
}
// top_k_categorical_accuracy(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/top_k_categorical_accuracy
message TopKCategoricalAccuracy {
option (metric_type) = MAXIMIZE;
}
// sparse_top_k_categorical_accuracy(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/sparse_top_k_categorical_accuracy
// DEPRECATED
message SparseTopKCategoricalAccuracy {
option (metric_type) = MAXIMIZE;
}
// Binary cross entropy as a metric is equal to the negative log likelihood
// (see logistic regression).
// In addition, when used to solve a binary classification task, binary cross
// entropy implies that the binary label will maximize binary accuracy.
// binary_crossentropy(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/binary_crossentropy
message BinaryCrossEntropy {
option (metric_type) = MINIMIZE;
}
// AKA the negative log likelihood or log loss.
// Given a label y\in {0,1} and a predicted probability p in [0,1]:
// -yln(p)-(1-y)ln(1-p)
// TODO(martinz): if this is interpreted the same as binary_cross_entropy,
// we may need to revisit the semantics.
// DEPRECATED
message LogisticRegression {
option (metric_type) = MINIMIZE;
}
// Area under curve for the ROC-curve.
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/AUC
message AUC {
option (metric_type) = MAXIMIZE;
}
// Area under curve for the precision-recall-curve.
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/AUC
message AUCPrecisionRecall {
option (metric_type) = MAXIMIZE;
}
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/SensitivityAtSpecificity
message SensitivityAtSpecificity {
option (metric_type) = MAXIMIZE;
// Minimal required specificity, (0.0, 1.0).
google.protobuf.DoubleValue specificity = 1;
}
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/SpecificityAtSensitivity
message SpecificityAtSensitivity {
option (metric_type) = MAXIMIZE;
// Minimal required sensitivity, (0.0, 1.0).
google.protobuf.DoubleValue sensitivity = 1;
}
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/PrecisionAtRecall
message PrecisionAtRecall {
option (metric_type) = MAXIMIZE;
// Minimal required recall, (0.0, 1.0).
google.protobuf.DoubleValue recall = 1;
}
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/RecallAtPrecision
message RecallAtPrecision {
option (metric_type) = MAXIMIZE;
// Minimal required precision, (0.0, 1.0).
google.protobuf.DoubleValue precision = 1;
}
message FalseNegativeRateAtThreshold {
option (metric_type) = MAXIMIZE;
// Threshold to apply to a prediction to determine positive vs negative.
// Note: if the model is calibrated, the threshold can be thought of as a
// probability so the threshold has a stable, intuitive semantic.
// However, not all solutions may be calibrated, and not all computations of
// the metric may operate on a calibrated score. In AutoTFX, the final model
// metrics are computed on a calibrated score, but the metrics computed within
// the model selection process are uncalibrated. Be aware of this possible
// skew in the metrics between model selection and final model evaluation.
google.protobuf.DoubleValue threshold = 1;
}
message FalsePositiveRateAtThreshold {
option (metric_type) = MAXIMIZE;
// Threshold to apply to a prediction to determine positive vs negative.
// Note: if the model is calibrated, the threshold can be thought of as a
// probability so the threshold has a stable, intuitive semantic.
// However, not all solutions may be calibrated, and not all computations of
// the metric may operate on a calibrated score. In AutoTFX, the final model
// metrics are computed on a calibrated score, but the metrics computed within
// the model selection process are uncalibrated. Be aware of this possible
// skew in the metrics between model selection and final model evaluation.
google.protobuf.DoubleValue threshold = 1;
}
message PrecisionAtK {
option (metric_type) = MAXIMIZE;
}
message MeanReciprocalRank {}
// https://www.tensorflow.org/responsible_ai/model_remediation/api_docs/python/model_remediation/min_diff/losses/MMDLoss
message MaximumMeanDiscrepancy {
option (metric_type) = MINIMIZE;
// Kernel to apply to the predictions. Currently supported values are
// 'gaussian' and 'laplace'. Defaults to 'gaussian'.
string kernel = 1;
}
// The mean of the prediction across the dataset.
message PredictionMean {}
// Area under ROC-curve calculated globally for MultiClassClassification (model
// predicts a single label) or MultiLabelClassification (model predicts class
// probabilities). The area is calculated by treating the entire set of data as
// an aggregate result, and computing a single metric rather than k metrics
// (one for each target label) that get averaged together. For example, the FPR
// and TPR at a given point on the AUC curve for k targer labels are:
// FPR = (FP1 + FP2 + ... + FPk) / ((FP1 + FP2 + ... + FPk) +
// (TN1 + TN2 + ... + TNk))
// TPR = (TP1 + TP2 + ... +TPk) / ((TP1 + TP2 + ... + TPk) +
// (FN1 + FN2 + ... + FNk))
message MicroAUC {
option (metric_type) = MAXIMIZE;
}
// Cross entropy for MultiLabelClassification where each target and
// prediction is the probabily of belonging to that class independent of other
// classes.
message MultilabelCrossEntropy {
option (metric_type) = MINIMIZE;
}
// DEPRECATED
message BlockUtility {
option (metric_type) = MAXIMIZE;
repeated double weight = 1;
}
// A custom metric.
// Prefer using or adding an explicit metric message
// and only use this generic message as a last resort.
// NEXT_TAG: 4
message CustomMetric {
option (metric_type) = CUSTOM;
// The display name of a metric computed by the model. The name should match
// ^[a-zA-Z0-9\s]{1,25}$ and must be unique across all performance metrics.
// Trailing and leading spaces will be truncated before matching.
string name = 1;
// True if the metric is maximized: false if it is minimized.
// Must be specified if the CustomMetric is used as an objective.
bool is_maximized = 2;
// RegistrySpec is a full specification of the custom metric and its
// construction based on the binary’s metric registry. New custom metrics must
// be linked to the binary and registered in its metric registry to be
// identifiable via this specification.
message RegistrySpec {
// Identifier of the metric class in the metric registry of the binary.
string key = 1;
// Generic proto describing the configuration for the metric to be computed.
// It's upto the implementer of the metric to parse this configuration.
google.protobuf.Any config = 2;
}
// Specification of the metric in the binary’s metric registry.
RegistrySpec registry_spec = 3;
}
// Performance metrics measure the quality of a model. They need not be
// differentiable.
message PerformanceMetric {
oneof performance_metric {
AUC auc = 1;
AUCPrecisionRecall auc_precision_recall = 26;
BinaryAccuracy binary_accuracy = 2;
BinaryCrossEntropy binary_cross_entropy = 3;
BlockUtility block_utility = 4 [deprecated = true];
CategoricalAccuracy categorical_accuracy = 5;
CategoricalCrossEntropy categorical_cross_entropy = 6;
Cosine cosine = 7 [deprecated = true];
Hinge hinge = 8 [deprecated = true];
KullbackLeiblerDivergence kullback_leibler_divergence = 9
[deprecated = true];
LogisticRegression logistic_regression = 10 [deprecated = true];
MeanAbsoluteError mean_absolute_error = 11;
MeanAbsolutePercentageError mean_absolute_percentage_error = 12;
MeanSquaredError squared_error = 13;
MeanSquaredLogarithmicError mean_squared_logarithmic_error = 14;
MeanReciprocalRank mean_reciprocal_rank = 15;
MicroAUC micro_auc = 27;
MultilabelCrossEntropy multi_label_cross_entropy = 28;
Poisson poisson = 16 [deprecated = true];
PrecisionAtK precision_at_k = 17;
SquaredHinge squared_hinge = 18 [deprecated = true];
SparseTopKCategoricalAccuracy sparse_top_k_categorical_accuracy = 19
[deprecated = true];
TopKCategoricalAccuracy top_k_categorical_accuracy = 20;
CustomMetric custom_metric = 21;
SensitivityAtSpecificity sensitivity_at_specificity = 22;
SpecificityAtSensitivity specificity_at_sensitivity = 23;
PrecisionAtRecall precision_at_recall = 24;
RecallAtPrecision recall_at_precision = 25;
}
// NEXT_TAG: 37;
}