⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outlier.r

📁 是基于linux系统的C++程序
💻 R
字号:
outlier <- function(x, ...) UseMethod("outlier")outlier.randomForest <- function(x, ...) {    if (!inherits(x, "randomForest")) stop("x is not a randomForest object")    if (x$type == "regression") stop("no outlier measure for regression")    if (is.null(x$proximity)) stop("no proximity measures available")    outlier.default(x$proximity, x$y)}outlier.default <- function(x, cls=NULL, ...) {    if (nrow(x) != ncol(x)) stop ("x must be a square matrix")    n <- nrow(x)    if (is.null(cls)) cls <- rep(1, n)    cls <- factor(cls)    lvl <- levels(cls)    cls.n <- table(cls)[lvl]    id <- if (is.null(rownames(x))) 1:n else rownames(x)    outlier <- structure(rep(NA, n), names=id)    for (i in lvl) {        out <- rowSums(x[cls == i, cls == i]^2)        out <- n / ifelse(out == 0, 1, out)        out <- (out - median(out)) / mad(out)        outlier[names(out)] <- out    }    outlier}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -