Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comparison of Float with Float failed (ArgumentError) on a simple training test #27

Closed
hamac opened this issue Nov 13, 2014 · 6 comments

Comments

@hamac
Copy link

hamac commented Nov 13, 2014

Hi,
I had an error and managed to reproduce it with the following basic test adapted from the Readme example:

require 'classifier-reborn'
lsi = ClassifierReborn::LSI.new
strings = [["Word1 Word2", :cat],
           ["Word1 Word3", :cat],
           ["Word4 Word5 Word6 Word7", :cat]]
strings.each {|x| lsi.add_item x.first, x.last}

the third .add_item fails with:

classifier-reborn-2.0.2/lib/classifier-reborn/lsi.rb:284:in `sort': comparison of Float with Float failed (ArgumentError)

Anything I'm doing wrong?

Thanks

@parkr
Copy link
Member

parkr commented Nov 13, 2014

Hmmmm @jekyll/classifier-reborn?

@Ch4s3
Copy link
Member

Ch4s3 commented Nov 21, 2014

@hamac Can you provide any more details on how to reproduce this error? I can't seem to get it to happen. Which Ruby version are you using?

@Ch4s3
Copy link
Member

Ch4s3 commented Dec 2, 2014

I was finally able to reproduce this.

It seems that the problem is caused by The arc tangent function here being called on the quotient of some rotations. If the rotations return 0.0 for the dividend and divisor then NaN is returned. It propagates to the sort function here. Where it finally explodes.

I can probably fix it, but it could have introduce other bugs. I'm not the best at doing hairy matrix manipulations. Any ideas @jekyll/classifier-reborn?

@parkr
Copy link
Member

parkr commented Dec 3, 2014

Holy moly, that is the most convoluted code I have ever read. Yikes. What is the practical meaning of the rotations returning 0.0? That a match wasn't found? We can probably write a better SVD...

@Ch4s3
Copy link
Member

Ch4s3 commented Dec 3, 2014

I think that might be what it means... but I'm not 100% sure. I need to do some more reading about SVDs/ask the guys at the company next to mine. I think we could definitely write something more maintainable. For what its worth here is how Numpy does SVD. I've never written more than 15 lines of Python so I couldn't quite reproduce it.

So what is the plan from here? Should make some improvements in place for now, or plan a full rewrite?

Looks trivial to generate test cases with Wolfram Alpha. And I can brush up on linear algebra in the mean time.

@Ch4s3 Ch4s3 mentioned this issue Dec 3, 2014
@Ch4s3
Copy link
Member

Ch4s3 commented Dec 30, 2016

this is related to #30, so I'm closing in favor of #30

@Ch4s3 Ch4s3 closed this as completed Dec 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants