-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pointwise error computation to method and add to forecasting unit…
… test
- Loading branch information
1 parent
dcdab7a
commit fe696a9
Showing
3 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .metrics import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import xarray as xr | ||
from deepsensor.model.pred import Prediction | ||
|
||
|
||
def compute_errors(pred: Prediction, target: xr.Dataset) -> xr.Dataset: | ||
""" | ||
Compute errors between predictions and targets. | ||
Args: | ||
pred: Prediction object. | ||
target: Target data. | ||
Returns: | ||
xr.Dataset: Dataset of pointwise differences between predictions and targets | ||
at the same valid time in the predictions. Note, the difference is positive | ||
when the prediction is greater than the target. | ||
""" | ||
errors = {} | ||
for var_ID, pred_var in pred.items(): | ||
target_var = target[var_ID] | ||
error = pred_var["mean"] - target_var.sel(time=pred_var.time) | ||
error.name = f"{var_ID}" | ||
errors[var_ID] = error | ||
return xr.Dataset(errors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters