tfma.metrics.specs_from_metrics
Stay organized with collections
Save and categorize content based on your preferences.
Returns specs for tf_keras.metrics/losses or tfma.metrics classes.
tfma.metrics.specs_from_metrics(
metrics: Optional[_MetricsOrLosses] = None,
unweighted_metrics: Optional[_MetricsOrLosses] = None,
model_names: Optional[List[str]] = None,
output_names: Optional[List[str]] = None,
output_weights: Optional[Dict[str, float]] = None,
binarize: Optional[tfma.BinarizationOptions
] = None,
aggregate: Optional[tfma.AggregationOptions
] = None,
query_key: Optional[str] = None,
include_example_count: Optional[bool] = None,
include_weighted_example_count: Optional[bool] = None
) -> List[tfma.MetricsSpec
]
Examples |
metrics_specs = specs_from_metrics(
[
tf_keras.metrics.BinaryAccuracy(),
tfma.metrics.AUC(),
tfma.metrics.MeanLabel(),
tfma.metrics.MeanPrediction()
...
],
unweighted=[
tfma.metrics.Precision(),
tfma.metrics.Recall()
])
metrics_specs = specs_from_metrics({
'output1': [
tf_keras.metrics.BinaryAccuracy(),
tfma.metrics.AUC(),
tfma.metrics.MeanLabel(),
tfma.metrics.MeanPrediction()
...
],
'output2': [
tfma.metrics.Precision(),
tfma.metrics.Recall(),
]
})
|
Args |
metrics
|
List of tfma.metrics.Metric, tf_keras.metrics.Metric, or
tf_keras.losses.Loss. For multi-output models a dict of dicts may be
passed where the first dict is indexed by the output_name. Whether these
metrics are weighted or not will be determined based on whether the
ModelSpec associated with the metrics contains example weight key settings
or not.
|
unweighted_metrics
|
Same as metrics only these metrics will not be weighted
by example_weight regardless of the example weight key settings.
|
model_names
|
Optional model names (if multi-model evaluation).
|
output_names
|
Optional output names (if multi-output models). If the metrics
are a dict this should not be set.
|
output_weights
|
Optional output weights for creating overall metric
aggregated across outputs (if multi-output model). If a weight is not
provided for an output, it's weight defaults to 0.0 (i.e. output ignored).
|
binarize
|
Optional settings for binarizing multi-class/multi-label metrics.
|
aggregate
|
Optional settings for aggregating multi-class/multi-label
metrics.
|
query_key
|
Optional query key for query/ranking based metrics.
|
include_example_count
|
True to add example_count metric. Default is True.
|
include_weighted_example_count
|
True to add weighted example_count metric.
Default is True. A weighted example count will be added per output for
multi-output models.
|
Returns |
MetricsSpecs based on options provided. A separate spec is returned for
weighted vs unweighted metrics. A separate spec is also returned for each
output if a dict of metrics per output is passed.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-04-26 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2024-04-26 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[]]