Learn R Programming

milr (version 0.3.1)

softmax: Multiple-instance logistic regression via softmax function

Description

This function calculates the alternative maximum likelihood estimation for multiple-instance logistic regression through a softmax function (Xu and Frank, 2004; Ray and Craven, 2005).

Usage

softmax(y, x, bag, alpha = 0, ...)

Arguments

y

a vector. Bag-level binary labels.

x

the design matrix. The number of rows of x must be equal to the length of y.

bag

a vector, bag id.

alpha

A non-negative realnumber, the softmax parameter.

...

arguments to be passed to the optim function.

Value

a list including coefficients and fitted values.

References

  1. S. Ray, and M. Craven. (2005) Supervised versus multiple instance learning: An empirical comparsion. in Proceedings of the 22nd International Conference on Machine Learnings, ACM, 697--704.

  2. X. Xu, and E. Frank. (2004) Logistic regression and boosting for labeled bags of instances. in Advances in Knowledge Discovery and Data Mining, Springer, 272--281.

Examples

Run this code
# NOT RUN {
set.seed(100)
beta <- runif(10, -5, 5)
trainData <- DGP(40, 3, beta)
testData <- DGP(5, 3, beta)
# Fit softmax-MILR model S(0)
softmax_result <- softmax(trainData$Z, trainData$X, trainData$ID, alpha = 0)
coef(softmax_result)      # coefficients
fitted(softmax_result)                    # fitted bag labels
fitted(softmax_result, type = "instance") # fitted instance labels
predict(softmax_result, testData$X, testData$ID)                    # predicted bag labels
predict(softmax_result, testData$X, testData$ID, type = "instance") # predicted instance labels
# Fit softmax-MILR model S(3) (not run)
# softmax_result <- softmax(trainData$Z, trainData$X, trainData$ID, alpha = 3)
# }

Run the code above in your browser using DataLab