Skip to content

Weighted Losses for Unbalanced Targets - RealMLP #37

@antoniobrych

Description

@antoniobrych

Currently RealMLP_TD_Classifier only supports class_weights="balanced" for handling class imbalance. However, it does not allow users to specify custom class weights.
This limitation makes it difficult to tune models for highly imbalanced datasets, where manually defined weights often perform better than automatic balancing.

For example, the following snippet triggers an error:

RealMLP_TD_Classifier(
    class_weights={0: 1.0, 1: 3.44},
    verbosity=1
)

Proposed API change:
Allow class_weights to accept either
class_weights: Union[str, Dict[int, float]] or
class_weights='balanced'

Example (usage):

RealMLP_TD_Classifier(
    class_weights={0: 1.0, 1: 3.44},
    verbosity=1
)

Motivation
Custom class weighting is widely supported in other ML libraries:
scikit-learn
LightGBM
XGBoost

Thanks a lot! Pytabkit is awesome

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions