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

Regarding the log prior (phi_0 in the paper) #7

Closed
Hugo101 opened this issue Jul 16, 2018 · 3 comments
Closed

Regarding the log prior (phi_0 in the paper) #7

Hugo101 opened this issue Jul 16, 2018 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Hugo101
Copy link
Contributor

Hugo101 commented Jul 16, 2018

  1. about the function performInference in boosting.py during the inference:
    logPrior = log(0.5/float(1-0.5)) = 0

    However, in the java version, this is -1.8.

  2. about the functions: setPos and setNeg in util.py during learning:

    • self.pos[example] = 0.5 # Set initial gradient to 0.5 for positives.
    • self.neg[example] = -0.5 # Set initial gradient to -0.5 for negatives.

    However, in the java version:

    • For positives, the prob is 1-p=1 - sigmoid(-1.8)
    • For negatives, the prob is 0-p = 0 - sigmoid(-1.8)
@Hugo101 Hugo101 changed the title regarding the log prior (phi_0 in the paper) 1. regarding the log prior (phi_0 in the paper) Jul 16, 2018
@Hugo101 Hugo101 changed the title 1. regarding the log prior (phi_0 in the paper) 1: regarding the log prior (phi_0 in the paper) Jul 16, 2018
@hayesall
Copy link
Owner

Good catch, some additional background (some lines are removed for easier reading, line numbers from BoostSRL's current master branch are marked)

edu.wisc.cs.will.Boosting.RDN.ConditionalModelPerPredicate.java

public class ConditionalModelPerPredicate implements Serializable {
    /**
    *  Prior log probability i.e. \psi_0
    */
    private double log_prior = -1.8; // Line 49

    public void setLog_prior(double logPrior) { // Line 589
        log_prior = logPrior;
    }

Setting the log prior to 0 in this repository may be left over from when regression was implemented. The BoostSRL codebase sets the log prior to 0 when a regression model is learned.

edu.wisc.cs.will.Boosting.RDN.LearnBoostedRDN

if (cmdArgs.isLearnRegression()) {
    rdn.setLog_prior(0); // 171
}

@hayesall
Copy link
Owner

None of the unit tests in this repository check __logPrior__, so for the classification case we can simply switch the lines out.

https://github.com/starling-lab/rfgb.py/blob/288fa25613716531c0bf280f2e7fb05a6106d3e6/rfgb/boosting.py#L35

For regression we may want to do something similar to the Java codebase where the prior can be adjusted, maybe as a function in boosting or as a parameter in boosting.updateGradients.

- __logPrior__ = log(0.5/float(1-0.5))
+ __logPrior__ = -1.8
+
+ def setLogPrior(prior):
+     __logPrior__ = prior

I looked back through the original RDN-Boost paper but didn't find this specific value referenced there. @boost-starai or @gkunapuli may know where this originated from.

@hayesall hayesall added the bug Something isn't working label Jul 17, 2018
@hayesall hayesall added this to the Match BoostSRL milestone Jul 17, 2018
@boost-starai
Copy link

boost-starai commented Jul 17, 2018 via email

@hayesall hayesall changed the title 1: regarding the log prior (phi_0 in the paper) Regarding the log prior (phi_0 in the paper) Jul 17, 2018
@hayesall hayesall added the good first issue Good for newcomers label Jul 17, 2018
hayesall added a commit that referenced this issue Jul 28, 2018
Solution for issue #7 and issue #8 

* `rfgb/boosting.py` replace the `logPrior` with `-1.8` since the default function is the classification. Since regression is also an option, in that case the `logPrior` is `0`.

* `rfgb/utils.py` replace the initial values with correct ones.
@hayesall hayesall mentioned this issue Mar 23, 2019
hayesall added a commit that referenced this issue Mar 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants