knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
This package is an alternative implementation of the missForest
and missRanger
packages using tuned Random Forests. The tuneRF
function from the randomForest
is used internally to find the optimal mtry
parameter.
You can install the development version from Github with:
# install.packages("devtools") devtools::install_github("kvantas/missTune")
This is a basic example about infilling a dataset.
library(missTune) # create random na values iris_na <- generate_na(iris, p = 0.1, seed = 123) # infill values res_imp <- miss_tune(x_miss = iris_na, num_trees = 100, verbose = TRUE)
Let's view the original data-set with the missing values and the infilled one.
head(iris_na) head(res_imp$x_imp)
And finally let's create a plot with the mean out of bag error during the iterations of the algorithm.
library(ggplot2) mean_errors <- unlist(lapply(res_imp$oob_list, mean)) ggplot()+ geom_line(aes(x = 1: length(mean_errors), mean_errors)) + scale_x_continuous(breaks = 1: length(mean_errors)) + xlab("Iteration") + ylab("Error")+ theme_bw()
Please note that the missTune
project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.