Metric wrappers and reduction metrics
Mean
Bases: Metric
Compute the mean of the given values.
For example, if values is [1, 3, 5, 7] then the mean is 4.
This metric creates two variables, total and count.
The mean value returned is simply total divided by count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
(Optional) string name of the metric instance. |
'mean'
|
in_mask
|
list
|
(Optional) list of keys to keep to compute the metric. |
None
|
out_mask
|
list
|
(Optional) list of keys to remove to compute the metric. |
None
|
in_mask_pattern
|
str
|
(Optional) Regex pattern; fields whose names match
are kept (combined with |
None
|
out_mask_pattern
|
str
|
(Optional) Regex pattern; fields whose names match
are dropped (combined with |
None
|
Example:
Source code in synalinks/src/metrics/reduction_metrics.py
MeanMetricWrapper
Bases: Mean
Wrap a stateless metric function with the Mean metric.
You could use this class to quickly build a mean metric from a function. The
function needs to have the signature fn(y_true, y_pred) and return a
per-sample reward array. MeanMetricWrapper.result() will return
the average metric value across all samples seen so far.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
callable
|
The metric function to wrap, with signature
|
required |
name
|
str
|
(Optional) string name of the metric instance. |
None
|
in_mask
|
list
|
(Optional) list of keys to keep to compute the metric. |
None
|
out_mask
|
list
|
(Optional) list of keys to remove to compute the metric. |
None
|
in_mask_pattern
|
str
|
(Optional) Regex pattern; fields whose names match
are kept (combined with |
None
|
out_mask_pattern
|
str
|
(Optional) Regex pattern; fields whose names match
are dropped (combined with |
None
|
**kwargs
|
keyword arguments
|
Keyword arguments to pass on to |
{}
|
Source code in synalinks/src/metrics/reduction_metrics.py
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 | |
get_config()
Returns the serializable config of the metric.
Source code in synalinks/src/metrics/reduction_metrics.py
Sum
Bases: Metric
Compute the (weighted) sum of the given values.
For example, if values is [1, 3, 5, 7] then their sum is 16.
This metric creates one variable, total.
This is ultimately returned as the sum value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
(Optional) string name of the metric instance. |
'sum'
|
in_mask
|
list
|
(Optional) list of keys to keep to compute the metric. |
None
|
out_mask
|
list
|
(Optional) list of keys to remove to compute the metric. |
None
|
in_mask_pattern
|
str
|
(Optional) Regex pattern; fields whose names match
are kept (combined with |
None
|
out_mask_pattern
|
str
|
(Optional) Regex pattern; fields whose names match
are dropped (combined with |
None
|
Example: