rf-model-importance-analysis

Train a two-class random forest in R and rank feature importance with reproducible plots.

Updated Sep 15, 2026
One-click install
npx skills add https://github.com/mrsonord2240/openscience-specialists --skill rf-model-importance-analysis-mrsonord2240
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rf-model-importance-analysis
Source: https://github.com/mrsonord2240/openscience-specialists/tree/main/specialists/clinical-prediction-model-specialist/versions/1.0.0/package/skills/rf-model-importance-analysis
Command: npx skills add https://github.com/mrsonord2240/openscience-specialists --skill rf-model-importance-analysis-mrsonord2240

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires optparse, randomForest, ggplot2, tidyr, and includes scripts (resource) and references (resource) components.

What problem does it solve? It provides a standardized, reproducible R CLI workflow for training a binary random forest classifier on an expression-like feature matrix and ranking variable importance, eliminating ad-hoc scripting for biomarker-style feature screening. ## Core Features & Use Cases - Binary Random Forest Training: Fits a two-class classifier with configurable ntree, mtry, and nodesize, controlled by a fixed random seed. - Importance Ranking and Plots: Exports ranked importance tables (CSV) plus OOB error and variable-importance PDF plots, with extensive plot styling options. - Plot-Only Mode: Regenerates plots from an existing rf_result.rds model bundle without retraining. - Use Case: A researcher with a cleaned gene-expression matrix and case/control labels runs one Rscript command to obtain ranked feature importance tables and publication-ready error and importance plots. ## Quick Start Run the main R script with your expression matrix, group file, case and control labels, and an output directory to generate the trained model, importance tables, and plots.

Frequently Asked Questions about rf-model-importance-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I rank feature importance with a random forest in R?▼

Run the main R script with an expression matrix, a group file, and case/control labels. It trains a randomForest classifier and exports ranked importance tables as CSV plus a variable-importance PDF plot using MeanDecreaseAccuracy or MeanDecreaseGini.

What input format does a random forest feature-importance workflow need?▼

It needs a CSV or TSV expression matrix with sample IDs in the first column and numeric features in the remaining columns, plus a group file with matching sample IDs and exactly two group labels. Missing values and non-numeric features are rejected.

Can random forest importance analysis handle missing values or multiclass data?▼

No. This workflow supports only two-class classification on fully cleaned data. Imputation, normalization, batch correction, regression, and multiclass tasks must be handled by a separate preprocessing or modeling workflow first.

Why does my random forest run fail with SKILL_SAMPLE_MISMATCH?▼

SKILL_SAMPLE_MISMATCH means the expression matrix and group file contain different sample IDs. Align both files to identical sample sets, removing whitespace, duplicates, or renamed samples before rerunning.

How do I regenerate random forest plots without retraining the model?▼

Use plot-only mode by passing --plot_only TRUE with the same output directory from a previous full run. The script reuses the stored data/rf_result.rds bundle and regenerates the error and importance plots without retraining.