Closed jtoy closed 10 years ago
These are weights telling the algorithm to prefer certain features over others? Is it the same as just scaling those dimensions manually?
These weights are used for dealing with imbalanced data, not for features. It is important to use the weights if you don't want the objective function to be accuracy. In my specific case I needed to tune this to get recall for the positive data.
From the code: *
nr_weight, weight_label, and weight are used to change the penalty * for some classes (If the weight for a class is not changed, it is * set to 1). This is useful for training classifier using unbalanced * input data or with asymmetric misclassification cost.
https://github.com/bwaldvogel/liblinear-java/blob/master/src/main/java/de/bwaldvogel/liblinear/Parameter.java#L44Ah, cool, that makes sense.
Can you add a note to that extent in the docstring for the train fn?
Also, change the if
into a when
, since there is no else clause.
Then I'm happy to merge, thanks for the contribution!
Done!
Oh! Please don't mess with project.clj when submitting pull requests. I just pushed a 0.1.1-SNAPSHOT; if you could squash your two commits into a single one with a more explicit message ("Add weight keyword arg to train fn for unbalanced training data") and rebase onto master, then we're good to go.
Oh, I had changed that version when I was testing locally.
I've added the ability to pass a weights option like so: (train (map :data data) (map :target data) :weights [[0.03 0.97][1,0]])
Tests have also been added