tf.keras.metrics.ConcordanceCorrelation

Calculates the Concordance Correlation Coefficient (CCC).

Inherits From: MeanMetricWrapper, Mean, Metric

CCC evaluates the agreement between true values (y_true) and predicted values (y_pred) by considering both precision and accuracy. The coefficient ranges from -1 to 1, where a value of 1 indicates perfect agreement.

This metric is useful in regression tasks where it is important to assess how well the predictions match the true values, taking into account both their correlation and proximity to the 45-degree line of perfect concordance.

name (Optional) string name of the metric instance.
dtype (Optional) data type of the metric result.
axis (Optional) integer or tuple of integers of the axis/axes along which to compute the metric. Defaults to -1.

Example:

ccc = keras.metrics.ConcordanceCorrelation(axis=-1)
y_true = [[0, 1, 0.5], [1, 1, 0.2]]
y_pred = [[0.1, 0.9, 0.5], [1, 0.9, 0.2]]
ccc.update_state(y_true, y_pred)
ccc.result()
0.9816320385426076

Usage with compile() API:

model.compile(optimizer='sgd',
              loss='mean_squared_error',
              metrics=[keras.metrics.ConcordanceCorrelation()])

dtype

variables

Methods

add_variable

View source

add_weight

View source

from_config

View source

get_config

View source

Return the serializable config of the metric.

reset_state

View source

Reset all of the metric state variables.

This function is called between epochs/steps, when a metric is evaluated during training.

result

View source

Compute the current metric value.

Returns
A scalar tensor, or a dictionary of scalar tensors.

stateless_reset_state

View source

stateless_result

View source

stateless_update_state

View source

update_state

View source

Accumulate statistics for the metric.

__call__

View source

Call self as a function.