Quickstart
This is a short introduction to wavy
, geared mainly for new users.
[1]:
# Import libraries
import numpy as np
import pandas as pd
import wavy
from wavy import models
import plotly.io as pio
pio.renderers.default = 'pdf'
[2]:
# Start with any time series dataframe
df = pd.DataFrame({'price': np.random.randn(1000)}, index=range(1000))
[3]:
# Create panels. Each panel is composed of a list of frames.
x, y = wavy.create_panels(df, lookback=10, horizon=1)
[4]:
# Set training split
wavy.set_training_split(x, y, train_size=0.4, val_size=0.3, test_size=0.3)
[5]:
# x and y are contain the past and corresponding future data.
# lookback and horizon are the number of timesteps.
print("Lookback:", x.num_timesteps, "Horizon:", y.num_timesteps)
Lookback: 10 Horizon: 1
[6]:
# Plot the target.
y.plot()
[7]:
# Convert to numpy arrays
x_train, y_train = x.train.values, y.train.values
x_test, y_test = x.test.values, y.test.values
print(x_train.shape, y_train.shape)
(3960, 1) (396, 1)
[ ]:
# Or just instantiate a model.
model = models.LinearRegression(x, y)
model.score()