https://github.com/eva-kaushik/auto-ts-time-series
https://github.com/eva-kaushik/auto-ts-time-series
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/eva-kaushik/auto-ts-time-series
- Owner: Eva-Kaushik
- Created: 2023-12-05T08:23:21.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-05T15:55:22.000Z (almost 2 years ago)
- Last Synced: 2025-02-14T22:47:59.892Z (8 months ago)
- Language: Jupyter Notebook
- Size: 1.97 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Auto-TS-Time-Series
## AutoTS Forecasting## Overview
The AutoTS Forecasting project is a Python implementation leveraging the `autots` library for streamlined time series forecasting. This tool automates the process of generating accurate forecasts with minimal coding effort. The primary focus is on predicting future values in time series data to facilitate well-informed decision-making.
## Key Features
- **Automatic Time Series Forecasting:** Utilize the `autots` library to automate the generation of time series forecasts.
- **Forecast Visualization:** Visualize forecast results for different categories, providing a clear understanding of predicted trends.- **Customizable Forecasting Model:** The code includes the creation of a forecasting model with various customizable parameters, allowing users to tailor the model to their specific needs.
## Usage
1. **Import Required Libraries:**
```python
from autots import AutoTS
import pandas as pd
import numpy as np
```2. **Load Time Series Data:**
```python
# Example: Loading data from a CSV file
df_all = pd.read_csv(r"Path of temp data.xlsx")
df_all['Date'] = pd.to_datetime(df_all['Date'], format="%d-%m-%Y")
```3. **Create Forecasting Model:**
```python
model = AutoTS(
forecast_length=15,
frequency='infer',
prediction_interval=0.9,
ensemble='auto',
model_list="fast_parallel", # Options: "superfast", "default", "fast_parallel"
transformer_list="fast", # Options: "superfast",
drop_most_recent=1,
max_generations=10,
num_validations=4,
validation_method="backwards"
)model = model.fit(
df_all[df_all.Date < dt],
date_col='Date' if long else None,
value_col='Value' if long else None,
id_col='Category' if long else None,
)
```4. **Generate Predictions:**
```python
prediction = model.predict()
```5. **Access Forecast Values:**
```python
def getfcast_value(cat, d):
try:
ret_val = round(prediction.forecast.loc[d.strftime("%Y-%m-%d")][cat], 3)
return ret_val
except Exception as e:
print(e)
return np.NaNdf_all['f1'] = df_all.apply(lambda x: getfcast_value(x['Category'], x['Date']) if x['Date'] >= dt else np.NaN, axis=1)
```6. **Visualize Forecast Results:**
```python
for cat in df_all.Category.unique():
df_all[(df_all.Category == cat) & (df_all.Date > '2022-01-01')].set_index('Date').drop('Category', axis=1).plot(
title="Category : " + cat, figsize=(12, 3)
)
```## Getting Started
1. Clone the repository:
```bash
git clone https://github.com/your-username/your-repo.git2. Install the required dependencies:
```bash
pip install autots pandas numpy
3. Run the script