* add installation options * add new tested setup.py and quickstart changes * add installation guide * add some doc fix * chronos typo * fix typos * fix pep8 * fix accord comments
14 KiB
Chronos User Guide
1. Overview
Chronos is an application framework for building large-scale time series analysis applications.
You can use Chronos to do:
- Data pre/post-processing and feature generation (using TSDataset)
- Time Series Forecasting (using Standalone Forecasters, Auto Models (with HPO) or AutoTS (full AutoML enabled pipelines))
- Anomaly Detection (using Anomaly Detectors)
- Synthetic Data Generation (using Simulators)
- Speed up or tune your customized time-series model (using TSTrainer and AutoTS)
2. Install
.. raw:: html
<link rel="stylesheet" type="text/css" href="../../../_static/css/chronos_installation_guide.css" />
<div class="displayed">
<table id="table-1" style="margin:auto">
<thead>
<th>AI Framework</th>
<th colspan="1"><button id="pytorch"
title="Use PyTorch as deep learning models' backend. Most of the model support and works better under PyTorch.">PyTorch</br>(Recommended)</button>
</th>
<th colspan="1"><button id="tensorflow"
title="Use Tensorflow as deep learning models' backend.">Tensorflow</button></th>
<th colspan="1"><button id="prophet" title="For Prophet model.">Prophet</button></th>
<th colspan="1"><button id="pmdarima" title="For ARIMA model.">pmdarima</button></th>
</thead>
<tbody>
<tr>
<td>OS</td>
<td colspan="2"><button id="linux" title="Ubuntu/CentOS is recommended">Linux</button></td>
<td colspan="2"><button id="win" title="WSL is needed for Windows users">Windows</button></td>
</tr>
<tr>
<td>Auto Tuning</td>
<td colspan="2" title="I don't need any hyperparameter auto tuning feature."><button
id="automlno">No need</button></td>
<td colspan="2" title="I need chronos to help me tune the hyperparameters."><button
id="automlyes">Needed</button></td>
</tr>
<tr>
<td>Hardware</td>
<td colspan="2"><button id="singlenode" title="For users use laptop/single node server.">Single
node</button></td>
<td colspan="2"><button id="cluster" title="For users use K8S/Yarn Cluster.">Cluster</button></td>
</tr>
<tr>
<td>Release</td>
<td colspan="2"><button id="pypi" title="For users use pip to install chronos.">Pip</button></td>
<td colspan="2"><button id="docker" title="For users use docker image.">Docker</button></td>
</tr>
<tr>
<td>Build</td>
<td colspan="2"><button id="stable"
title="For users would like to deploy chronos in their production">Stable (2.0.0)</button>
</td>
<td colspan="2"><button id="nightly"
title="For users would like to try chronos's latest feature">Nightly (2.1.0b)</button></td>
</tr>
<tr>
<td>Install CMD</td>
<td colspan="4">
<div id="cmd" style="text-align: left;">NA</div>
</td>
</tr>
</tbody>
</table>
</div>
<script src="../../../_static/js/chronos_installation_guide.js"></script>
2.1 Pypi
When you install bigdl-chronos from PyPI. We recommend to install with a conda virtual environment. To install Conda, please refer to here.
conda create -n my_env python=3.7 setuptools=58.0.4
conda activate my_env
pip install --pre --upgrade bigdl-chronos[pytorch] # or other options you may want to use
source bigdl-nano-init
2.2 Tensorflow backend
Tensorflow is one of the supported backend of Chronos in nightly release version, while it can not work alone without pytorch in Chronos for now. We will fix it soon. If you want to use tensorflow backend, please
pip install --pre --upgrade bigdl-nano[tensorflow]
after you install the pytorch backend chronos.
OS and Python version requirement
.. note::
**Supported OS**:
Chronos is thoroughly tested on Ubuntu (16.04/18.04/20.04), and should works fine on CentOS. If you are a Windows user, the most convenient way to use Chronos on a windows laptop might be using WSL2, you may refer to https://docs.microsoft.com/en-us/windows/wsl/setup/environment or just install a ubuntu virtual machine.
.. note::
**Supported Python Version**:
Chronos only supports Python 3.7.2 ~ latest 3.7.x. We are validating more Python versions.
3. Run
Various Python programming environments are supported to run a Chronos application.
3.1 Jupyter Notebook
You can start the Jupyter notebook as you normally do using the following command and run Chronos application directly in a Jupyter notebook:
jupyter notebook --notebook-dir=./ --ip=* --no-browser
3.2 Python Script
You can directly write Chronos application in a Python file (e.g. script.py) and run in the command line as a normal Python program:
python script.py
.. note::
**Optimization on Intel® Hardware**:
Chronos integrated many optimized libraries and best known methods (BKMs), users can have best performance to add ``bigdl-nano-init`` before their scripts.
``bigdl-nano-init python script.py``
Currently, this function is under active development and we encourage our users to add ``bigdl-nano-init`` for forecaster's training.
4. Get Started
4.1 Initialization
Chronos uses Orca to enable distributed training and AutoML capabilities. Initialize orca as below when you want to:
- Use the distributed mode of a forecaster.
- Use automl to distributedly tuning your model.
- Use
XshardsTSDatasetto process time series dataset in distribution fashion.
Otherwise, there is no need to initialize an orca context.
View Orca Context for more details. Note that argument init_ray_on_spark must be True for Chronos.
from bigdl.orca import init_orca_context, stop_orca_context
if __name__ == "__main__":
# run in local mode
init_orca_context(cluster_mode="local", cores=4, init_ray_on_spark=True)
# run on K8s cluster
init_orca_context(cluster_mode="k8s", num_nodes=2, cores=2, init_ray_on_spark=True)
# run on Hadoop YARN cluster
init_orca_context(cluster_mode="yarn-client", num_nodes=2, cores=2, init_ray_on_spark=True)
# >>> Start of Chronos Application >>>
# ...
# <<< End of Chronos Application <<<
stop_orca_context()
4.2 AutoTS Example
This example run a forecasting task with automl optimization with AutoTSEstimator on New York City Taxi Dataset. To run this example, install the following: pip install --pre --upgrade bigdl-chronos[all].
from bigdl.orca.automl import hp
from bigdl.chronos.data.repo_dataset import get_public_dataset
from bigdl.chronos.autots import AutoTSEstimator
from bigdl.orca import init_orca_context, stop_orca_context
from sklearn.preprocessing import StandardScaler
if __name__ == "__main__":
# initial orca context
init_orca_context(cluster_mode="local", cores=4, memory="8g", init_ray_on_spark=True)
# load dataset
tsdata_train, tsdata_val, tsdata_test = get_public_dataset(name='nyc_taxi')
# dataset preprocessing
stand = StandardScaler()
for tsdata in [tsdata_train, tsdata_val, tsdata_test]:
tsdata.gen_dt_feature().impute()\
.scale(stand, fit=tsdata is tsdata_train)
# AutoTSEstimator initalization
autotsest = AutoTSEstimator(model="tcn",
future_seq_len=10)
# AutoTSEstimator fitting
tsppl = autotsest.fit(data=tsdata_train,
validation_data=tsdata_val)
# Evaluation
autotsest_mse = tsppl.evaluate(tsdata_test)
# stop orca context
stop_orca_context()
5. Details
Chronos provides flexible components for forecasting, detection, simulation and other userful functionalities. You may review following pages to fully learn how to use Chronos to build various time series related applications.
- Time Series Processing and Feature Engineering Overview
- Time Series Forecasting Overview
- Time Series Anomaly Detection Overview
- Generate Synthetic Sequential Data Overview
- Useful Functionalities Overview
- Speed up Chronos built-in/customized models
- Chronos API Doc
6. Examples and Demos
- Quickstarts
- Examples
- Use AutoLSTM on nyc taxi dataset
- Use AutoProphet on nyc taxi dataset
- High dimension time series forecasting with Chronos TCMFForecaster
- Use distributed training with Chronos Seq2SeqForecaster
- Use ONNXRuntime to accelerate the inference of AutoTSEstimator
- Use ONNXRuntime to accelerate the inference of Seq2SeqForecaster
- Generate synthetic data with DPGANSimulator in a data-driven fashion
- Quantizate your forecaster to speed up inference
- Use cases
- Unsupervised Anomaly Detection
- Unsupervised Anomaly Detection based on Forecasts
- Stock Price Prediction with LSTM
- Stock Price Prediction with ProphetForecaster and AutoProphet
- Network Traffic Forecasting with AutoTSEstimator
- Network Traffic Forecasting (using multivariate time series data)
- Network Traffic Forecasting (using multistep time series data)
- Network Traffic Forecasting with Customized Model
- Help pytorch-forecasting improve the training speed of DeepAR model
- Help pytorch-forecasting improve the training speed of TFT model