Skip to main content

Gene Programming Rules (GPR) implementation

Project description

An implementation of an extremely simple classifier (GPR) that consists of highly interpretable fuzzy metarules and is suitable for many applications. GPR is effective in accuracy and area under the receiver operating characteristic (ROC) curve. We provide a Python implementation of the GPR algorithm to enable the use of the algorithm without using commercial software tools and open access to the research community. We also added enhancements to facilitate the reading and interpretation of the rules.

Example usage

import numpy as np
from gpr_algorithm import GPR

feature_names = ['weight', 'height']
target_names = ['sick', 'healthy']

cls = GPR(
    feature_names=feature_names,
    target_names=target_names,
    max_n_of_rules=2, max_n_of_ands=2, n_generations=10, n_populations=10,
    verbose=False
)

attributes = np.array([
    [.9, .1],  # sick
    [1., .9],  # sick
    [0., .9],
    [.1, .1]
])
labels = np.array([
    0,  # sick
    0,  # sick
    1,
    1
])
cls.fit(attributes, labels)

pred_labels = cls.predict(attributes)

assert np.all(labels == pred_labels)
rules = cls.rules
assert rules == ['IF weight is Low THEN healthy | Support: 0.9500', 'ELSE sick']

Project details


Download files

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

Source Distribution

gpr-algorithm-1.0.0.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

gpr_algorithm-1.0.0-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

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