Open Source Framework for Explainable Time Series Analysis
Project description
WhyTrend
Open Source Framework for Explainable Time Series Analysis
WhyTrend detects anomalies, change points, and trend shifts in time series — then automatically explains why they happened using external context and LLMs.
If this project is useful to you, consider giving it a star on GitHub — it helps others discover the project. Forks and pull requests are welcome.
Features
- Fluent
PipelineAPI for source → detection → collection → ranking → explanation - Pluggable sources, detectors, collectors, rankers, and LLM providers
- Structured
Reportoutput (JSON and Markdown) - Async collectors and LLM calls
- Works offline with
MockLLMProviderand local models viaOllamaExplainer
Installation
From PyPI
pip install whytrend
Optional extras
pip install "whytrend[openai]" # OpenAI API
pip install "whytrend[trends]" # Google Trends
pip install "whytrend[prophet]" # Prophet detector
pip install "whytrend[ranking]" # Embedding ranker
pip install "whytrend[all]" # everything
From source (development)
git clone https://github.com/AlexProvatorov/WhyTrend.git
cd WhyTrend
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
Quickstart (CSV, no API keys)
from whytrend import (
BM25Ranker,
CSVSource,
LLMExplainer,
MockLLMProvider,
Pipeline,
ZScoreDetector,
)
pipeline = (
Pipeline(window_days=3)
.add_source(CSVSource("your_series.csv", keyword="Python"))
.add_detector(ZScoreDetector(threshold=1.0))
.add_ranker(BM25Ranker(top_k=5))
.add_explainer(LLMExplainer(MockLLMProvider()))
)
report = pipeline.run()
print(report.executive_summary)
print(report.to_markdown())
CSV must have timestamp and value columns. When developing from a clone, you can use
tests/fixtures/python_interest.csv as sample data.
Run the full demo (requires a repository clone):
git clone https://github.com/AlexProvatorov/WhyTrend.git
cd WhyTrend
pip install -e ".[dev]"
python examples/mvp_demo.py
Production-style example
from whytrend import (
GoogleTrends,
OpenAIExplainer,
Pipeline,
ProphetDetector,
)
from whytrend.collectors import HackerNewsCollector, WikipediaCollector
from whytrend.rankers import BM25Ranker
pipeline = (
Pipeline()
.add_source(GoogleTrends("Python"))
.add_detector(ProphetDetector())
.add_collector(HackerNewsCollector())
.add_collector(WikipediaCollector())
.add_ranker(BM25Ranker())
.add_explainer(OpenAIExplainer()) # OPENAI_API_KEY env var or api_key="..."
)
report = pipeline.run()
print(report.executive_summary)
Use OllamaExplainer(model="llama3.2") for a local LLM instead of OpenAI.
For OpenAI, pass a key explicitly or set the environment variable:
OpenAIExplainer(api_key="sk-...")
# or: export OPENAI_API_KEY=sk-...
Architecture
Source → Detector → Event Builder → Collectors → Ranker → Explainer → Report
Roadmap
Core MVP is in place. Next focus: integrations and ecosystem.
v0.2 — More collectors
- Google News
- GitHub Releases
- RSS / Stack Overflow
v0.3 — More detectors
- Ruptures (change-point)
- River / streaming detectors
v0.4 — More LLM providers
- Anthropic, Gemini, DeepSeek
- Azure OpenAI, OpenRouter
v0.5 — Reports and DX
- HTML / PDF reports
- CLI (
whytrend analyze ...) - Plugin registry (entry points)
Track progress in GitHub Issues.
Development
Requires a repository clone:
git clone https://github.com/AlexProvatorov/WhyTrend.git
cd WhyTrend
pip install -e ".[dev]"
ruff check src tests
mypy src/whytrend
pytest
Author
Alexander Provatorov — GitHub @AlexProvatorov
License
Licensed under the Apache License, Version 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file whytrend-0.1.0.tar.gz.
File metadata
- Download URL: whytrend-0.1.0.tar.gz
- Upload date:
- Size: 32.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb6de441f119f0f96713ed1a72f4f3dfb8b8ceb4a18930e5543a54b8f43df106
|
|
| MD5 |
06aa1f2b191f2852af07413e6d8941d9
|
|
| BLAKE2b-256 |
3211efdb959c00048505e5d505bd54f96cf5bad26aabd9acf05eac8d3395ea45
|
File details
Details for the file whytrend-0.1.0-py3-none-any.whl.
File metadata
- Download URL: whytrend-0.1.0-py3-none-any.whl
- Upload date:
- Size: 40.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2aa10b5eeb826674e14c55417053fc876f02053d2bc2a19a85db71986ca5a61d
|
|
| MD5 |
b154fafa4380f41161563f34cbe01223
|
|
| BLAKE2b-256 |
a898ffcf4a51dae960190c4f613998d687f38590c1432bbd70e8d50fc00529db
|