PRML/PRMLT

Label output from logitBin.m seems inverted

erikr opened this issue · 3 comments

erikr commented

Hi Mo,

First, thanks so much for your efforts here.

I want to ask if there is a problem with logitBinPred.m. Output seems inverted (i.e. 0 should be 1, and 1 should be 0).

I need to delve further into the script itself, but please run this test script as an illustrative example.

I create a vector of labels, and features that are linearly related to the labels.

The logistic regression should be able to easily classify these features; I've confirmed with MATLAB built-in functions and other tools like libsvm.

If I invert the output from logitBinPred.m, the performance dramatically improves to expected levels.

Am I missing something? I'll explore your script more.

Thanks.

erikr commented

I found a fix and submitted a pull request.

fixed. Thanks for reporting.

@erikrtn thanks for the bug report. log1pexp(x) is a numerical stable version of log(1+exp(x)). So the fix for the bug you reported should be
-p = exp(-log1pexp(w'X));
+p = exp(-log1pexp(-w'X));