# TS Decomposition

`Tutorials` are the best documentation — [<mark style="color:blue;">`Time Series Decomposition Tutorial`</mark>](https://colab.research.google.com/github/sovai-research/sovai-public/blob/main/notebooks/computational/Decomposition%20Notebook.ipynb)

### Decomposition Techniques

The module primarily uses the Multiple Seasonal-Trend decomposition using LOESS method, which allows for:

* Trend extraction
* Multiple seasonal component extraction (e.g., weekly, monthly, quarterly)
* Remainder (residual) calculation

### Reactive Trend Analysis

This feature categorizes the trend in real-time as:

* Increasing
* Decreasing
* Sideways

### Usage Examples

```python
import sovai as sov

# Authenticate and load data
sov.token_auth(token="your_token_here")

df_accounting = sov.data("accounting/weekly").select_stocks("mega")
```

### Time Decomposition and Statistrics

<figure><img src="https://1304136543-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCbqQ4ogM0YiEs5Z9Djdn%2Fuploads%2Fgit-blob-41b0d4c6eb8cf5e0da6f236e1e3fd9f0ec086657%2Fimage%20(88).png?alt=media" alt=""><figcaption></figcaption></figure>

```python
# Perform time decomposition
df_time = df_accounting.time_decomposition(method="data", ticker="AAPL", feature="total_revenue")
# Access overall statistics
```

```
print(df_time.attrs["stats"])
```

#### ![](https://github.com/sovai-research/sovai-documentation/blob/main/.gitbook/assets/image%20\(78\).png)

### Interactive Dashboard

```python
# Generate decomposition plot
df_accounting.time_decomposition(method="plot", ticker="AAPL", feature="total_revenue")
```

<figure><img src="https://1304136543-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCbqQ4ogM0YiEs5Z9Djdn%2Fuploads%2Fgit-blob-2e94713bf06c062d14e61cc37948ebb11b200878%2Fimage%20(89).png?alt=media" alt=""><figcaption></figcaption></figure>
