Skip to main content

Python implementation of Gradual Pattern (GP) mining algorithms

PyPI Licence Python Version Documentation

Downloads Downloads Dependents DOI

SO4GP is a high-performance Python library designed to optimize the extraction of gradual patterns from large-scale datasets. By integrating advanced computation techniques and data management strategies, the library significantly reduces processing time and memory overhead during knowledge discovery.

Implemented Extraction Algorithms

The library provides native Python implementations for the core and meta-heuristic gradual pattern mining algorithms. Here are some examples:

  • GRAANK: The foundational classical approach for mining gradual patterns.
  • Ant Colony Optimization (AntGRAANK): Meta-heuristic ACO algorithm for search-space pruning GP candidates.
  • Genetic Algorithm (GeneticGRAANK): Meta-heuristic GA for search-space pruning GP candidates.
  • Particle Swarm Optimization (ParticleGRAANK): Meta-heuristic PSO algorithm for search-space pruning GP candidates.
  • Random Search (HillClimbingGRAANK): Baseline stochastic search variant for pruning GP candidates.
  • Clustering-based Mining (ClusterGP): Applies K-Means clustering approximation to mine GPs.
  • TGRAANK: extends GRAANK to mine GPs with temporal lags.

What are Gradual Patterns?

A Gradual Pattern (GP) is a co-occurring set of gradual items (GI) that captures covariations between attributes. A pattern's quality is measured quantitatively by its computed support value.

Example

Consider a dataset containing 10 objects with 3 attributes: age, salary, and cars. An extracted GP might look like:

$${\text{age}^+, \text{salary}^-} \quad [\text{Support} = 0.8]$$

This output explicitly reveals that in 80% of the dataset (8 out of 10 objects), an increase in age ($^+$) strongly correlates with a simultaneous decrease in salary ($^-$).

Installation

pip install so4gp

Usage

To use any algorithm to mine GPs, follow the instructions that follow.

First and foremost, import the so4gp python package via:

import so4gp as sgp

# OR
from so4gp.algorithms import GRAANK, TGRAANK, ClusterGP

GRAdual rANKing Algorithm for GPs (GRAANK)

This is the classical approach (initially proposed by Anne Laurent) for mining gradual patterns. All the remaining algorithms are variants of this algorithm.

import pandas as pd
from so4gp.algorithms import GRAANK

df = pd.DataFrame(
    [
        [30, 3, 1, 10],
        [35, 2, 2, 8],
        [40, 4, 2, 7],
        [50, 1, 1, 6],
        [52, 7, 1, 2],
    ],
    columns=["Age", "Salary", "Cars", "Expenses"],
)

miner_gp = GRAANK(
    data_source=df,
    min_sup=0.5,
)

results = miner_gp.discover()

print(results)

where you specify the parameters as follows:

  • data_source - [required] data source {either a file in csv format or a Pandas DataFrame}
  • min_sup - [optional] minimum support default = 0.5
  • eq - [optional] encode equal values as gradual default = False

Sample Output

The default output is the format of JSON:

{
	"Algorithm": "GRAANK",
	"Patterns": [
            [["Age+", "Salary+"], 0.6], 
            [["Expenses-", "Age+", "Salary+"], 0.6]
	]
}

Benchmarks

Contributors ✨

Thanks go to these incredible people:

Made with contrib.rocks.

References

  • Owuor, D., Runkler T., Laurent A., Menya E., Orero J (2021), Ant Colony Optimization for Mining Gradual Patterns. International Journal of Machine Learning and Cybernetics. https://doi.org/10.1007/s13042-021-01390-w
  • Dickson Owuor, Anne Laurent, and Joseph Orero (2019). Mining Fuzzy-temporal Gradual Patterns. In the proceedings of the 2019 IEEE International Conference on Fuzzy Systems (FuzzIEEE). IEEE. https://doi.org/10.1109/FUZZ-IEEE.2019.8858883.
  • Laurent A., Lesot MJ., Rifqi M. (2009) GRAANK: Exploiting Rank Correlations for Extracting Gradual Itemsets. In: Andreasen T., Yager R.R., Bulskov H., Christiansen H., Larsen H.L. (eds) Flexible Query Answering Systems. FQAS 2009. Lecture Notes in Computer Science, vol 5822. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-04957-6_33

See Docs for more details

Metadata

Release files for so4gp 1.1.4

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

Source distribution (sdist)

Source distribution for so4gp 1.1.4
File Size Uploaded Provenance Actions
so4gp-1.1.4.tar.gz 81.5 kB Without provenance Details for so4gp-1.1.4.tar.gz

Built distribution (wheel)

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

Total release size: 170.4 kB

Release files / so4gp-1.1.4.tar.gz

Download URL so4gp-1.1.4.tar.gz
Size 81.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ece5df5ea404669abf3d320cd4bc192bbb9ea16c006cdd693b3e8c458da550e6
BLAKE2b-256 checksum
How to use checksums
0a103f31c410cbc552786fe634ece362b7f5796d1d285ceecc61d51260cf3bfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / so4gp-1.1.4-py3-none-any.whl

Download URL so4gp-1.1.4-py3-none-any.whl
Size 89.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f65b850c8a0dbcf38ed2cac5dea4d2c9b8dec8a2026fa3945a62190c6863a785
BLAKE2b-256 checksum
How to use checksums
34fc6cb65149d1ddf5d59b18e48ce741f77b7f70543b084f8ad4a656546b4d77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Security for so4gp 1.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.4 This release

2 release files No provenance

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