Web Analytics

missForest

⭐ 109 stars Traditional Chinese by stekhoven

🌐 語言

missForest

CRAN 狀態 CRAN RStudio 鏡像下載量 CRAN RStudio 鏡像總下載量 R-CMD-check

test-coverage License: GPL (≥ 2)-blue.svg)

missForest 是一種非參數填補方法,適用於 R 中 混合型 表格資料。它能同時處理 數值型與分類型 變數,透過迭代訓練隨機森林,從已觀測到的資料預測缺失值。不需明確建模假設、不進行矩陣分解——僅以強大的預測基準直接運作並取得良好成效。

本套件亦包含測量填補誤差、產生缺失實驗資料、檢查變數型態等工具。


安裝

# CRAN (recommended)
install.packages("missForest")

Development version (from GitHub)

install.packages("remotes")

remotes::install_github("stekhoven/missForest")


Quick start

library(missForest)

Example data

data(iris)

Introduce ~20% MCAR missingness

set.seed(81) iris_mis <- prodNA(iris, noNA = 0.20)

Impute with default backend (ranger)

imp <- missForest(iris_mis, xtrue = iris, verbose = TRUE)

Imputed data

head(imp$ximp)

Estimated OOB errors (NRMSE for numeric, PFC for factors)

imp$OOBerror

True error if xtrue was provided (for benchmarking only)

imp$error

選擇後端

# Legacy behavior using randomForest
imp_rf <- missForest(iris_mis, backend = "randomForest")

Explicitly use ranger with limited threads

imp_rg <- missForest(iris_mis, backend = "ranger", num.threads = 2)

平行化

可透過 parallelize 使用兩種模式:

# Not run:

library(doParallel)

registerDoParallel(2)

imp_vars <- missForest(iris_mis, parallelize = "variables", verbose = TRUE)

imp_fors <- missForest(iris_mis, parallelize = "forests", verbose = TRUE, num.threads = 2)


API 總覽

missForest(xmis, ...)

核心插補函數。

主要參數:

backend = "ranger" 之參數對應關係:

公用工具

---

小技巧與最佳實踐

  set.seed(123); imp <- missForest(x)
  ``
  • 在原型設計階段,可以降低 ntree 以加快迭代速度。
---

引用

如果您使用 missForest,請引用:

Stekhoven, D. J. & Bühlmann, P. (2012). MissForest—nonparametric missing value imputation for mixed-type data.* Bioinformatics, 28(1), 112–118. https://doi.org/10.1093/bioinformatics/btr597

您也可以引用此套件:

r citation("missForest") ``


Contributing

Issues and pull requests are welcome. Please include a minimal reproducible example when reporting bugs. For performance discussions, share small benchmarks and session info.


License

GPL (≥ 2)


Contact

Daniel J. Stekhoven — stekhoven@nexus.ethz.ch


--- Tranlated By Open Ai Tx | Last indexed: 2026-07-17 ---