Skip to content

More work for multi-label classification #7

@singsinghai

Description

@singsinghai

Hi @amparore,

In the previous commit I made changes to help LEAF display for mutliclass problem. However, I noticed that the fidelity score is always very low (close to 0), then I realized the problem came from eval_whitebox_classifier function due to these lines:

BBY0, WBY0 = bb_classifier(NX0)[:,0], g.predict(SNX0)
BBY1, WBY1 = bb_classifier(NX1)[:,0], g.predict(SNX1)
if label_x0 == 1:
    WBY0, WBY1 = 1 - WBY0, 1 - WBY1
BBCLS0, WBCLS0 = BBY0 > 0.5, WBY0 > 0.5
BBCLS1, WBCLS1 = BBY1 > 0.5, WBY1 > 0.5

In the first two lines, you retrieved the output probability of the 1st class and revert the probability if the label is 1 in the if statement.
To make it general for multiclass, I suggest changing the code above to:

BBY0, WBY0 = bb_classifier(NX0)[:,label_x0], g.predict(SNX0)      # The label_x0 is now the index of the bb class
BBY1, WBY1 = bb_classifier(NX1)[:,label_x0], g.predict(SNX1)      # while the g.predict already got coef and intercept from the bb class earlier

BBCLS0, WBCLS0 = BBY0 > 0.5, WBY0 > 0.5
BBCLS1, WBCLS1 = BBY1 > 0.5, WBY1 > 0.5

Now the fidelity becomes normal again
image
I will check to find if there are further lines to fix to fit the multiclass, but I think the change above is already fulfill. Would you mind if I create a commit for this afterwards?

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