View source on GitHub |
Computes F-Beta score.
Inherits From: Metric
tf.keras.metrics.FBetaScore(
average=None,
beta=1.0,
threshold=None,
name='fbeta_score',
dtype=None
)
Formula:
b2 = beta ** 2
f_beta_score = (1 + b2) * (precision * recall) / (precision * b2 + recall)
This is the weighted harmonic mean of precision and recall.
Its output range is [0, 1]
. It works for both multi-class
and multi-label classification.
Returns | |
---|---|
F-Beta Score: float. |
Example:
metric = keras.metrics.FBetaScore(beta=2.0, threshold=0.5)
y_true = np.array([[1, 1, 1],
[1, 0, 0],
[1, 1, 0]], np.int32)
y_pred = np.array([[0.2, 0.6, 0.7],
[0.2, 0.6, 0.6],
[0.6, 0.8, 0.0]], np.float32)
metric.update_state(y_true, y_pred)
result = metric.result()
result
[0.3846154 , 0.90909094, 0.8333334 ]
Attributes | |
---|---|
dtype
|
|
variables
|
Methods
add_variable
add_variable(
shape, initializer, dtype=None, aggregation='sum', name=None
)
add_weight
add_weight(
shape=(), initializer=None, dtype=None, name=None
)
from_config
@classmethod
from_config( config )
get_config
get_config()
Returns the serializable config of the metric.
reset_state
reset_state()
Reset all of the metric state variables.
This function is called between epochs/steps, when a metric is evaluated during training.
result
result()
Compute the current metric value.
Returns | |
---|---|
A scalar tensor, or a dictionary of scalar tensors. |
stateless_reset_state
stateless_reset_state()
stateless_result
stateless_result(
metric_variables
)
stateless_update_state
stateless_update_state(
metric_variables, *args, **kwargs
)
update_state
update_state(
y_true, y_pred, sample_weight=None
)
Accumulate statistics for the metric.
__call__
__call__(
*args, **kwargs
)
Call self as a function.