Skip to content

Commit

Permalink
Add mean error metric (#203)
Browse files Browse the repository at this point in the history
* Add mean error metric

* Update docstring remove rmse

* Update docstring

* precomit

* Add me to init and create docs

* iResort

* Comments fixed

Co-authored-by: ahuang11 <[email protected]>
  • Loading branch information
ahuang11 and ahuang11 authored Oct 7, 2020
1 parent e0c9667 commit 5252261
Show file tree
Hide file tree
Showing 57 changed files with 194 additions and 59 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Changelog History
xskillscore v0.0.19 (2020-XX-XX)
--------------------------------

Features
~~~~~~~~
- Added mean error
:py:func:`~xskillscore.me`. (:issue:`202`, :pr:`200`)
`Andrew Huang`_

Internal Changes
~~~~~~~~~~~~~~~~
- Added Python 3.7 and Python 3.8 to the CI. Use the latest version of Python 3
Expand Down
1 change: 1 addition & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Distance Metrics
.. autosummary::
:toctree: api/

me
rmse
mse
mae
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.accuracy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.accuracy
.. automethod:: Contingency.accuracy
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.bias_score.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.bias_score
.. automethod:: Contingency.bias_score
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.correct_negatives
.. automethod:: Contingency.correct_negatives
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.equit_threat_score
.. automethod:: Contingency.equit_threat_score
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.false_alarm_rate
.. automethod:: Contingency.false_alarm_rate
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.false_alarm_ratio
.. automethod:: Contingency.false_alarm_ratio
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.false_alarms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.false_alarms
.. automethod:: Contingency.false_alarms
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.gerrity_score.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.gerrity_score
.. automethod:: Contingency.gerrity_score
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.heidke_score.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.heidke_score
.. automethod:: Contingency.heidke_score
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.hit_rate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.hit_rate
.. automethod:: Contingency.hit_rate
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.hits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.hits
.. automethod:: Contingency.hits
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.misses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.misses
.. automethod:: Contingency.misses
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.odds_ratio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.odds_ratio
.. automethod:: Contingency.odds_ratio
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.odds_ratio_skill_score
.. automethod:: Contingency.odds_ratio_skill_score
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.peirce_score.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.peirce_score
.. automethod:: Contingency.peirce_score
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
~Contingency.observations
~Contingency.table



2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.success_ratio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.success_ratio
.. automethod:: Contingency.success_ratio
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autoproperty:: Contingency.table
.. autoproperty:: Contingency.table
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.Contingency.threat_score.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. automethod:: Contingency.threat_score
.. automethod:: Contingency.threat_score
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.brier_score.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: brier_score
.. autofunction:: brier_score
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.crps_ensemble.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: crps_ensemble
.. autofunction:: crps_ensemble
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.crps_gaussian.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: crps_gaussian
.. autofunction:: crps_gaussian
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.crps_quadrature.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: crps_quadrature
.. autofunction:: crps_quadrature
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.discrimination.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: discrimination
.. autofunction:: discrimination
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.effective_sample_size.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: effective_sample_size
.. autofunction:: effective_sample_size
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.mae.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: mae
.. autofunction:: mae
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.mape.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: mape
.. autofunction:: mape
6 changes: 6 additions & 0 deletions docs/source/api/xskillscore.me.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
xskillscore.me
================

.. currentmodule:: xskillscore

.. autofunction:: me
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.median_absolute_error.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: median_absolute_error
.. autofunction:: median_absolute_error
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.mse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: mse
.. autofunction:: mse
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.pearson_r.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: pearson_r
.. autofunction:: pearson_r
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.pearson_r_eff_p_value.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: pearson_r_eff_p_value
.. autofunction:: pearson_r_eff_p_value
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.pearson_r_p_value.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: pearson_r_p_value
.. autofunction:: pearson_r_p_value
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.r2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: r2
.. autofunction:: r2
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.rank_histogram.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: rank_histogram
.. autofunction:: rank_histogram
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.reliability.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: reliability
.. autofunction:: reliability
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.rmse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: rmse
.. autofunction:: rmse
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.rps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: rps
.. autofunction:: rps
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.sign_test.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: sign_test
.. autofunction:: sign_test
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.smape.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: smape
.. autofunction:: smape
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.spearman_r.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: spearman_r
.. autofunction:: spearman_r
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.spearman_r_eff_p_value.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: spearman_r_eff_p_value
.. autofunction:: spearman_r_eff_p_value
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.spearman_r_p_value.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: spearman_r_p_value
.. autofunction:: spearman_r_p_value
2 changes: 1 addition & 1 deletion docs/source/api/xskillscore.threshold_brier_score.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

.. currentmodule:: xskillscore

.. autofunction:: threshold_brier_score
.. autofunction:: threshold_brier_score
1 change: 1 addition & 0 deletions docs/source/quick-start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"\n",
"### Distance-Based\n",
"\n",
"* Mean Error (`me`)\n",
"* Root Mean Squared Error (`rmse`)\n",
"* Mean Squared Error (`mse`)\n",
"* Mean Absolute Error (`mae`)\n",
Expand Down
1 change: 1 addition & 0 deletions xskillscore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
effective_sample_size,
mae,
mape,
me,
median_absolute_error,
mse,
pearson_r,
Expand Down
6 changes: 6 additions & 0 deletions xskillscore/core/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
effective_sample_size,
mae,
mape,
me,
median_absolute_error,
mse,
pearson_r,
Expand Down Expand Up @@ -84,6 +85,11 @@ def spearman_r_eff_p_value(self, a, b, *args, **kwargs):
b = self._in_ds(b)
return spearman_r_eff_p_value(a, b, *args, **kwargs)

def me(self, a, b, *args, **kwargs):
a = self._in_ds(a)
b = self._in_ds(b)
return me(a, b, *args, **kwargs)

def rmse(self, a, b, *args, **kwargs):
a = self._in_ds(a)
b = self._in_ds(b)
Expand Down
Loading

0 comments on commit 5252261

Please sign in to comment.