Hi Ted 
Thanks. That fix didn't quite solve it. Upon closer inspection, it looks
like the mismatch between the istop and the StopCode, is because the
condition "StopCode.LEAST_SQUARES_CONVERGE" is never being tested for.
I replaced the "StopCode.TRIVIAL" with "StopCode.LEAST_SQUARES_CONVERGE",
and did not test for StoipCode.TRIVIAL, which seemed right to me. I also
removeed istop and the IllegalStateException & check, which didn't seem to
be doing anything. I am not an expert in this stuff by any means, so 1)
I'm not sure if I can come up with test data which exercises what I saw, 2)
I can't vouch for the correctness of the change made. However, it does
behave the way I expect now.
One thing that's bugging me though is that if I'm the first person to come
across this, is there another part of the library everyone else is using
for sparse linear regressions that I don't know about?
Thanks for the quick response.
Jim
On Thu, Jan 10, 2013 at 9:14 PM, Ted Dunning <ted.dunning@gmail.com> wrote:
> I filed MAHOUT1139, added a test case and committed a fix.
>
> Let me know if that solves your problem.
>
> Thanks for noticing the problem!
>
>
> On Thu, Jan 10, 2013 at 5:58 PM, Ted Dunning <ted.dunning@gmail.com>
> wrote:
>
> > In the meantime, can you file a JIRA with your sample code?
> >
> >
> > On Thu, Jan 10, 2013 at 5:57 PM, Ted Dunning <ted.dunning@gmail.com
> >wrote:
> >
> >> Hmm...
> >>
> >> The LSMRTest code works. So it seems like there is a mismatch
> somewhere.
> >>
> >> In debugging that test, it seems that the loop exits via ITERATION_LIMIT
> >> which avoids the problematic if statement. This is likely due to the
> fact
> >> that the test is solving a Hilbert matrix which has exceedingly bad
> >> condition number.
> >>
> >> I will put in a random matrix test and see what happens. I suspect that
> >> changing line 457 to this:
> >>
> >> if (stop != StopCode.CONTINUE && stop.ordinal() != istop) {
> >>
> >> will solve your problem.
> >>
> >> This code is translated from the reference implementation for LSMR.
> That
> >> is the source of some of these strange constructs.
> >>
> >> On Thu, Jan 10, 2013 at 5:04 PM, James Frohnhofer <fijimf@gmail.com
> >wrote:
> >>
> >>> Hi 
> >>>
> >>> I'm fairly new to Mahout, and the LSRM solver seemed like a quick and
> >>> robust way to solve a linear regression problem.
> >>>
> >>> However whenever I call solve, I get an IllegalStateException, at
> >>> LMSR.java
> >>> line 457, with the error "bad code math 2 vs 2" or "bad code match 1 vs
> >>> 1".
> >>> Looking at the code, it doesn't appear to me that the StopCode could
> >>> ever
> >>> be set without throwing this exception.
> >>>
> >>> I may be missing something because it's not clear to me at all, the
> point
> >>> of setting the StopCode, manually setting the istop flag to a the
> ordinal
> >>> value of the StopCode enum and then throwing an exception if they are
> the
> >>> same.
> >>>
> >>> Also the documentation talks about the regularization parameter lanbda,
> >>> but
> >>> the setLambda method is private.
> >>>
> >>> Any help or guidance would be appreciated.
> >>>
> >>> Thanks,
> >>>
> >>> Jim
> >>>
> >>
> >>
> >
>
