softmax: Multiple-instance logistic regression via softmax function

View source: R/softmax.R

softmaxR Documentation

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

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)
## Not run: 
softmax_result <- softmax(trainData$Z, trainData$X, trainData$ID, alpha = 3)

## End(Not run)

ChingChuan-Chen/milr documentation built on March 12, 2024, 10:22 a.m.