Diverse Metrics implemented in TensorFlow
Diverse Tensorflow customied metrics used in the ChoiceLearn library.
HitRate
Bases: Metric
Compute Hit Rate at k.
Source code in choice_learn/utils/metrics.py
result()
Compute the current metric value.
Returns:
| Type | Description |
|---|---|
float
|
Negative Log Likelihood value |
update_state(y_true, y_pred, batch=None)
Accumulate statistics for the metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_true |
ndarray
|
Ground Truth value |
required |
y_pred |
ndarray
|
Predicted values |
required |
Source code in choice_learn/utils/metrics.py
MRR
Bases: Metric
Compute Mean Reciprocal Rank.
Source code in choice_learn/utils/metrics.py
result()
Compute the current metric value.
Returns:
| Type | Description |
|---|---|
float
|
Negative Log Likelihood value |
update_state(y_true, y_pred, batch=None)
Accumulate statistics for the metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_true |
ndarray
|
Ground Truth value |
required |
y_pred |
ndarray
|
Predicted values |
required |
Source code in choice_learn/utils/metrics.py
MeanRank
Bases: Metric
Compute Mean Rank.
Source code in choice_learn/utils/metrics.py
result()
Compute the current metric value.
Returns:
| Type | Description |
|---|---|
float
|
Negative Log Likelihood value |
update_state(y_true, y_pred, batch=None)
Accumulate statistics for the metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_true |
ndarray
|
Ground Truth value |
required |
y_pred |
ndarray
|
Predicted values |
required |
Source code in choice_learn/utils/metrics.py
NegativeLogLikeliHood
Bases: Metric
Compute Negative Loglikelihood.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_logits |
bool
|
Whether provided values are logits or probabilities, by default False |
False
|
sparse |
bool
|
Whether y_true is given as an index or a one-hot, by default False |
False
|
epsilon |
float
|
Lower bound for log(.), by default 1e-10 |
1e-10
|
name |
str
|
Name of operation, by default "negative_log_likelihood" |
'negative_log_likelihood'
|
axis |
int
|
axis on which to apply the metric, by default -1 |
-1
|
Source code in choice_learn/utils/metrics.py
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 | |
__init__(from_logits=False, sparse=False, average_on_trip=False, epsilon=1e-10, name='negative_log_likelihood', axis=-1, **kwargs)
Initialize metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_logits |
bool
|
Whether provided values are logits or probabilities, by default False |
False
|
sparse |
bool
|
Whether y_true is given as an index or a one-hot, by default False |
False
|
epsilon |
float
|
Lower bound for log(.), by default 1e-10 |
1e-10
|
average_on_trip |
Whether the metric should be averaged over each trip, by default False |
False
|
|
name |
str
|
Name of operation, by default "negative_log_likelihood" |
'negative_log_likelihood'
|
axis |
int
|
axis on which to apply the metric, by default -1 |
-1
|
Source code in choice_learn/utils/metrics.py
result()
Compute the current metric value.
Returns:
| Type | Description |
|---|---|
float
|
Negative Log Likelihood value |
update_state(y_true, y_pred, batch=None, sample_weight=None)
Accumulate statistics for the metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_true |
ndarray
|
Ground Truth value |
required |
y_pred |
ndarray
|
Predicted values |
required |
sample_weight |
ndarray
|
sample wise weight, by default None |
None
|