Skip to content

Consider using per-class weights during training #23

@FrancescoCasalegno

Description

@FrancescoCasalegno

Our classification problem is often unbalanced, with some classes having much more samples than other.

If we are interested in evaluating the problem in a way that each class gets equal weight (macro average) we could consider training the model using weights per class. In sklearn, this is achieved by passing an array sample_weight when calling

model.fit(X, y, sample_weight)

where the sample_weight that gives more weight to under-represented classes can be easily computed using sklearn's compute_sample_weight.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions