1
0
mirror of https://github.com/andre-wojtowicz/uci-ml-to-r.git synced 2024-11-03 14:20:28 +01:00
uci-ml-to-r/utils.R

29 lines
749 B
R
Raw Normal View History

library(futile.logger)
mkdir = function(dest.dir)
{
if (!dir.exists(dest.dir))
{
flog.debug(paste("Creating directory", dest.dir))
dir.create(dest.dir)
} else {
flog.debug(paste("Target directory", dest.dir, "already exists"))
}
}
printDatasetStatistics = function(dataset)
{
if (ncol(dataset)==0) # for mockups
{
flog.warn("Empty dataset")
return()
}
no.cases = nrow(dataset)
no.attributes = ncol(dataset) - 1
perc.classes = round(100*as.numeric(table(dataset[, ncol(dataset)]))/nrow(dataset), 0)
flog.info(paste0("Cases: ", no.cases, ", attributes: ", no.attributes,
", classes: ", perc.classes[1], "%/", perc.classes[2], "%"))
}