Nothing
#'@title Information Gain
#'@description Information Gain is a feature selection technique based on information theory. It measures the information obtained for the target variable by knowing the presence or absence of a feature.
#' It wraps the FSelector library.
#'@param attribute The target variable.
#'@return A `fs_ig` object.
#'@examples
#'data(iris)
#'myfeature <- daltoolbox::fit(fs_ig("Species"), iris)
#'data <- daltoolbox::transform(myfeature, iris)
#'head(data)
#'@importFrom daltoolbox dal_transform
#'@importFrom daltoolbox fit
#'@importFrom daltoolbox transform
#'@export
fs_ig <- function(attribute) {
obj <- fs(attribute)
class(obj) <- append("fs_ig", class(obj))
return(obj)
}
#'@importFrom FSelector information.gain
#'@importFrom doBy orderBy
#'@importFrom daltoolbox fit
#'@export
fit.fs_ig <- function(obj, data, ...) {
data <- data.frame(data)
data[,obj$attribute] = as.factor(data[, obj$attribute])
class_formula <- formula(paste(obj$attribute, " ~ ."))
weights <- FSelector::information.gain(class_formula, data)
tab <- data.frame(weights)
tab <- doBy::orderBy(~-attr_importance, data=tab)
tab$i <- row(tab)
tab$import_acum <- cumsum(tab$attr_importance)
myfit <- daltoolbox::fit_curvature_min()
res <- daltoolbox::transform(myfit, tab$import_acum)
tab <- tab[tab$import_acum <= res$y, ]
vec <- rownames(tab)
obj$features <- vec
return(obj)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.