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

PUBDEV-8947: aic glm #6672

Merged
merged 69 commits into from
May 19, 2023
Merged

PUBDEV-8947: aic glm #6672

merged 69 commits into from
May 19, 2023

Conversation

syzonyuliia
Copy link
Contributor

@wendycwong
Copy link
Contributor

@syzonyuliia : I have added a R unit test for you that attempts to compare likelihood/aic calculation for GLM. You can do a
git cherry-pick d4708df

@wendycwong wendycwong changed the base branch from master to HEXDEV-785-loglikelihood-GLM April 24, 2023 21:24
@wendycwong wendycwong changed the base branch from HEXDEV-785-loglikelihood-GLM to master April 24, 2023 21:24
@wendycwong
Copy link
Contributor

Something is wrong. Here when I run the comparison with R, here is what I got:

image

@syzonyuliia syzonyuliia changed the base branch from master to HEXDEV-785-loglikelihood-GLM April 28, 2023 12:46
@syzonyuliia syzonyuliia changed the base branch from HEXDEV-785-loglikelihood-GLM to master April 28, 2023 13:15
R.formula = (R.data[,"GLEASON"]~.)
model.h2o.gaussian.identity <- h2o.glm(calc_like=TRUE, x=myX, y=myY, training_frame=h2o.data, family="gaussian", link="identity",alpha=0.5, lambda=0, nfolds=0)
model.R.gaussian.identity <- glm(formula=R.formula, data=R.data[,2:9], family=gaussian(link=identity), na.action=na.omit)
perf <- h2o.performance(model.h2o.gaussian.identity, h2o.data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change

perf <- h2o.performance(model.h2o.gaussian.identy, h2o.data)

to

perf <- h2o.performance(model.h2o.gaussian.identy, train=TRUE)

Copy link
Contributor

@wendycwong wendycwong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most are only small changes.

- log(yr) - Gamma.logGamma(w * invPhiEst);
case tweedie:
if (DispersionMethod.ml.equals(_dispersion_parameter_method) && !_fix_tweedie_variance_power) {
return -TweedieVariancePowerMLEstimator.logLikelihood(yr, ym[0], _tweedie_variance_power, _init_dispersion_parameter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change

if (DispersionMethod.ml.equals(_dispersion_parameter_method) && !_fix_tweedie_variance_power)

to just

if (DispersionMethod.ml.equals(_dispersion_parameter_method))

We should not care what the user sets when they want to estimate Tweedie dispersion parameter. They should be able to get their likelihood calculation regardless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, and we also explicitly set the _dispersion_parameter_method to ML, so there is no reason to check for it

@syzonyuliia syzonyuliia merged commit e23473a into master May 19, 2023
65 checks passed
@syzonyuliia syzonyuliia deleted the PUBDEV-8947-AIC-GLM branch May 19, 2023 13:43
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.

None yet

4 participants