kdwd: Distance Weighted Discrimination

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Distance Weighted Discriminations are an excellent tool for classification. kdwd supports the well known binary classification formulations along with native multi-class classification formulations.

Usage

1
2
3
4
5
6
7
## S4 method for signature 'formula'
kdwd(x, data = NULL, ..., subset,na.action = na.omit, 
scaled = TRUE)
## S4 method for signature 'matrix'
kdwd(x, y = NULL, scaled = TRUE, type = "bdwd", 
C = 100, fit = TRUE, cross = 0, class.weights = NULL,
     subset, na.action = na.omit)

Arguments

x

a symbolic description of the model to be fit. When not using a formula x can be a matrix containing the training data.

data

an optional data frame containing the training data, when using a formula.

y

a response vector with one label for each row/component of x. Can be a factor.

scaled

A logical vector indicating the variables to be scaled. If scaled is of length 1, the value is recycled as many times as needed and all non-binary variables are scaled.

type

kdwd can be used for binary and multiclass classification Depending on whether y is a level two factor or not, the default setting for type is bdwd, but can be overwritten by setting an explicit value.
Valid options are:

  • bdwd Binary classification or one-vs-one for multi-class classification

  • mdwd Global multi-class classification

C

cost of constraints violation (default: 1) this is the ‘C’-constant of the regularization term in the Lagrange formulation.

class.weights

a named vector of weights for the different classes, used for asymmetric class sizes. Not all factor levels have to be supplied (default weight: 1). All components have to be named.

cross

if a integer value k>0 is specified, a k-fold cross validation on the training data is performed to assess the quality of the model: the accuracy rate for classification.

fit

indicates whether the fitted values should be computed and included in the model or not (default: TRUE).

subset

An index vector specifying the cases to be used in the training sample. (NOTE: If given, this argument must be named.)

na.action

A function to specify the action to be taken if NAs are found. The default action is na.omit, which leads to rejection of cases with missing values on any required variable. An alternative is na.fail, which causes an error if NA cases are found. (NOTE: If given, this argument must be named.)

...

further arguments.

Details

kdwd uses SDPT3 infeasible path-following algorithm to solve the DWD SOCP problem.
For multiclass-classification with k classes, k > 2, bdwd uses the ‘one-against-one’-approach, in which k(k-1)/2 binary classifiers are trained; the appropriate class is found by a voting scheme, The mdwd formulations deal with the multiclass-classification problems by solving a single SOCP problem involving all the classes.
In classification when cross is k a k-fold cross validation is performed on the data. The data can be passed to the kdwd function in a matrix or a data.frame.

Value

An S4 object of class "kdwd" containing the fitted model, Accessor functions can be used to access the slots of the object (see examples) which include:

w

The direction vector pointing towards positive class, unit vector (i.e length 1). In case of one-against-one classification this is a list of vectors. In case of global multiclass classification, it is a matrix.

b0

The intercept. In case of one-against-one classification this is a list of scalers. In case of global multiclass classification, it is a vector.

obj

The value of the objective function. In case of one-against-one classification this is a vector of values.

error

Training error.

cross

Cross validation error, (when cross > 0).

fitted

Fitted class label for training data.

Author(s)

Hanwen Huang: hanwenh@email.unc.edu; Perry Haaland: Perry_Haaland@bd.com; Xiaosun Lu: Xiaosun_Lu@bd.com; Yufeng Liu: yfliu@email.unc.edu; J. S. Marron: marron@email.unc.edu

References

See Also

predict.kdwd, kdwd-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
    ## simple binary classification example
	data(promotergene)

	## train DWD
	gene <- kdwd(Class~.,data=promotergene,C=100,scaled=TRUE,cross=5)

	gene@fitted

	## simple multiclass example using the famous iris data
	data(iris)

	## train an OVO multiclass DWD
	irismodel <- kdwd(Species~.,data=iris,type="bdwd",C=100,scaled=TRUE,cross=5)

	## get fitted values
	irismodel@fitted

	## Test on the training set
	predict(irismodel, iris)

DWD documentation built on May 2, 2019, 5 p.m.

Related to kdwd in DWD...