plot_metrics

plot_metrics(df_metrics, date, estimate, metric, n, **kw)

Plot metrics over a given time period

Parameters

df_metrics : DataFrame

Pandas dataframe of metrics over time, such as created by compute_metrics()

date : = 'index'

Name of column in df_metrics containing dates

estimate : = 'estimate'

Name of column in df_metrics containing metric output

metric : = 'metric'

Name of column in df_metrics containing metric name

n : = 'n'

Name of column in df_metrics containing number of observations

Returns

: plotly.express.line

A plotly line plot is returned with metrics over time

Examples

First, we will set up some example data.

import vetiver
import pandas as pd

# Example data
df = pd.DataFrame(
{'index': {0: pd.Timestamp('2021-01-01 00:00:00'),
           1: pd.Timestamp('2021-01-01 00:00:00'),
           2: pd.Timestamp('2021-01-02 00:00:00'),
           3: pd.Timestamp('2021-01-02 00:00:00')},
 'n': {0: 1, 1: 1, 2: 1, 3: 1},
 'metric': {0: 'mean_squared_error',
            1: 'mean_absolute_error',
            2: 'mean_squared_error',
            3: 'mean_absolute_error'},
 'estimate': {0: 4.0, 1: 2.0, 2: 1.0, 3: 1.0}}
)

plot = vetiver.plot_metrics(
    df_metrics = df,
    date = "index",
    estimate = "estimate",
    metric = "metric",
    n = "n")

plot.show()