vetiver.compute_metrics#

vetiver.compute_metrics(data: pandas.core.frame.DataFrame, date_var: str, period: datetime.timedelta, metric_set: list, truth: str, estimate: str, **kw) pandas.core.frame.DataFrame#

Compute metrics for given time period

Parameters
  • data (DataFrame) – Pandas dataframe

  • date_var – Column in data containing dates

  • period (datetime.timedelta) – Defining period to group by

  • metric_set (list) – List of metrics to compute, that have the parameters y_true and y_pred

  • truth – Column name for true results

  • estimate – Column name for predicted results

Example

>>> from datetime import timedelta
>>> import pandas as pd
>>> from sklearn.metrics import mean_squared_error, mean_absolute_error
>>> df = pd.DataFrame(
...   {
...        "index": ["2021-01-01", "2021-01-02", "2021-01-03"],
...        "truth": [200, 201, 199],
...        "pred": [198, 200, 199],
...   }
... )
>>> td = timedelta(days = 1)
>>> metric_set = [mean_squared_error, mean_absolute_error]
>>> metrics = compute_metrics(df, "index", td, metric_set, "truth", "pred")