def test_rbf_with_dataset(): '''Tests the RBF model with TimeSeriesDataset''' rbf_model = RidgeRBFModel(10, .5, alpha=.01) D = tsio.from_id_row_mat(YOUTUBE_1K, add_eps=1e-6) y = D.np_like_firstn().sum(axis=1) model = rbf_model.fit(D, y) y_pred = model.predict(D) mrse = (((y - y_pred) / y)**2).mean() assert_almost_equal(0, mrse, 4)
def test_rbf_model(): '''Tests the RBF model''' rbf_model = RidgeRBFModel(100, 50, alpha=.00001) D = tsio.from_id_row_mat(YOUTUBE_1K, add_eps=1e-6).np_like_firstn() X_train = D[:500, :7] X_test = D[500:, :7] y_train = D.sum(axis=1)[:500] y_test = D.sum(axis=1)[500:] model = rbf_model.fit(X_train, y_train) y_pred = model.predict(X_test) mrse = (((y_test - y_pred) / y_test)**2).mean() print(mrse) assert_equal(1, mrse > 0) assert_equal(1, mrse < 1)