Skip to main content

A library for automatically finding the optimal model within feature and hyperparameter space.

Project description

wavetrainer

PyPi

A library for automatically finding the optimal model within feature and hyperparameter space on time series models.

wavetrain

Dependencies :globe_with_meridians:

Python 3.11.6:

Raison D'être :thought_balloon:

wavetrainer aims to split out the various aspects of creating a good model into different composable pieces and searches the space of these different pieces to find an optimal model. This came about after doing code like this multiple times on multiple projects. This is specifically geared towards time series models, validating itself through walk-forward analysis.

Architecture :triangular_ruler:

wavetrainer is an object orientated library. The entities are organised like so:

  • Trainer: A sklearn compatible object that can fit and predict data.
    • Reducer: An object that can reduce the feature space based on heuristics.
    • Weights: An object that adds weights to the features.
    • Selector: An object that can select which features to include from the training set.
    • Calibrator: An object that can calibrate the probabilities produced by the model.
    • Model: An object that represents the underlying model architecture being used.
    • Windower: An object that represents the lookback window of the data.

Installation :inbox_tray:

This is a python package hosted on pypi, so to install simply run the following command:

pip install wavetrainer

or install using this local repository:

python setup.py install --old-and-unmanageable

Usage example :eyes:

The use of wavetrainer is entirely through code due to it being a library. It attempts to hide most of its complexity from the user, so it only has a few functions of relevance in its outward API.

Training

To train a model:

import wavetrainer as wt
import pandas as pd
import numpy as np
import random

data_size = 10
df = pd.DataFrame(
    np.random.randint(0, 30, size=data_size),
    columns=["X"],
    index=pd.date_range("20180101", periods=data_size),
)
df["Y"] = [random.choice([True, False]) for _ in range(data_size)]

X = df["X"]
Y = df["Y"]

wavetrainer = wt.create("my_wavetrain")
wavetrainer = wavetrainer.fit(X, y=Y)

This will save it to the folder my_wavetrain.

Load

To load a trainer (as well as its composite states):

import wavetrainer as wt

wavetrainer = wt.load("my_wavetrain")

Predict

To make a prediction from new data:

import wavetrainer as wt
import pandas as pd
import numpy as np

wavetrainer = wt.load("my_wavetrain")
data_size = 1
df = pd.DataFrame(
    np.random.randint(0, 30, size=data_size),
    columns=["X"],
    index=pd.date_range("20180101", periods=data_size),
)
X = df["X"]

preds = wavetrainer.predict(X)

preds will now contain both the predictions and the probabilities associated with those predictions.

License :memo:

The project is available under the MIT License.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wavetrainer-0.0.26.tar.gz (23.1 kB view details)

Uploaded Source

File details

Details for the file wavetrainer-0.0.26.tar.gz.

File metadata

  • Download URL: wavetrainer-0.0.26.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for wavetrainer-0.0.26.tar.gz
Algorithm Hash digest
SHA256 50645c0a28a4c7cf8bd14da4cdfbabc6065f238ebc55ce83e5f3b911bcf6e42b
MD5 735e6f6943557b8b84e3c7eca117efad
BLAKE2b-256 ae9fcf085fff9c019fb21551ae6310201fe652df6d5db22d8f34392d229c479a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page