Skip to content

Conversation

@dikejiang
Copy link

In this version, we add two functions: 1) predictByVotingWithWeight(features: Vector) and 2) predictWithWeight(features: Vector). And we also modify the function: predictByVoting(features: Vector).

There are at least two reasons why we make such improvement:

1 ) In our practice, we want to find the top N samples from one category. However in 1.3.0 version, the function of predict can only give the predicted category but without weights.

  1. What's more, in our practice, the numbers of positive and negative samples are very unbalance. There are much less positive samples than negative samples. According to the results of votes, there are very few samples predicted as positive sample. If the weights are also given, users can make a proper threshold to modify the results so that the performance can be improved.

In this version, we add two functions: 1) predictByVotingWithWeight(features: Vector) and 2) predictWithWeight(features: Vector). And we also modify the function: predictByVoting(features: Vector).

There are at least two reasons why we make such improvement:

1 ) In our practice, we want to find the top N samples from one category. However in 1.3.0 version, the function of predict can only give the predicted category but without weights.

2) What's more, in our practice, the numbers of positive and negative samples are very unbalance. There are much less positive samples than negative samples. According to the results of votes, there are very few samples predicted as positive sample. If the weights are also given, users can make a proper threshold to modify the results so that the performance can be improved.
@mengxr
Copy link
Contributor

mengxr commented Dec 3, 2014

@dikejiang Do you mind creating a JIRA and adding the JIRA number to the PR title? Thanks!

@dikejiang dikejiang changed the title [mllib] [random forest] functions returning the category with weights [SPARK-4736][mllib] [random forest] functions returning the category with weights Dec 4, 2014
@dikejiang
Copy link
Author

@mengxr done!

@jkbradley
Copy link
Member

@dikejiang Thanks for the PR! I'm wondering if you'd be interested in a more general API. In the new experimental ML package, I have a PR [https://www.github.com//pull/3637] which introduces a few prediction methods, one of which is:

def predictRaw(features: Vector): Vector // for each label, predict a confidence

What do you think of using this instead of only predicting the top label's weight?
Eventually, confidence predictions could be improved by incorporating each tree's confidence in its prediction (rather than having each tree simply vote for a single label, as is done now). (But that could be a later PR.)

@dikejiang
Copy link
Author

@jkbradley Of course I am intersted in the more general API if it could provid confidence prdictions, because in our practice we usually need such confidence value to make top N rank. In addtion, I am quite agree with you that confidence predictions could be improved by incorporating each tree's confidence.

@jkbradley
Copy link
Member

@dikejiang Great, thanks!

@dikejiang
Copy link
Author

@mengxr OK to go?

@jkbradley
Copy link
Member

@dikejiang Apologies--I think I was not clear. I was recommending that you change this PR to implement predictRaw(), rather than predictWithWeight(). Does that sound reasonable? Since predictRaw gives more info than predictWithWeight, it seems best to only include predictRaw. Thanks!

change function name
predictWithWeight->predictRaw
predictByVotingWithWeight->predictRawByVoting
@jkbradley
Copy link
Member

@dikejiang Do you still plan to update this PR to return a Vector of probabilities? I'm planning a major reorganization of trees & ensembles APIs here: [https://issues.apache.org/jira/browse/SPARK-6113]
I don't want it to mess up your PR; we could either finish up this PR soon, or we could wait until the API update (which should help by making the proper API clearer).

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@jkbradley
Copy link
Member

@dikejiang This work is now being done here: [https://issues.apache.org/jira/browse/SPARK-3727]
Can you please close this PR?

If you still want to work on this task, please coordinate on the JIRA I linked. Thanks!

@asfgit asfgit closed this in 555213e Apr 28, 2015
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

Successfully merging this pull request may close these issues.

4 participants