Skip to main content

TrendyPy

PyPI tests Codecov Documentation Status Downloads GitHub last commit Twitter

TrendyPy is a small Python package for sequence clustering. It is initially developed to create time series clusters by calculating trend similarity distance with Dynamic Time Warping.

Installation

You can install TrendyPy with pip.

pip install trendypy

TrendyPy depends on Pandas, Numpy and fastdtw and works in Python 3.7+.

Quickstart

Trendy has scikit-learn like api to allow easy integration to existing programs. Below is a quick example to show how it clusters increasing and decreasing trends.

>>> from trendypy.trendy import Trendy
>>> a = [1, 2, 3, 4, 5] # increasing trend
>>> b = [1, 2.1, 2.9, 4.4, 5.1] # increasing trend
>>> c = [6.2, 5, 4, 3, 2] # decreasing trend
>>> d = [7, 6, 5, 4, 3, 2, 1] # decreasing trend
>>> trendy = Trendy(n_clusters=2)
>>> trendy.fit([a, b, c, d])
>>> print(trendy.labels_)
[0, 0, 1, 1]
>>> trendy.predict([[0.9, 2, 3.1, 4]]) # another increasing trend
[0]

It can also be utilized to cluster strings by using string similarity metrics.

>>> from trendypy.trendy import Trendy
>>> from trendypy.algos import levenshtein_distance
>>> company_names = [
... 	'apple inc', 
... 	'Apple Inc.', 
... 	'Microsoft Corporation', 
... 	'Microsft Corp.']
>>> trendy = Trendy(n_clusters=2, algorithm=levenshtein_distance)
>>> trendy.fit(company_names)
>>> print(trendy.labels_)
[0, 0, 1, 1]
>>> trendy.predict(['Apple'])
[0]

Refer to extensive demo to see it in clustering stock trends, images or to see how to define your own metric or just check API Reference for details.

Post

The idea is originated from the post Trend Clustering.

Metadata

Release files for trendypy 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trendypy 0.2.2
File Size Uploaded
trendypy-0.2.2.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trendypy 0.2.2
File Interpreter ABI Platform
trendypy-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.9 kB

Release files / trendypy-0.2.2.tar.gz

Download URL trendypy-0.2.2.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
600fce1cab6716cba08c097d67f38c9f28c624ee9417abc290b5d6498f146fca
BLAKE2b-256 checksum
How to use checksums
f55d09fad4c1b5603691efce6a489955d3d0066d39b48a16ba849857a3e7371e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / trendypy-0.2.2-py3-none-any.whl

Download URL trendypy-0.2.2-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7aee02cc96d92d599aec3bd226958f030312a485e462ac0d0eb5107caf078a70
BLAKE2b-256 checksum
How to use checksums
961ba1b6493490d4df52663fa1872087351e4e98c783df5214fea2df889fc5c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page