Giter Site home page Giter Site logo

cali_tutorial's People

Contributors

easonfg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cali_tutorial's Issues

Small error in the H-L-C calculation

Thanks for your paper and providing this code, very useful!

I just quickly wanted to flag that there is a little error in the H-L-C calculation when splitting the dataset into equal chunks. If the dataset size isn't a multiple of g, the nrow(data) % g rows with the highest predicted scores are grouped with the lowest decile group. The issue is in the following line:

split_mtx = split(mtx, rep(1:ceiling(nr/n), each=n, length.out=nr))

Minimal example

g = 3
y = rep(c(0, 1), each = 5)
prob = seq(0, 1, length.out = 10)

mtx = cbind(y, y_not = 1- y, prob, prob_not = 1-prob)
mtx = as.data.frame(mtx)
mtx = mtx[order(mtx$prob),]
n <- length(prob)/g
nr <- nrow(mtx)

split(mtx, rep(1:ceiling(nr/n), each=n, length.out=nr))
#> $`1`
#>    y y_not      prob  prob_not
#> 1  0     1 0.0000000 1.0000000
#> 2  0     1 0.1111111 0.8888889
#> 3  0     1 0.2222222 0.7777778
#> 10 1     0 1.0000000 0.0000000    <-- wrongly put in lowest class
#> 
#> $`2`
#>   y y_not      prob  prob_not
#> 4 0     1 0.3333333 0.6666667
#> 5 0     1 0.4444444 0.5555556
#> 6 1     0 0.5555556 0.4444444
#> 
#> $`3`
#>   y y_not      prob  prob_not
#> 7 1     0 0.6666667 0.3333333
#> 8 1     0 0.7777778 0.2222222
#> 9 1     0 0.8888889 0.1111111

Easy fix

An easy fix could be to use dplyr::ntile instead or rep.

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.