Skip to content

Add binary classification support via sigmoid_rmse fitness function#5

Open
Narden91 wants to merge 3 commits intoDALabNOVA:mainfrom
Narden91:main
Open

Add binary classification support via sigmoid_rmse fitness function#5
Narden91 wants to merge 3 commits intoDALabNOVA:mainfrom
Narden91:main

Conversation

@Narden91
Copy link
Copy Markdown

@Narden91 Narden91 commented Mar 8, 2026

Summary

This PR adapts SLIM_GSGP (and GP/GSGP) for binary classification following the approach of Bakurov et al. (2022).
It also fixes a NameError present in the original README example and restructures the feature into a proper first-class API.


Changes

New: binary_classification/ subpackage

  • __init__.py
    Re-exports:

    • sigmoid_rmse
    • binary_sign_transform
      This allows convenient imports.
  • example_binary_classification.py
    End-to-end working example using load_breast_cancer.


New fitness functions (evaluators/fitness_functions.py)

  • sigmoid_rmse(scaling_factor)
    Factory returning a fitness function that:

    • Wraps tree outputs with a sigmoid
    • Computes RMSE
    • Bounds predictions to [0, 1] during training
  • binary_sign_transform(y_pred)
    Converts raw outputs to binary labels at prediction time:

    • Negative → 0
    • Non-negative → 1

Config registration

Files updated:

  • config/slim_config.py
  • config/gp_config.py
  • config/gsgp_config.py

Changes:

  • sigmoid_rmse added to fitness_function_options in all algorithm configs.

API parameter

Files updated:

  • main_slim.py
  • main_gp.py
  • main_gsgp.py

New parameter added to:

  • slim()
  • gp()
  • gsgp()

sigmoid_scaling_factor: float = 1.0

Purpose:

  • Allows tuning sigmoid steepness at call time
  • Avoids modifying configuration files

README.md

Improvements and fixes:

  • Replaced broken binary classification example:

    • Removed undefined binarized variable
    • Fixed incorrect sklearn import
    • Replaced wrong dataset
  • Added clean working example

  • Fixed incorrect log_path descriptions (previously all said "for slim")

  • Removed duplicate copy_parent bullet

  • Added sigmoid_scaling_factor to arguments table

  • Updated Python version requirement to match setup.py (>=3.10)


setup.py

  • Added missing dependency:

    • dill

Usage

from slim_gsgp.main_slim import slim
from slim_gsgp.evaluators.fitness_functions import binary_sign_transform

final_tree = slim(
    X_train=X_train,
    y_train=y_train,
    fitness_function="sigmoid_rmse",
    sigmoid_scaling_factor=1.0,
    slim_version="SLIM+ABS",
)

predictions = binary_sign_transform(final_tree.predict(X_test))

Reference

Bakurov, I., et al. (2022).
General purpose optimization library (GPOL).
Swarm and Evolutionary Computation, 68, 101028.

https://doi.org/10.1016/j.swevo.2021.101028

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant