Skip to main content

Time series anomaly detection and forecasting

Project description


SAM

PyPI Latest Release Documentation Status Downloads License Code style: black Imports: isort

SAM (Smart Asset Management) is a Python package for timeseries analysis, anomaly detection and forecasting.

The documentation is available on ReadTheDocs.

Author: Royal HaskoningDHV

Email: ruud.kassing@rhdhv.com

Getting started

Installation

The easiest way to install is package is using pip:

pip install sam

There are different optional dependencies for SAM, if you are unsure use pip install 'sam[all]' other options include plotting (just use the plotting functionality), data_science (all dependencies needed for a data scientist) and data_engineering (dependencies for data engineer).

Keep in mind that the sam package is updated frequently, and after a while, your local version may be out of date with the online documentation. To be sure, run the pip install -U sam command to install the latest version.

Simple example

Below you can find a simple example on how to use one of our timeseries models. For more examples, check our example notebooks

from sam.datasets import load_rainbow_beach
from sam.models import MLPTimeseriesRegressor
from sam.feature_engineering import SimpleFeatureEngineer

data = load_rainbow_beach()
X, y = data, data["water_temperature"]

# Easily create rolling and time features to be used by the model
simple_features = SimpleFeatureEngineer(
    rolling_features=[
        ("wave_height", "mean", 24),
        ("wave_height", "mean", 12),
    ],
    time_features=[
        ("hour_of_day", "cyclical"),
    ],
    keep_original=False,
)

# Define your model, see the docs for all parameters
model = MLPTimeseriesRegressor(
    predict_ahead=(1, 2, 3), # Multiple predict aheads are possible
    quantiles=(0.025, 0.975), # Predict quantile bounds for anomaly detection
    feature_engineer=simple_features,
    epochs=20,
)
model.fit(X, y)

Configuration

A configuration file can be created as .config and should be located in your working directory. This configuration file only stores api credentials for now, but more options may be added in the future. The configuration file is parsed using the Python3 configparser, and an example configuration is shown below:

[regenradar]
url=https://rhdhv.lizard.net/api/v3/raster-aggregates/?
user=user.name
password=secret

[openweathermap]
apikey=secret

Issue tracking and Feature Requests

Anyone can create feature requests or bug reports! You can browse and create new issues on GitHub: https://github.com/RoyalHaskoningDHV/sam/issues

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

sam-5.1.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

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

sam-5.1.0-py3-none-any.whl (672.0 kB view details)

Uploaded Python 3

File details

Details for the file sam-5.1.0.tar.gz.

File metadata

  • Download URL: sam-5.1.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for sam-5.1.0.tar.gz
Algorithm Hash digest
SHA256 260f70c1f9b5d737e58108ff0f693beac2fc208fe04ab0076888329844b34219
MD5 ea5eef0498b3a82cef5602a2eeebf373
BLAKE2b-256 7c0a1f9ae900ba2ab6d3f8c74ec576bb924cb5e3b39193b1214d96b0b97af31b

See more details on using hashes here.

File details

Details for the file sam-5.1.0-py3-none-any.whl.

File metadata

  • Download URL: sam-5.1.0-py3-none-any.whl
  • Upload date:
  • Size: 672.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for sam-5.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0f972191fd9e9a279dcd8c340cbad5e5a7c2f95b4e4f2cb7be91ca87b549ad4
MD5 c5ef96931217b5a13045d83625e884b5
BLAKE2b-256 d99378f69931c5b2cc2a95359e49c84441109effef3196de5adb8ac26ade4ed6

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