Skip to main content

GSP (Generalized Sequence Pattern) algorithm in Python

Project description


Generalized Sequence Pattern (GSP) algorithm in Python

PyPI License PyPI Python version DOI

This package was created to use GSP with Python

Table of Contents


Install Python:

sudo apt install python3


To download GSP-Py just clone the Git repository hosted in GitHub:

git clone
python install

Alternatively, you can install it with pip:

pip install gsppy


Examples of configuring and running are located in the test folders gsppy folder.

To use it in a project, import it and use the GSP class.

from gsppy.gsp import GSP

It is assumed that your transactions are a sequence of sequences representing items in baskets.

 transactions = [
            ['Bread', 'Milk'],
            ['Bread', 'Diaper', 'Beer', 'Eggs'],
            ['Milk', 'Diaper', 'Beer', 'Coke'],
            ['Bread', 'Milk', 'Diaper', 'Beer'],
            ['Bread', 'Milk', 'Diaper', 'Coke']

Init the class to prepare the transactions and to find patterns in baskets that occur over the support threshold (count):

result = GSP(transactions).search(0.3)

The support count (or simply support) for a sequence is defined as the fraction of total data-sequences that "contain" this sequence. (Although the word "contains" is not strictly accurate once we incorporate taxonomies, it captures the spirt of when a data-sequence contributes to the support of a sequential pattern.)


This project is licensed under the terms of the MIT - see the LICENSE file for details.


If this package contributes to a project which leads to a scientific publication, I would appreciate a citation.

  author       = {Prado Lima, Jackson Antonio do},
  title        = {{GSP-Py - Generalized Sequence Pattern algorithm in Python}},
  month        = jul,
  year         = 2019,
  doi          = {10.5281/zenodo.3333988},
  url          = {}

Project details

Release history Release notifications | RSS feed

This version


Download files

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

Source Distribution

gsppy-1.1.tar.gz (4.3 kB view hashes)

Uploaded source

Built Distribution

gsppy-1.1-py3-none-any.whl (5.7 kB view hashes)

Uploaded py3

Supported by

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