Skip to main content

GradientDrift uses JAX to fit econometric models on datasets that do not fit in memory.

Project description

GradientDrift

PyPI Version Python Versions Tests License

GradientDrift is a Python library for high-performance econometric time series analysis, specifically designed for datasets that are too large to fit into memory. It leverages the power of JAX for hardware acceleration (CPU/GPU/TPU) and just-in-time (JIT) compilation of models.

⚠️ Under Active Development

This project is currently in a pre-release (beta) stage. The API may change in future versions, and while thoroughly tested, some model implementations should be considered experimental. We welcome feedback and contributions to stabilize and improve the library!


Key Features

  • Memory Efficient: Processes data in batches, allowing you to train models on datasets of any size.
  • High-Performance: Uses JAX to JIT-compile and accelerate model fitting, making it significantly faster than traditional libraries for many workloads.
  • Classic Models, Modern Backend: Implements standard econometric models like VAR (Vector Autoregression) and GARCH with a modern, functional, and hardware-agnostic backend.
  • Clean API: A simple, intuitive interface for defining, fitting, and predicting with your models.

Installation

You can install GradientDrift directly from PyPI:

pip install gradientdrift

Quickstart

Here is a simple example of how to use GradientDrift to fit a VAR model on a sample dataset.

import jax
import pandas as pd
import gradientdrift as gd 

numberOfLags = 1
numberOfVariables = 2

# The dataset object also accepts numpy arrays
data = gd.data.Dataset(pd.read_csv("test_data.csv"))

# Use any of the models, the fit and summary syntax bellow will be equivalent
model = gd.models.VAR(numberOfLags = numberOfLags, numberOfVariables = numberOfVariables)

# Fit the model (default uses ADAM optimizer)
model.fit(data, batchSize = 100)

# Optionally, provide the data to the summary function, this will calculate the confidence interval (but can be expensive)
model.summary(data)

# Alternative optimizers:
model.fit(data, optimizer="lbfgs")
model.fit(data, optimizer="ClosedForm")

A GARCH example where we first simulate data using a model specification:

# Define the true parameters of a model
trueParams = {
    'mu': 0.05,
    'logOmega': jax.numpy.log(0.1),
    'logAlpha': jax.numpy.log(0.1),
    'logBeta': jax.numpy.log(0.85)
}

# Define a model
generatorModel = gd.models.GARCH(p=1, q=1)
generatorModel.setParameters(trueParams)
initialValues = generatorModel.getInitialValues()

# Simulate data
simulatedData = generatorModel.simulate(initialValues, steps=1000000)

# Put in a dataset container for batching
data = gd.data.Dataset(simulatedData)

# Fit the model
model = gd.models.GARCH(p = 1, q = 1)
model.fit(data)
model.summary(data, trueParams = trueParams) # Provide true params to show in the coefficient table

Contributing

Contributions are welcome! Whether it's bug reports, feature requests, or new model implementations, your help is appreciated.

Please feel free to open an issue on the GitHub Issue Tracker to start a discussion. If you plan to contribute code, please see the (forthcoming) CONTRIBUTING.md file for guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

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

Source Distribution

gradientdrift-0.2.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gradientdrift-0.2.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file gradientdrift-0.2.0.tar.gz.

File metadata

  • Download URL: gradientdrift-0.2.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for gradientdrift-0.2.0.tar.gz
Algorithm Hash digest
SHA256 522b25981bcc2f8cdf691bc13b88dc133d39dc945ca4abd49747ec64e9d6b5f8
MD5 e79104db1553371e74ada3e3975006d5
BLAKE2b-256 60e70669ebf08346bc328070ab74f559a01f541e0da0127099909e7b4fca3e45

See more details on using hashes here.

File details

Details for the file gradientdrift-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: gradientdrift-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for gradientdrift-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 811ef0fdd84bbc07d3e7ce8e56c3611c35d41e7b6ad7a5579d5263c8fb1036f6
MD5 f70fb9711176224dfc6aeff086414219
BLAKE2b-256 ff3fd4902e448678fc184c0c8b4bac514bc2e1a5f4b9ca9f9e3198ab6166507c

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