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

Unbalanced data / weights #9

Open
pgswartz opened this issue Jul 8, 2013 · 4 comments
Open

Unbalanced data / weights #9

pgswartz opened this issue Jul 8, 2013 · 4 comments

Comments

@pgswartz
Copy link

pgswartz commented Jul 8, 2013

Hi Tom et al,
I'm dealing with some pretty unbalanced data and was trying to define the parameters necessary for assigning my own weights. I'm doing the following:

pa = Parameter.new
pa.nr_weight = 2
pos_weight = 1 - clean_positive_train.size/(clean_positive_train.size + clean_negative_train.size)
pa.weight_label([positive_label,negative_label])
pa.weight([pos_weight, 1-pos_weight])

This results in a segmentation fault. I can avoid this segmentation fault by setting nr_weight to 0, but as I understand it, this will mean no weights are assigned (i.e., all classes get weight 1). Could I please ask for your advice on what I'm doing wrong?

Thanks for the awesome library!
Peter

@pgswartz
Copy link
Author

pgswartz commented Jul 9, 2013

Changed my code a bit, based on errors, to:

pa = Parameter.new
pa.nr_weight = 2
pos_weight = 1 - clean_positive_train.size.to_f/(clean_positive_train.size.to_f + clean_negative_train.size.to_f)
pa.weight_label = [positive_label,negative_label]
pa.weight = [pos_weight, 1-pos_weight]

Seems to be working now... Will be in touch with results

@pgswartz pgswartz closed this as completed Jul 9, 2013
@pgswartz
Copy link
Author

Sorry, I'm reopening. I'm using the above formulation, but even adjusting my weights in an exaggerated manner (i.e., assign positive weight = 10^-5 and negative_weight =1) does not fundamentally change my results in any real way. I am assigning weights incorrectly, or would you have other advice?
Thank you,
PGS

@pgswartz pgswartz reopened this Jul 10, 2013
@tomz
Copy link
Owner

tomz commented Jul 10, 2013

Hi Peter,

Thanks for pointing this out, at this point I don't have much idea, I am planning to rewrite this at some point. The results of earlier versions of the gem were verified by the LIBSVM developers, the gem then got upgraded to make use of newer versions of LIBSVM, so it's possible that the weighted input may not be working.

Tom

@pgswartz
Copy link
Author

Hi Tom,
Thanks for the message. I'll keep investigating, will update this thread with my findings. Very much appreciate the cool gem you've made!
Peter

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

2 participants