| mlQda | R Documentation |
Unified (formula-based) interface version of the quadratic discriminant
analysis algorithm provided by MASS::qda().
mlQda(train, ...)
ml_qda(train, ...)
## S3 method for class 'formula'
mlQda(formula, data, ..., subset, na.action)
## Default S3 method:
mlQda(train, response, ...)
## S3 method for class 'mlQda'
predict(
object,
newdata,
type = c("class", "membership", "both"),
prior = object$prior,
method = c("plug-in", "predictive", "debiased", "looCV", "cv"),
...
)
train |
a matrix or data frame with predictors. |
... |
further arguments passed to |
formula |
a formula with left term being the factor variable to predict
and the right term with the list of independent, predictive variables,
separated with a plus sign. If the data frame provided contains only the
dependent and independent variables, one can use the |
data |
a data.frame to use as a training set. |
subset |
index vector with the cases to define the training set in use (this argument must be named, if provided). |
na.action |
function to specify the action to be taken if |
response |
a vector of factor for the classification. |
object |
an mlQda object |
newdata |
a new dataset with same conformation as the training set (same variables, except may by the class for classification or dependent variable for regression). Usually a test set, or a new dataset to be predicted. |
type |
the type of prediction to return. |
prior |
the prior probabilities of class membership. By default, the prior are obtained from the object and, if they where not changed, correspond to the proportions observed in the training set. |
method |
|
ml_qda()/mlQda() creates an mlQda, mlearning object
containing the classifier and a lot of additional metadata used by the
functions and methods you can apply to it like predict() or
cvpredict(). In case you want to program new functions or extract
specific components, inspect the "unclassed" object using unclass().
mlearning(), cvpredict(), confusion(), also MASS::qda() that
actually does the classification.
# Prepare data: split into training set (2/3) and test set (1/3)
data("iris", package = "datasets")
train <- c(1:34, 51:83, 101:133)
iris_train <- iris[train, ]
iris_test <- iris[-train, ]
# One case with missing data in train set, and another case in test set
iris_train[1, 1] <- NA
iris_test[25, 2] <- NA
iris_qda <- ml_qda(data = iris_train, Species ~ .)
summary(iris_qda)
confusion(iris_qda)
confusion(predict(iris_qda, newdata = iris_test), iris_test$Species)
# Another dataset (binary predictor... not optimal for qda, just for test)
data("HouseVotes84", package = "mlbench")
house_qda <- ml_qda(data = HouseVotes84, Class ~ ., na.action = na.omit)
summary(house_qda)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.