Skip to main content

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

Release files for sam 6.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sam 6.0.2
File Size Uploaded
sam-6.0.2.tar.gz 2.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for sam 6.0.2
File Interpreter ABI Platform
sam-6.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 2.7 MB

Release files / sam-6.0.2.tar.gz

Download URL sam-6.0.2.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
224b52b43a4229989cb759fb1850ef26ba8d0764f0e796a802fb5da9cb34944c
BLAKE2b-256 checksum
How to use checksums
76e2ff95e862133bc5f95c2a42a57b09709a032c8f79ce8f80f117b5e256a8ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / sam-6.0.2-py3-none-any.whl

Download URL sam-6.0.2-py3-none-any.whl
Size 672.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8a370af8803dee49258d8a24c902b442afe0abd73b9f4a6c917f603737a89ea
BLAKE2b-256 checksum
How to use checksums
7723e18b46d7c594aee82ed8a3fe178edb94da7c338a2184ddcc9d28093da121
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25
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