print.randomforest.r

来自「是基于linux系统的C++程序」· R 代码 · 共 42 行

R
42
字号
"print.randomForest" <-function(x, ...) {  cat("\nCall:\n", deparse(x$call), "\n")  cat("               Type of random forest: ", x$type, "\n", sep="")  cat("                     Number of trees: ", x$ntree, "\n",sep="")  cat("No. of variables tried at each split: ", x$mtry, "\n\n", sep="")  if(x$type == "classification") {    if(!is.null(x$confusion)) {      cat("        OOB estimate of  error rate: ",          round(x$err.rate[x$ntree, "OOB"]*100, dig=2), "%\n", sep="")      cat("Confusion matrix:\n")      print(x$confusion)      if(!is.null(x$test$err.rate)) {        cat("                Test set error rate: ",            round(x$test$err.rate[x$ntree, "Test"]*100, dig=2), "%\n",            sep="")        cat("Confusion matrix:\n")        print(x$test$confusion)      }    }  }  if(x$type == "regression") {    if(!is.null(x$mse)) {      cat("          Mean of squared residuals: ", x$mse[length(x$mse)],          "\n", sep="")      cat("                    % Var explained: ",          round(100*x$rsq[length(x$rsq)], dig=2), "\n", sep="")      if(!is.null(x$test$mse)) {        cat("                       Test set MSE: ",            round(x$test$mse[length(x$test$mse)], dig=2), "\n", sep="")        cat("                    % Var explained: ",            round(100*x$test$rsq[length(x$test$rsq)], dig=2), "\n", sep="")      }          }    if (!is.null(x$coefs)) {      cat("  Bias correction applied:\n")      cat("  Intercept: ", x$coefs[1], "\n")      cat("      Slope: ", x$coefs[2], "\n")    }  }}

⌨️ 快捷键说明

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