pin_metrics

pin_metrics(board, df_metrics, metrics_pin_name, pin_type=None, index_name='index', overwrite=False)

Update an existing pin storing model metrics over time

Parameters

Name Type Description Default
board Pins board required
df_metrics pd.DataFrame Dataframe of metrics over time, such as created by vetiver_compute_metrics() required
metrics_pin_name str Pin name for where the metrics are stored required
index_name str The column in df_metrics containing the aggregated dates or datetimes. Note that this defaults to a column named “index”. 'index'
overwrite bool If True, overwrite any metrics for dates that exist both in the existing pin and new metrics with the new values. If False, error when the new metrics contain overlapping dates with the existing pin. False

Examples

>>> import pins
>>> import vetiver
>>> 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}}
... )
>>> board = pins.board_temp()
>>> board.pin_write(df, "metrics", type = "csv")
>>> df = pd.DataFrame(
... {'index': {0: pd.Timestamp('2021-01-02 00:00:00'),
...            1: pd.Timestamp('2021-01-02 00:00:00'),
...            2: pd.Timestamp('2021-01-03 00:00:00'),
...            3: pd.Timestamp('2021-01-03 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: 6.0, 2: 2.0, 3: 1.0}}
... )
>>> vetiver.pin_metrics(
...    board=board,
...    df_metrics=df2,
...    metrics_pin_name="metrics",
...    index_name="index",
...    overwrite=True)