def evaluate_sklearn_metric(f, y, k:int, a=None, t=None, e=None, r=None, metric=None, n_burn=None)->float:
    """ Compute prior for skater and evaluate an sklearn metric """
    assert metric is not None
    assert n_burn is not None
    x, x_std = prior(f=f, y=y, k=k, a=a, t=t, r=r, e=e )
    yt = targets(y)
    xk = [ xt[-1] for xt in x ]  # k-steps ahead
    return metric(yt[n_burn:], xk[n_burn:] )
Beispiel #2
0
def prior_plot(f,
               y=None,
               k=None,
               t=None,
               e=None,
               r=None,
               x0=np.nan,
               n=150,
               n_plot=25):
    """
         Apply state machine to univariate series,
         Show observations and out of sample predictions predictions
    """
    if y is None:
        y = brownian_with_noise(n=n)

    if t is None:
        t = range(len(y))

    x, x_std = prior(f=f, y=y, k=k, a=t, t=t, e=e, r=r, x0=x0)
    ysf = [[y_] for y_ in y]
    xk = [xt[-1] for xt in x]
    plot_with_last_value(t=t, x=xk, y=ysf, k=k, n_plot=n_plot)
Beispiel #3
0
def prior_plot_exogenous(f,
                         y=None,
                         k=None,
                         a=None,
                         t=None,
                         e=None,
                         r=None,
                         x0=np.nan,
                         n=150,
                         n_plot=25):
    """
          Apply state machine to univariate series,
          Show observations, out of sample predictions predictions, and exogenous variables
     """
    if y is None:
        y = brownian_with_exogenous(n)

    if t is None:
        t = range(len(y))

    x, x_std = prior(f=f, y=y, k=k, a=a, t=t, e=e, r=r, x0=x0)
    xk = [xt[-1] for xt in x]
    plot_with_last_value(t=t, x=xk, y=y, k=k, n_plot=n_plot)