Skip to main content

A Python library for gradual pattern mining algorithms.

Project description

Python implementation of Gradual Pattern (GP) mining algorithms

PyPI GNU licensed 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 following core and meta-heuristic gradual pattern mining algorithms:

  • GRAANK: The foundational classical approach for mining gradual patterns.
  • Ant Colony Optimization (AntGRAANK): Meta-heuristic swarm optimization for search-space pruning.
  • Genetic Algorithm (GeneticGRAANK): Evolutionary search strategy for optimized pattern extraction.
  • Particle Swarm Optimization (ParticleGRAANK): Swarm intelligence framework for fast convergence.
  • Random Search (HillClimbingGRAANK): Baseline stochastic search variant.
  • Clustering-based Mining (ClusterGP): Data partitioning to accelerate pattern discovery.

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

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

dummy_data = [["2021-03", 30, 3, 1, 10], ["2021-04", 35, 2, 2, 8], ["2021-05", 40, 4, 2, 7], ["2021-06", 50, 1, 1, 6], ["2021-07", 52, 7, 1, 2]]
dummy_df = pd.DataFrame(dummy_data, columns=['Date', 'Age', 'Salary', 'Cars', 'Expenses'])
    
mine_obj = GRAANK(data_source=dummy_df, min_sup=0.5, eq=False)
gp_json = mine_obj.discover()
print(gp_json)

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",
	"Best Patterns": [
            [["Age+", "Salary+"], 0.6], 
            [["Expenses-", "Age+", "Salary+"], 0.6]
	],
	"Iterations": 20
}

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

Project details


Release history Release notifications | RSS feed

This version

0.9.3

Download files

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

Source Distribution

so4gp-0.9.3.tar.gz (61.8 kB view details)

Uploaded Source

Built Distribution

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

so4gp-0.9.3-py3-none-any.whl (74.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for so4gp-0.9.3.tar.gz
Algorithm Hash digest
SHA256 f20917abc776732a7dd1187ed94e27b9d74eca105c04c81e064368882361e58e
MD5 02fba21aded9e51791bc074cb632a3c1
BLAKE2b-256 32d89c53897581c2c1b212ad6690f1c6febdd7a22ce5f25b155a982a5ed9a4b4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for so4gp-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 11a99c6a5471f171cb63e8c3c4dd6baad945ab50851c1ee2c3cedb447ef86ca3
MD5 adc3babbf0f63c086a552c67d807f16f
BLAKE2b-256 09718e9904f8915299657dcb22d1fc5fa7e48306ec57c8246bd0e3b51abbbb9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page