Description Usage Arguments Details Value Note Author(s) References See Also Examples
A novel Greedy AUC-maximize Strategy
1  | glmauc.greed(data.train, data.test = NA, varlist, terms, MaxVar = 8, auc.inf0 = rep(0, MaxVar), varlist.in = NULL, trace.info = T)
 | 
data.train | 
 Train Data which is needed to be a data-frame.  | 
data.test | 
 If NA, the output is trained data, otherwise, one should offer test data, which is of the same form of train data.  | 
varlist | 
 Features that are used in this model.  | 
terms | 
 Features that are used in this model.  | 
MaxVar | 
 Max number of features that are allowed.  | 
auc.inf0 | 
 trace info.  | 
varlist.in | 
 trace info.  | 
trace.info | 
 trace info.  | 
GAS
term  | 
|
model | 
|
auc.train  | 
The license is BSD
Yifan Yang
http://sweb.uky.edu/~yya234/wordpress
GAS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77  | ##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.
## The function is currently defined as
function (data.train, data.test = NA, varlist, terms, MaxVar = 8, 
    auc.inf0 = rep(0, MaxVar), varlist.in = NULL, trace.info = T) 
{
    tic <- proc.time()
    L <- length(varlist)
    trace.matrix <- matrix(0, 8, L)
    ii = 1
    while (ii <= MaxVar) {
        auc.list <- rep(0, length(varlist))
        for (i in varlist) {
            model.term <- paste.my(terms[c(i, varlist.in)])
            model.parse <- paste("glm(lable~", model.term, ",data=data.train,family=binomial('probit'))", 
                sep = " ")
            model.tmp <- eval(parse(text = model.parse))
            pred <- logit(predict.glm(model.tmp, data.train[, 
                -16], type = "link"))
            auc.list[i] <- auc(pred, data.train$lable)
            if (trace.info) 
                cat(ii, "-th Turn, testing var+=", terms[i], 
                  "    AUC=", auc.list[i], "\n")
        }
        auc.inf0[ii] <- max(auc.list)
        if (ii > 1) {
            if (auc.inf0[ii] > auc.inf0[ii - 1]) {
                varlist.in <- c(varlist.in, varlist[which.max(auc.list)])
                trace.matrix[ii, ] <- sort(auc.list, index.return = T)$ix
                varlist <- varlist[!(varlist == which.max(auc.list))]
                ii = ii + 1
            }
            else {
                if (trace.info) 
                  cat(ii, "-th Turn, testing var --\n")
                ii = ii - 1
                pop.ind <- trace.matrix[ii, 1]
                trace.matrix[ii, ] = c(trace.matrix[ii, 2:L], 
                  0)
                if (trace.matrix[ii, 1] == 0) 
                  break
                varlist.in <- c(varlist.in[1:ii], trace.matrix[ii, 
                  1])
                varlist <- c(varlist, pop.ind)
                ii = ii + 1
            }
        }
        else {
            varlist.in <- c(varlist.in, varlist[which.max(auc.list)])
            trace.matrix[ii, 1:(L + 1 - ii)] <- sort(auc.list, 
                index.return = T)$ix
            varlist <- varlist[!(varlist == which.max(auc.list))]
            ii = ii + 1
        }
    }
    model.term <- paste.my(terms[varlist.in])
    model.parse <- paste("glm(lable~", model.term, ",data=data.train,family=binomial('probit'))", 
        sep = " ")
    model.final <- eval(parse(text = model.parse))
    if (!is.na(data.test)) {
        pred <- logit(predict.glm(model.final, data.test[, -16], 
            type = "link"))
        auc.test <- auc(pred, data.test$lable, T)
        cat("AUC on test set is", auc.inf0[MaxVar], "\nAUC on test set is:", 
            auc.test, "\n")
        toc <- proc.time()
        toc - tic
        return(list(term = model.term, model = model.final, prediction = pred, 
            auc.train = auc.inf0, auc.test = auc.test))
    }
    else {
        return(list(term = model.term, model = model.final, prediction = pred, 
            auc.train = auc.inf0))
    }
  }
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.