Skip to content

Fix/split on nodes - #74

Open
gAldeia wants to merge 25 commits into
masterfrom
fix/splitOn_nodes
Open

gAldeia wants to merge 25 commits into
masterfrom
fix/splitOn_nodes

Conversation

@gAldeia

@gAldeia gAldeia commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces several improvements and fixes to the pybrush estimator code, focusing on more robust feature type handling, enhancements to incremental training (partial_fit), and improved evaluation logic. The changes increase code reliability, make the estimator more flexible with different input types, and clarify documentation for users.

Feature type handling and data preparation:

  • Refactored feature type inference and moved the logic into a dedicated _prepare_feature_types method, improving maintainability and ensuring consistent encoding for both DataFrame and ndarray inputs. Now supports explicit feature_types as a parameter, with clear rules for inferring types when unspecified.
  • Improved encoding of categorical and string columns, ensuring consistent treatment at prediction time and better support for unseen categories.

Incremental training (partial_fit) enhancements:

  • Added a refit parameter to partial_fit, allowing users to control whether the population is refitted or only reevaluated, and clarified behavior when max_gens=0. Now checks for changes in pop_size and num_islands to prevent inconsistent state.
  • Changed population update logic to retain the selected individual as a candidate, rather than replacing the entire population with copies, improving evolutionary diversity.
  • Ensured that data and training/validation partitions are updated after partial_fit, and that final model selection is only run when appropriate.

Evaluation and prediction logic:

  • Improved evaluation logic to handle edge cases, such as AUROC with only one class in the sample, and fixed class weighting for bootstrapped samples. Now uses a seeded random number generator for reproducibility.
  • Refactored predict and predict_proba to use the unified _make_data method for consistent data preparation, supporting both DataFrame and ndarray inputs.

Documentation improvements:

  • Expanded and clarified docstrings for EstimatorInterface and BrushClassifier, especially regarding feature types, batching, verbosity, and incremental training behavior.

Code cleanup and imports:

  • Moved pandas dtype utility imports to EstimatorInterface.py for centralization and removed unused imports from BrushEstimator.py.

…zer.

The weights are used as the comparison value for operators
that works with integers (because in Brush integers correspond to classes).

For example, in the node Equals(category, 2), the 2 is data.W
Because we want to use Int as categories, we also need to make sure
each category exists in the data, so they can be sampled as terminals.

weights_init should help prioritize some of them, and
bandits should learn their utilities
previously it was looking only on the predicted classes,
which could lead to a simplification that affects the log loss
drastically.

now it should word fine
:
Split nodes are ignoring user defined class weights when finding
split thresholds, lets fix that
…ith >10 samples from a pandas dataframe or used defined types
Also, gini scores now take into account weighted samples
if the user has provided it

This branch has not been deployed

No deployments
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