Skip to main content

NODEFit

Downloads

Fit time-series data with a Neural Differential Equation!

This repository contains time-series data fit capabilities using both Neural Ordinary Differential Equations and Neural Stochastic Differential Equations

GPU support is packaged as part of PyTorch

Also checkout its Julia version

How to install and execute?

Tested on Python 3.9

Just run

pip install nodefit

The following program illustrates a basic example

import numpy as np
import torch.nn as nn
from nodefit.constants import DEVICE

from nodefit.neural_ode import NeuralODE
from nodefit.neural_sde import NeuralSDE


###
# DEFINE NETWORKS
###

# Neural ODE parameters
ndim, drift_nhidden, diffusion_nhidden = 2, 10, 2

drift_nn = nn.Sequential(
    nn.Linear(ndim+1, drift_nhidden),
    nn.Sigmoid(),
    nn.Linear(drift_nhidden, ndim)
).double().to(DEVICE)

diffusion_nn = nn.Sequential(
    nn.Linear(ndim+1, diffusion_nhidden),
    nn.Sigmoid(),
    nn.Linear(diffusion_nhidden, ndim)
).double().to(DEVICE)

###
# PROVIDE DATA
###

# Training between data for 0 and 5 seconds
t = np.linspace(0, 5, 10)
# Provide data as list of lists with starting condition
data = np.array([[...]])

###
# FIT USING NEURALODE
###
print('Performing fit using Neural ODE...')

neural_ode = NeuralODE(drift_nn, t, data)
neural_ode.train(2000)

# # Extrapolate the training data to 10 seconds
extra_data = neural_ode.extrapolate(10)
neural_ode.plot(extra_data)

###
# FIT USING NEURALSDE
###
print('Performing fit using Neural SDE...')

neural_sde = NeuralSDE(drift_nn, diffusion_nn, t, data)
neural_sde.train(1)

# # Extrapolate the training data to 10 seconds
extra_data = neural_sde.extrapolate(10)
neural_sde.plot(extra_data)

Sample Output

Sample Output

Whom to contact?

Please direct your queries to gpavanb1 for any questions.

Acknowledgements

This package would not be possible without the supporting packages - torchdiffeq and torchsde

Download files

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

Source Distribution

nodefit-0.2.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

nodefit-0.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file nodefit-0.2.tar.gz.

File metadata

  • Download URL: nodefit-0.2.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for nodefit-0.2.tar.gz
Algorithm Hash digest
SHA256 008829325c4b35b5b3a79ba22f2babe503d06aba863143ba7729f11ccafc80f5
MD5 b5cd7563a8412947bc2dab6dff6e5e45
BLAKE2b-256 9af8e06b9a04dffdd292bb7fd3a3795e900cffbfe4b2b4d6aedcfc0c18f76b2f

See more details on using hashes here.

File details

Details for the file nodefit-0.2-py3-none-any.whl.

File metadata

  • Download URL: nodefit-0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for nodefit-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bf9dedd70df90661ade2b40f73c2e41eebf1b3ac650721260c7c20e08357ab4c
MD5 9a9be937d48c77d399e3e76ba3eb6b62
BLAKE2b-256 59131b41ed6c6e872034c712dab31beaa1ed3f98c4d51528e32b08e3464ad4c4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2 This release

2 files

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page