Chronos: add updated information about models and Nano to document (#4048)
* add updated information about models and Nano * fix false formate * add quantization related information * fix missing quantization api doc * fix typos
This commit is contained in:
		
							parent
							
								
									c9be2b979e
								
							
						
					
					
						commit
						1375438de3
					
				
					 3 changed files with 84 additions and 17 deletions
				
			
		| 
						 | 
					@ -10,6 +10,8 @@ You can use _Chronos_ to do:
 | 
				
			||||||
- **Anomaly Detection** (using [Anomaly Detectors](./anomaly_detection.html#anomaly-detection))
 | 
					- **Anomaly Detection** (using [Anomaly Detectors](./anomaly_detection.html#anomaly-detection))
 | 
				
			||||||
- **Synthetic Data Generation** (using [Simulators](./simulation.html#generate-synthetic-data))
 | 
					- **Synthetic Data Generation** (using [Simulators](./simulation.html#generate-synthetic-data))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Furthermore, Chronos is adapted to integrate many optimized library and best known methods(BKMs) for accuracy and performance improvement.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
### **2. Install**
 | 
					### **2. Install**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,6 +28,12 @@ pip install bigdl-chronos[all]
 | 
				
			||||||
# nightly built version
 | 
					# nightly built version
 | 
				
			||||||
pip install --pre --upgrade bigdl-chronos[all]
 | 
					pip install --pre --upgrade bigdl-chronos[all]
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					```eval_rst
 | 
				
			||||||
 | 
					.. note:: 
 | 
				
			||||||
 | 
					    **Supported OS**:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     Chronos is thoroughly tested on Ubuntu (16.04/18.04/20.04). 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.
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
### **3. Run**
 | 
					### **3. Run**
 | 
				
			||||||
Various python programming environments are supported to run a _Chronos_ application.
 | 
					Various python programming environments are supported to run a _Chronos_ application.
 | 
				
			||||||
| 
						 | 
					@ -46,6 +54,18 @@ You can directly write _Chronos_ application in a python file (e.g. script.py) a
 | 
				
			||||||
python script.py
 | 
					python script.py
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```eval_rst
 | 
				
			||||||
 | 
					.. note:: 
 | 
				
			||||||
 | 
					    **Optimization on Intel® Hardware**:
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					     Chronos integrated many optimized library 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. Get Started**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,7 +81,7 @@ Otherwise, there is no need to initialize an orca context.
 | 
				
			||||||
View [Orca Context](../../Orca/Overview/orca-context.md) for more details. Note that argument `init_ray_on_spark` must be `True` for _Chronos_. 
 | 
					View [Orca Context](../../Orca/Overview/orca-context.md) for more details. Note that argument `init_ray_on_spark` must be `True` for _Chronos_. 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```python
 | 
					```python
 | 
				
			||||||
from bigdl.orca.common import init_orca_context, stop_orca_context
 | 
					from bigdl.orca import init_orca_context, stop_orca_context
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# run in local mode
 | 
					# run in local mode
 | 
				
			||||||
init_orca_context(cluster_mode="local", cores=4, init_ray_on_spark=True)
 | 
					init_orca_context(cluster_mode="local", cores=4, init_ray_on_spark=True)
 | 
				
			||||||
| 
						 | 
					@ -101,7 +121,6 @@ for tsdata in [tsdata_train, tsdata_val, tsdata_test]:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# AutoTSEstimator initalization
 | 
					# AutoTSEstimator initalization
 | 
				
			||||||
autotsest = AutoTSEstimator(model="tcn",
 | 
					autotsest = AutoTSEstimator(model="tcn",
 | 
				
			||||||
                            past_seq_len=hp.randint(50, 200),
 | 
					 | 
				
			||||||
                            future_seq_len=10)
 | 
					                            future_seq_len=10)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# AutoTSEstimator fitting
 | 
					# AutoTSEstimator fitting
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,21 +7,38 @@ There're three ways to do forecasting:
 | 
				
			||||||
- Use [**auto forecasting models**](#use-auto-forecasting-model) with auto hyperparameter optimization.
 | 
					- Use [**auto forecasting models**](#use-auto-forecasting-model) with auto hyperparameter optimization.
 | 
				
			||||||
- Use [**standalone forecasters**](#use-standalone-forecaster-pipeline).
 | 
					- Use [**standalone forecasters**](#use-standalone-forecaster-pipeline).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#### **0. Supported Time Series Forecasting Model**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- `Model`: Model name.
 | 
				
			||||||
 | 
					- `Style`: Forecasting model style. Detailed information will be stated in [this section](#time-series-forecasting-concepts).
 | 
				
			||||||
 | 
					- `Multi-Variate`: Predict more than one variable at the same time?
 | 
				
			||||||
 | 
					- `Multi-Step`: Predict more than one data point in the future?
 | 
				
			||||||
 | 
					- `Exogenous Variables`: Take other variables(you don't need to predict) into consideration?
 | 
				
			||||||
 | 
					- `Distributed`: Scale the model to a cluster and take data from distributed file system?
 | 
				
			||||||
 | 
					- `ONNX`: Export and use `OnnxRuntime` to do the inference.
 | 
				
			||||||
 | 
					- `Quantization`: Export and use quantized int8 model to do the inference.
 | 
				
			||||||
 | 
					- `Auto Models`: AutoModel API support.
 | 
				
			||||||
 | 
					- `AutoTS`: AutoTS API support.
 | 
				
			||||||
 | 
					- `Backend`: The DL framework we use to implement this model.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<span id="supported_forecasting_model"></span>
 | 
					<span id="supported_forecasting_model"></span>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| Model   | Style | Multi-Variate | Multi-Step | Distributed\* | Auto Models | AutoTS | Backend |
 | 
					| Model   | Style | Multi-Variate | Multi-Step | Exogenous Variables | Distributed | ONNX | Quantization | Auto Models | AutoTS | Backend |
 | 
				
			||||||
| ----------------- | ----- | ------------- | ---------- | ----------- | ----------- | ----------- | ----------- |
 | 
					| ----------------- | ----- | ------------- | ---------- | ------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- |
 | 
				
			||||||
| LSTM    | RR    | ✅             | ❌          | ✅           | ✅          | ✅         | pytorch  |
 | 
					| LSTM    | RR    | ✅             | ❌      | ✅    | ✅   | ✅           | ✅        | ✅          | ✅         | pytorch  |
 | 
				
			||||||
| Seq2Seq     | RR    | ✅             | ✅          | ✅           | ✅          | ✅         | pytorch  |
 | 
					| Seq2Seq     | RR    | ✅             | ✅     | ✅     | ✅     | ✅           | ❌      | ✅          | ✅         | pytorch  |
 | 
				
			||||||
| TCN | RR    | ✅             | ✅          | ✅           | ✅          | ✅         | pytorch  |
 | 
					| TCN | RR    | ✅             | ✅     | ✅     | ✅     | ✅           | ✅      | ✅          | ✅         | pytorch  |
 | 
				
			||||||
| MTNet   | RR    | ✅             | ❌         | ✅           | ❌          | ✳️\*\*\*        | tensorflow |
 | 
					| NBeats | RR    | ❌             | ✅     | ❌     | ✅     | ✅           | ✅      | ❌          | ❌         | pytorch  |
 | 
				
			||||||
| TCMF    | TS    | ✅             | ✅          | ✳️\*\*           | ❌          | ❌         | pytorch  |
 | 
					| MTNet   | RR    | ✅             | ❌    | ✅     | ✅     | ❌          | ❌         | ❌          | ✳️\*\*        | tensorflow |
 | 
				
			||||||
| Prophet | TS    | ❌             | ✅          | ❌           | ✅          | ❌         | prophet  |
 | 
					| TCMF    | TS    | ✅             | ✅    | ✅      | ✳️\*     | ❌          | ❌         | ❌          | ❌         | pytorch  |
 | 
				
			||||||
| ARIMA   | TS    | ❌             | ✅          | ❌           | ✅          | ❌         | pmdarima |
 | 
					| Prophet | TS    | ❌             | ✅    | ❌      | ❌        | ❌          | ❌      | ✅          | ❌         | prophet  |
 | 
				
			||||||
 | 
					| ARIMA   | TS    | ❌             | ✅    | ❌      | ❌         | ❌          | ❌     | ✅          | ❌         | pmdarima |
 | 
				
			||||||
 | 
					| Customized\*\*\* | RR | Customized | Customized | Customized | ❌ |✅|❌|❌|✅|pytorch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\* TCMF only partially supports distributed training.<br>
 | 
				
			||||||
 | 
					\*\*  Auto tuning of MTNet is only supported in our deprecated AutoTS API.<br>
 | 
				
			||||||
 | 
					\*\*\* Customized model is only supported in `AutoTSEstimator` with pytorch as backend.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\* Distributed training/inferencing is only supported by standalone forecasters.<br>
 | 
					 | 
				
			||||||
\*\* TCMF only partially supports distributed training.<br>
 | 
					 | 
				
			||||||
\*\*\*  Auto tuning of MTNet is only supported in our deprecated AutoTS API.<br>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### **1. Time Series Forecasting Concepts**
 | 
					#### **1. Time Series Forecasting Concepts**
 | 
				
			||||||
| 
						 | 
					@ -203,14 +220,19 @@ ProphetForecaster wraps the Prophet model ([site](https://github.com/facebook/pr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
View Stock Prediction [notebook](https://github.com/intel-analytics/BigDL/blob/branch-2.0/python/chronos/use-case/fsi/stock_prediction_prophet.ipynb) and [ProphetForecaster API Doc](../../PythonAPI/Chronos/forecasters.html#prophetforecaster) for more details.
 | 
					View Stock Prediction [notebook](https://github.com/intel-analytics/BigDL/blob/branch-2.0/python/chronos/use-case/fsi/stock_prediction_prophet.ipynb) and [ProphetForecaster API Doc](../../PythonAPI/Chronos/forecasters.html#prophetforecaster) for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<span id="NBeatsForecaster"></span>
 | 
				
			||||||
 | 
					###### **3.8 NBeatsForecaster**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Neural basis expansion analysis for interpretable time series forecasting ([N-BEATS](https://arxiv.org/abs/1905.10437)) is a deep neural architecture based on backward and forward residual links and a very deep stack of fully-connected layers. Nbeats can solve univariate time series point forecasting problems, being interpretable, and fast to train.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### **4. Use Auto forecasting model**
 | 
					#### **4. Use Auto forecasting model**
 | 
				
			||||||
Auto forecasting models are designed to be used exactly the same as Forecasters. The only difference is that you can set hp search function to the hyperparameters and the `.fit()` method will search the best hyperparameter setting.
 | 
					Auto forecasting models are designed to be used exactly the same as Forecasters. The only difference is that you can set hp search function to the hyperparameters and the `.fit()` method will search the best hyperparameter setting.
 | 
				
			||||||
```python
 | 
					```python
 | 
				
			||||||
# set hyperparameters in hp search function, loss, metric...
 | 
					# set hyperparameters in hp search function, loss, metric...
 | 
				
			||||||
f = Forecaster(...)
 | 
					auto_model = AutoModel(...)
 | 
				
			||||||
# input data, batch size, epoch...
 | 
					# input data, batch size, epoch...
 | 
				
			||||||
f.fit(...)
 | 
					auto_model.fit(...)
 | 
				
			||||||
# input test data x, batch size...
 | 
					# input test data x, batch size...
 | 
				
			||||||
f.predict(...)
 | 
					auto_model.predict(...)
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
The input data can be easily get from `TSDataset`. Users can refer to detailed [API doc](../../PythonAPI/Chronos/automodels.html).
 | 
					The input data can be easily get from `TSDataset`. Users can refer to detailed [API doc](../../PythonAPI/Chronos/automodels.html).
 | 
				
			||||||
| 
						 | 
					@ -90,3 +90,29 @@ f = Forecaster(..., distributed=True)
 | 
				
			||||||
f.fit(tsdata_xshards, ...)
 | 
					f.fit(tsdata_xshards, ...)
 | 
				
			||||||
f.predict(test_tsdata_xshards, ...)
 | 
					f.predict(test_tsdata_xshards, ...)
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					#### **5. Quantization**
 | 
				
			||||||
 | 
					Quantization refers to processes that enable lower precision inference. In Chronos, post-training quantization is supported relied on [Intel® Neural Compressor](https://intel.github.io/neural-compressor/README.html).
 | 
				
			||||||
 | 
					```python
 | 
				
			||||||
 | 
					# init
 | 
				
			||||||
 | 
					f = Forecaster(...)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# train the forecaster
 | 
				
			||||||
 | 
					f.fit(train_data, ...)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# quantize the forecaster
 | 
				
			||||||
 | 
					f.quantize(train_data, ...)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# predict with int8 model with better inference throughput
 | 
				
			||||||
 | 
					f.predict(test_data, quantize=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# predict with fp32
 | 
				
			||||||
 | 
					f.predict(test_data, quantize=False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# save
 | 
				
			||||||
 | 
					f.save(checkpoint_file="fp32.model"
 | 
				
			||||||
 | 
					       quantize_checkpoint_file="int8.model")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# load
 | 
				
			||||||
 | 
					f.load(checkpoint_file="fp32.model"
 | 
				
			||||||
 | 
					       quantize_checkpoint_file="int8.model")
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue