Example #1
0
]

p3 = [
    dict(name='mscale', value=1.0, transform='fixed'),
    dict(name='lscale', value=2.607e02, transform='log'),
    dict(name='sigv', value=0.0, transform='fixed'),
]

# Matérn 3/2 for short-term effects
p4 = [
    dict(name='mscale', value=4.595e-01, transform='log'),
    dict(name='lscale', value=6.359e-01, transform='log'),
    dict(name='sigv', value=0.0, transform='fixed'),
]

k1 = Matern52(p1, name='k1')
k2 = Periodic(p2, name='k2')
k3 = Matern32(p3, name='k3')
k4 = Matern32(p4, name='k4')

# Compose covariance function
K = k1 + k2 * k3 + k4
reg = Regressor(K)

fit_summary, corr_matrix, opt_summary = reg.fit(df=df, outputs='CO2_fit')
print(f'\n{fit_summary}')

# generate new prediction time instants
tnew = np.arange(1958, 2030, 0.01)
ym, ysd = reg.predict(df=df, outputs='CO2_pred', smooth=True, tnew=tnew)
Example #2
0
def matern52():
    return Matern52(name='m52')
Example #3
0
    save_model('test', Regressor(None))
    load_reg = load_model('test')

    assert load_reg.__version__ == __version__


@pytest.mark.parametrize(
    'ss,size_kb',
    [
        pytest.param(TwTi_RoRiAwAicv(), 4, id="rc_model"),
        pytest.param(Matern12(), 17, id="gp_model"),
        pytest.param(Periodic() * Matern12(), 32, id="gp_product"),
        pytest.param(
            TwTiTm_RoRiRmRbAwAicv(latent_forces='Qv') <=
            Periodic() * Matern52() + Matern52(),
            237,
            id="lfm_model",
        ),
    ],
)
def test_model_pickle_file_size_limit(ss, size_kb):
    model = Regressor(ss)
    model.ss.parameters.theta = np.random.uniform(
        1e-1, 1, len(model.ss.parameters.theta))
    model.ss.update_continuous_dssm()

    save_model('big', model)
    size = os.path.getsize('big.pickle')
    os.remove('big.pickle')