apply_DAP {DAP} | R Documentation |

Applies Discriminant Analysis via Projections to perform binary classification on the test dataset based on the training data.

apply_DAP(xtrain, ytrain, xtest, ytest = NULL, lambda_seq = NULL, n_lambda = 50, maxmin_ratio = 0.1, nfolds = 5, eps = 1e-04, maxiter = 10000, myseed = 1001, prior = TRUE)

`xtrain` |
A n x p training dataset; n observations on the rows and p features on the columns. |

`ytrain` |
A n vector of training group labels, either 1 or 2. |

`xtest` |
A m x p testing dataset; m observations on the rows and p features on the columns. |

`ytest` |
An optional m vector of testing group labels, either 1 or 2. If supplied,
the function returns misclassification error rate;
if |

`lambda_seq` |
An optional sequence of tunning parameters lambda. Default is |

`n_lambda` |
Number of lambda values, the default is 50. |

`maxmin_ratio` |
Smallest value for lambda, as a fraction of maximal value for which all coefficients are zero. The default is 0.1. |

`nfolds` |
Number of folds for cross-validation, the default is 5. |

`eps` |
Convergence threshold for the block-coordinate decent
algorithm based on the maximum element-wise change in |

`maxiter` |
Maximum number of iterations, the default is 10000. |

`myseed` |
Optional specification of random seed for generating the folds, the default value is 1001. |

`prior` |
A logical indicating whether to put larger weights to the groups of larger size; the default value is |

If no feature is selected by DAP, the function will return `error`

of 0.5 and no `ypred`

, indicating that the classifier is no better than random guessing.

A list of

`error` |
Misclassification error rate (if |

`ypred` |
Predicted labels on the test set (if |

`features` |
Number of selected features. |

`feature_id` |
Index of selected features. |

## This is an example for apply_DAP ## Generate data n_train = 50 n_test = 50 p = 100 mu1 = rep(0, p) mu2 = rep(3, p) Sigma1 = diag(p) Sigma2 = 0.5* diag(p) ## Build training data and test data x1 = MASS::mvrnorm(n = n_train, mu = mu1, Sigma = Sigma1) x2 = MASS::mvrnorm(n = n_train, mu = mu2, Sigma = Sigma2) xtrain = rbind(x1, x2) x1_test = MASS::mvrnorm(n = n_test, mu = mu1, Sigma = Sigma1) x2_test = MASS::mvrnorm(n = n_test, mu = mu2, Sigma = Sigma2) xtest = rbind(x1_test, x2_test) ytrain = c(rep(1, n_train), rep(2, n_train)) ytest = c(rep(1, n_test), rep(2, n_test)) ## Apply DAP # Given ytest, the function will return a miclassification error rate. ClassificationError = apply_DAP(xtrain, ytrain, xtest, ytest) # Without ytest, the function will return predictions. Ypredict = apply_DAP(xtrain, ytrain, xtest)

[Package *DAP* version 1.0 Index]