Skip to main content

A fast symbolic genetic programming library with bytecode expressions, compiled evaluation, and sklearn-style estimators.

Project description

FastSymbolicGP

FastSymbolicGP is a standalone symbolic genetic programming library focused on speed, compact symbolic expressions, and sklearn-style usability.

It is designed around:

  • postfix / bytecode symbolic expression representation
  • fast expression evaluation with optional Numba acceleration
  • NumPy fallback evaluator
  • binary symbolic classification
  • symbolic regression
  • one-vs-rest multiclass symbolic classification
  • symbolic ensemble classifiers and regressors
  • subtree mutation
  • subtree crossover
  • point mutation
  • elite expression export
  • symbolic expression strings
  • simple LaTeX export helper
  • sklearn-style .fit(), .predict(), .score() API

Installation

From the project root:

python -m pip install -e .[dev]

Quick binary classification example

from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from fastsymbolicgp import FastSymbolicClassifier

data = load_breast_cancer()
X_train, X_test, y_train, y_test = train_test_split(
    data.data, data.target, test_size=0.25, stratify=data.target, random_state=42
)

scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)

model = FastSymbolicClassifier(
    population_size=300,
    generations=20,
    max_depth=4,
    random_state=42,
)

model.fit(X_train, y_train)
print(model.score(X_test, y_test))
print(model.get_expression(feature_names=data.feature_names))

Regressor

from fastsymbolicgp import FastSymbolicRegressor

reg = FastSymbolicRegressor(population_size=300, generations=20, random_state=42)
reg.fit(X_train, y_train)
pred = reg.predict(X_test)

Multiclass classifier

from fastsymbolicgp import FastSymbolicMultiClassifier

clf = FastSymbolicMultiClassifier(population_size=200, generations=15, random_state=42)
clf.fit(X_train, y_train)
pred = clf.predict(X_test)

Ensemble classifier

from fastsymbolicgp import FastSymbolicEnsembleClassifier

ens = FastSymbolicEnsembleClassifier(n_estimators=5, population_size=150, generations=10)
ens.fit(X_train, y_train)
pred = ens.predict(X_test)

Export elite expressions

model.save_elite_expressions("elite_expressions.csv", feature_names=data.feature_names, n=50)

Current status

This is an alpha research library. It is suitable for experimentation, benchmarking, and continued development.

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

fastsymbolicgp-0.1.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

fastsymbolicgp-0.1.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file fastsymbolicgp-0.1.0.tar.gz.

File metadata

  • Download URL: fastsymbolicgp-0.1.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for fastsymbolicgp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 52fde5a8d25fb2a7b674be7fdc99deab7666e7d9dc6dcf7714ac1942c8b577f5
MD5 b9ac38a6fa85ee81dcee2a29edf5fd6c
BLAKE2b-256 5c54f079875278974f6787b4d554906055a43b6eb9088f43aeae30f3db0f9227

See more details on using hashes here.

File details

Details for the file fastsymbolicgp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fastsymbolicgp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for fastsymbolicgp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f732a3a41f7ea34883cf73ec9977e7c04fc7cf966abe44e2fb8734bb6d9e755
MD5 46d1c923802710f0d8fe9f012b804015
BLAKE2b-256 72d2046d241013810a75285a5689c238d0e1ddef7db2625fbecb4d30da0d64f3

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