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]
	]
}

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

so4gp-1.0.1.tar.gz (61.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

so4gp-1.0.1-py3-none-any.whl (74.9 kB view details)

Uploaded Python 3

File details

Details for the file so4gp-1.0.1.tar.gz.

File metadata

  • Download URL: so4gp-1.0.1.tar.gz
  • Upload date:
  • Size: 61.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for so4gp-1.0.1.tar.gz
Algorithm Hash digest
SHA256 57ce62450fa1178b56445cc4a835b2870be32731de11d2a6e61874ae71ec8768
MD5 73905521f8430539719131cbb4337ae7
BLAKE2b-256 21903309b1517892628cd4a43304540fd2f8990d3a9af65442e95f5f2cacc806

See more details on using hashes here.

File details

Details for the file so4gp-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: so4gp-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 74.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for so4gp-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f41db3f55578117f145bb08a5b85e9cafdc0c38669e84aec5ae75189df888de3
MD5 b7338e09531100ee9845638231f65b45
BLAKE2b-256 5e75e0d41dc82ea95444faf491005120af27fb689323ec0c79e11f9be9502e7c

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.2

2 files

This release

1.0.1 This release

2 files

1.0.0

2 files

0.9.9

2 files

0.9.8

2 files

0.9.7

2 files

0.9.6

2 files

0.9.5

2 files

0.9.4

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.9

2 files

0.8.8

2 files

0.8.7

2 files

0.8.6

2 files

0.8.5

2 files

0.8.4

2 files

0.8.3

2 files

0.8.1

2 files

0.8.0

2 files

0.7.9

2 files

0.7.8

2 files

0.7.7

2 files

0.7.6

2 files

0.7.5

2 files

0.7.4

2 files

0.7.3

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.9

2 files

0.6.8

2 files

0.6.7

2 files

0.6.6

2 files

0.6.5

2 files

0.6.4

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.9

2 files

0.5.8

2 files

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.9

2 files

0.4.7

2 files

0.4.6.5

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 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