-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
72 lines (51 loc) · 2.27 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
[![Travis build status](https://travis-ci.org/kvantas/missTune.svg?branch=master)](https://travis-ci.org/kvantas/missTune)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/kvantas/missTune?branch=master&svg=true)](https://ci.appveyor.com/project/kvantas/missTune)
[![Coverage status](https://codecov.io/gh/kvantas/missTune/branch/master/graph/badge.svg)](https://codecov.io/github/kvantas/missTune?branch=master)
[![CRAN status](https://www.r-pkg.org/badges/version/missTune)](https://cran.r-project.org/package=missTune)
[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
# missTune
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.
## Installation
You can install the development version from Github with:
``` r
# install.packages("devtools")
devtools::install_github("kvantas/missTune")
```
## Example
This is a basic example about infilling a dataset.
```{r "infill_iris"}
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.
```{r "view data"}
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.
```{r "plot_oob_error"}
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()
```
## Meta
Please note that the `missTune` project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.