Title: | Classification Models with Copula Functions |
---|---|
Description: | Provides several classifiers based on probabilistic models. These classifiers allow to model the dependence structure of continuous features through bivariate copula functions and graphical models, see Salinas-Gutiérrez et al. (2014) <doi:10.1007/s00180-013-0457-y>. |
Authors: | Rogelio Salinas Gutiérrez [aut, cre, cph] , Angélica Hernández Quintero [aut, cph] , Pedro Abraham Montoya Calzada [aut, cph] , Carlos Alberto López Hernández [aut, cph] , Juan Manuel Marquez Romero [aut, cph] |
Maintainer: | Rogelio Salinas Gutiérrez <[email protected]> |
License: | GPL-3 |
Version: | 1.0.1 |
Built: | 2024-12-23 06:19:02 UTC |
Source: | CRAN |
Calculates the confusion matrix and several performance metrics.
classification_report( y_true, y_pred )
classification_report( y_true, y_pred )
y_true |
A vector with the true labels. |
y_pred |
A vector with the predicted labels. |
Returns a list with the following entries:
metrics |
A table with the precision, recall and f1-score for each class. |
confusion_matrix |
The confusion matrix. |
accuracy |
The accuracy. |
mutual_information |
The mutual information between the true and the predicted classes. |
#Example 1 X <- iris[,1:4] y <- iris$Species model <- copulaClassifier(X = X, y = y, copula = "frank", distribution = "kernel", graph_model = "tree") y_pred <- copulaPredict(X = X, model = model) classification_report(y_true = y, y_pred = y_pred$class) #Example 2 X <- iris[,1:4] y <- iris$Species model <- copulaClassifier(X = X, y = y, copula = c("frank","clayton"), distribution = "kernel", graph_model = "chain") y_pred <- copulaPredict(X = X, model = model) classification_report(y_true = y, y_pred = y_pred$class)
#Example 1 X <- iris[,1:4] y <- iris$Species model <- copulaClassifier(X = X, y = y, copula = "frank", distribution = "kernel", graph_model = "tree") y_pred <- copulaPredict(X = X, model = model) classification_report(y_true = y, y_pred = y_pred$class) #Example 2 X <- iris[,1:4] y <- iris$Species model <- copulaClassifier(X = X, y = y, copula = c("frank","clayton"), distribution = "kernel", graph_model = "chain") y_pred <- copulaPredict(X = X, model = model) classification_report(y_true = y, y_pred = y_pred$class)
It trains a classification model based on copulas. The dependence structure of the joint density is built by using a graphical model along with bivariate copulas, as shown in Salinas-Gutiérrez et al., 2014.
copulaClassifier( X, y, distribution = "kernel", copula = "frank", weights = "likelihood", graph_model = "tree", k = 7, m = 7, method_grid = "ml" )
copulaClassifier( X, y, distribution = "kernel", copula = "frank", weights = "likelihood", graph_model = "tree", k = 7, m = 7, method_grid = "ml" )
X |
Data frame with |
y |
a vector of size |
distribution |
Marginal distribution to be used: "normal" or "kernel", by default kernel. |
copula |
Either a character or a string vector with the name of the copula to be used: "amh", "clayton", "frank", "gaussian", "grid", "gumbel", "independent" and "joe", by default "frank". For parametric copulas, "amh", "clayton", "frank", "gaussian", "gumbel", and "joe", one or more copulas can be selected. For nonparametric copula, only "grid" can be selected. See the examples for more details. |
weights |
A character with the weight construction method for the graphical model: "likelihood" or "mutual_information", by default "likelihood". |
graph_model |
A character with the graphical model structure: "tree" or "chain", by default "tree". |
k |
Only for the grid copula. Positive integer indicating the
number of subintervals for the |
m |
Only for the grid copula. Positive integer indicating the number
of subintervals for the |
method_grid |
Only for the grid copula. Fitting method, least squares "ls" or maximum likelihood "ml", by default "ml". |
Returns a trained model.
Salinas-Gutiérrez, R., Hernández-Aguirre, A., Villa-Diharce, E.R. (2014). Copula selection for graphical models in continuous Estimation of Distribution Algorithms. Computational Statistics, 29(3–4):685–713. doi:10.1007/s00180-013-0457-y
# Example 1 X <- iris[,1:4] y <- iris$Species model <- copulaClassifier(X = X, y = y, copula = "frank", distribution = "kernel", graph_model = "tree") y_pred <- copulaPredict(X = X, model = model) classification_report(y_true = y, y_pred = y_pred$class) # Example 2 X <- iris[,1:4] y <- iris$Species model <- copulaClassifier(X = X, y = y, copula = c("frank","clayton"), distribution = "kernel", graph_model = "chain") y_pred <- copulaPredict(X = X, model = model) classification_report(y_true = y, y_pred = y_pred$class)
# Example 1 X <- iris[,1:4] y <- iris$Species model <- copulaClassifier(X = X, y = y, copula = "frank", distribution = "kernel", graph_model = "tree") y_pred <- copulaPredict(X = X, model = model) classification_report(y_true = y, y_pred = y_pred$class) # Example 2 X <- iris[,1:4] y <- iris$Species model <- copulaClassifier(X = X, y = y, copula = c("frank","clayton"), distribution = "kernel", graph_model = "chain") y_pred <- copulaPredict(X = X, model = model) classification_report(y_true = y, y_pred = y_pred$class)
Use the models trained with copula functions to generate new predictions.
copulaPredict(X, model)
copulaPredict(X, model)
X |
Data frame with predictor variables. |
model |
A classification model given by |
A list with the following entries:
class |
a vector with the predicted class. |
prob |
a data frame with the probabilities of each class. |
# Example 1 X <- iris[,1:4] y <- iris$Species model <- copulaClassifier(X = X, y = y, copula = "frank", distribution = "kernel", graph_model = "tree") y_pred <- copulaPredict(X = X, model = model) classification_report(y_true = y, y_pred = y_pred$class) # Example 2 X <- iris[,1:4] y <- iris$Species model <- copulaClassifier(X = X, y = y, copula = c("frank","clayton"), distribution = "kernel", graph_model = "chain") y_pred <- copulaPredict(X = X, model = model) classification_report(y_true = y, y_pred = y_pred$class)
# Example 1 X <- iris[,1:4] y <- iris$Species model <- copulaClassifier(X = X, y = y, copula = "frank", distribution = "kernel", graph_model = "tree") y_pred <- copulaPredict(X = X, model = model) classification_report(y_true = y, y_pred = y_pred$class) # Example 2 X <- iris[,1:4] y <- iris$Species model <- copulaClassifier(X = X, y = y, copula = c("frank","clayton"), distribution = "kernel", graph_model = "chain") y_pred <- copulaPredict(X = X, model = model) classification_report(y_true = y, y_pred = y_pred$class)