GithubHelp home page GithubHelp logo

helper function for k-fold-cv about loo HOT 3 OPEN

stan-dev avatar stan-dev commented on July 22, 2024 1
helper function for k-fold-cv

from loo.

Comments (3)

bnicenboim avatar bnicenboim commented on July 22, 2024

I wrote all sort of helper functions to deal with k-fold CV for my submission to stancon.

It needs a vector that indicates with 1 what was held out, and 0 what was used for training. And then for the model, one can skip the held out data:

model {
...
for (n in 1:N_obs) 
    if(holdout[n] == 0)
      target += model_lpdf[n];
}

and the generative quantities has a vector[N_obs] log_lik. My helper functions extract the relevant log_lik, and calculate the elpd like it is done with loo.

If it's suitable, I could contribute it to the loo package (with a little bit of guidance).

from loo.

avehtari avatar avehtari commented on July 22, 2024

Thanks for the comment. Your helper functions are not directly related to this issue, but they would be helpful to make it easier for people to use k-fold-cv. Could you open a new issue for your proposal (something like "k-fold-cv helper functions"). I already wrote the below comment before I realized that this should be in a separate issue...

I think it would be better to use index vector (below trainidx). Then your code would change to

model {
...
for (n in trainidx) 
      target += model_lpdf[n];
}

and some models could be written simply as

model {
...
y[trainidx] ~ normal(mu, sigma);
}

from loo.

bnicenboim avatar bnicenboim commented on July 22, 2024

ok, I created a new issue, and yes, I forgot that Stan allows to do that now :)

from loo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.