Skip to content

ENH: multi-output class weights #173

@adriangb

Description

@adriangb

Currently, we handle single-output class weights. Keras itself should have support for multi-output class weights, but that feature is broken (keras-team/keras#4735) and there doesn't seem to be any plan to fix it.

Since we have access to all of sklearn's tools, we can relatively easily implement class_weights for multiple outputs, specifically, we can implement class weights via sample weights (Keras also supports a sample weight vector per output). In fact, sklearn implements a utility to convert class weights to sample weights, and it even supports multiple outputs, but it assumes n_outputs = y.shape[1], which isn't generally true with Keras data. This can be remedied by taking sklearn's compute_sample_weights function and modifying it slightly; it shouldn't be too hard.

Do you think this is worth implementing in SciKeras @stsievert ?

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