Giter Site home page Giter Site logo

auto_ks's Introduction

auto_ks

Implementation of the paper "Fitting a Kalman Smoother to Data".

Installation

To install, clone the repository and run:

pip install .

Install extra packages to run the examples:

pip install -r requirements.txt

Usage

To smooth a given dataset:

def kalman_smoother(kalman_smoother_parameters, y, K, lam):
    """
    minimize    ||Dz||^2
    subject to  Bz=c

    Args:
        - kalman_smoother_paramters: KalmanSmootherParameters object.
        - y: T x p output trajectory
        - K: T x p boolean output mask
        - lam: float, scale of Tikhonov regularization

    Returns:
        - xhat: state trajectory
        - yhat: output trajectory
        - DT: function that computes derivative
    """

To fit the parameters to a dataset:

def tune(initial_parameters, prox, y, K, lam, M=None, niter=200, lr=1.0, fraction=0.5,
         increase_rate=1.5, decrease_rate=0.5, verbose=True, callback=None):
    """
    Automatically fit a Kalman Smoother to data.

    Args:
        - initial_parameters: initial KalmanSmootherParameters object
        - prox: Proximal operator for regularization. Returns a
            KalmanSmootherParameters object and value of regularization.
        - y: T x p measurements matrix.
        - K: T x p mask matrix of known measurements.
        - lam: regularization parameter.
        - M (optional): T x p mask matrix of missing measurements. Defaults to
            dropping "fraction" of measurements. (Default=None)
        - niter (optional): Number of iterations. (Default=200)
        - lr (optional): Initial learning rate. (Default=1.0)
        - fraction (optional): Fraction of measurements to drop. (Default=0.5)
        - increase_rate (optional): Rate to increase learning rate. (Default=1.5)
        - decrease_rate (optional): Rate to decrease learning rate. (Default=0.5)
        - verbose (optional): Whether or not to print iterations. (Default=True)
        - callback (optional): Callback function to be called every iteration. (Default=None)
    Returns:
        - parameters: KalmanSmootherParameters result.
        - info: dictionary of results.
    """

Run tests

To run tests:

cd test
python -m unittest

Run examples

To run examples:

cd examples
python human_migration.py

Citing

If you use auto_ks in your research, please consider citing our paper:

@article{barratt2019fitting,
  title={Fitting a Kalman Smoother to Data},
  author={Barratt, Shane and Boyd, Stephen},
  journal={arXiv preprint arXiv:1910.08615},
  year={2019}
}

auto_ks's People

Contributors

sbarratt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.