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

Compute metrics for given time period

  • 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


from sklearn import metrics rng = pd.date_range(“1/1/2012”, periods=10, freq=”S”) new = dict(x=range(len(rng)), y = range(len(rng))) df = pd.DataFrame(new, index = rng).reset_index(inplace=True) td = timedelta(seconds = 2) metric_set = [sklearn.metrics.mean_squared_error, sklearn.metrics.mean_absolute_error] compute_metrics(df, “index”, td, metric_set=metric_set, truth=”x”, estimate=”y”)