Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
machine-learning
MLAir
Merge requests
!418
Resolve "add metric MNMB"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "add metric MNMB"
lukas_issue380_feat_add-metric-mnmb
into
develop
Overview
0
Commits
1
Pipelines
2
Changes
2
Merged
Ghost User
requested to merge
lukas_issue380_feat_add-metric-mnmb
into
develop
2 years ago
Overview
0
Commits
1
Pipelines
2
Changes
2
Expand
Closes
#380 (closed)
Edited
2 years ago
by
Ghost User
0
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
59ae0b88
1 commit,
2 years ago
2 files
+
54
−
3
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
mlair/helpers/statistics.py
+
16
−
2
Options
@@ -225,14 +225,28 @@ def index_of_agreement(a, b, dim=None):
return
1
-
frac
def
modified_normalized_mean_bias
(
a
,
b
,
dim
=
None
):
"""
Calculate modified normalized mean bias (MNMB) where a is the forecast and b the reference (e.g. observation).
"""
N
=
np
.
count_nonzero
(
a
)
if
len
(
a
.
shape
)
==
1
else
a
.
notnull
().
sum
(
dim
)
return
2
*
((
a
-
b
)
/
(
a
+
b
)).
sum
(
dim
)
/
N
def
calculate_error_metrics
(
a
,
b
,
dim
):
"""
Calculate MSE, RMSE, MAE, and IOA. Aditionally, return number of used values for calculation.
"""
"""
Calculate MSE, RMSE, MAE, IOA, and MNMB. Additionally, return number of used values for calculation.
:param a: forecast data to calculate metrics for
:param b: reference (e.g. observation)
:param dim: dimension to calculate metrics along
:returns: dict with results for all metrics indicated by lowercase metric short name
"""
mse
=
mean_squared_error
(
a
,
b
,
dim
)
rmse
=
np
.
sqrt
(
mse
)
mae
=
mean_absolute_error
(
a
,
b
,
dim
)
ioa
=
index_of_agreement
(
a
,
b
,
dim
)
mnmb
=
modified_normalized_mean_bias
(
a
,
b
,
dim
)
n
=
(
a
-
b
).
notnull
().
sum
(
dim
)
return
{
"
mse
"
:
mse
,
"
rmse
"
:
rmse
,
"
mae
"
:
mae
,
"
ioa
"
:
ioa
,
"
n
"
:
n
}
return
{
"
mse
"
:
mse
,
"
rmse
"
:
rmse
,
"
mae
"
:
mae
,
"
ioa
"
:
ioa
,
"
mnmb
"
:
mnmb
,
"
n
"
:
n
}
def
mann_whitney_u_test
(
data
:
pd
.
DataFrame
,
reference_col_name
:
str
,
**
kwargs
):
Loading