Decision Tree Analysis logo

Decision Tree Analysis

OrganizationPopular
aipoch
decision-tree-analysis

Use when building a decision tree model in R and generating feature importance ranking outputs. Supports classification and regression, automatic task detection, parameter validation, model evaluation summaries, and exports of feature-importance tables and figures.

Overview

Publisheraipoch
Repositorymedical-research-skills
Skill namedecision-tree-analysis
Stars
1.9K
Forks
175
Bundled files
11
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 11 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by aipoch on GitHub. Read the source before you install it.

Installation

Install the Decision Tree Analysis AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.

Use it in TypingMind

Enable Decision Tree Analysis in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Decision Tree Analysis on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Decision Tree Analysis is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Source: https://github.com/aipoch/medical-research-skills

Decision Tree Analysis

Use this skill to train a decision tree model from a tabular file and export feature importance ranking results.

Use This Skill When

  • You need a decision tree workflow in R for either classification or regression.
  • You need feature importance ranking as a table and a figure.
  • You need a command-line workflow with parameter validation and standardized output folders.

Primary Command

bash
Rscript scripts/main.R \
  --data_file <input_file> \
  --target_var <target_column> \
  --task_type <auto|classification|regression> \
  --output_dir <output_dir>

Prerequisites

  • Rscript is available in the shell.
  • Required R packages: optparse, data.table, rpart.
  • Install missing packages with Rscript -e 'install.packages(c("optparse", "data.table", "rpart"), repos="https://cloud.r-project.org")'.

Core Arguments

ArgumentRequiredDescription
--data_fileYesInput data file in CSV, TXT, or TSV format
--target_varYesTarget column to predict
--task_typeNoauto, classification, or regression. Default auto
--output_dirNoOutput directory, default ./Decision_Tree_Results
--train_ratioNoTrain set ratio between 0 and 1, default 0.7
--max_depthNoMaximum tree depth, default 5
--minsplitNoMinimum observations required to attempt a split, default 10
--minbucketNoMinimum observations allowed in a terminal node, default 3
--cpNoComplexity parameter for pruning, default 0.001
--seedNoRandom seed, default 42
--exclude_varsNoComma-separated columns to exclude from modeling
--importance_top_nNoNumber of top features to show in the importance plot, default 15
--output_formatNoTable output format: csv or txt, default csv

Input Requirements

  • The input file must contain the target column.
  • All predictor columns come from the remaining columns after excluding target_var and exclude_vars.
  • If the first column is unnamed or uses an ID-like name such as id or rowname, and its values are unique, the skill automatically treats it as row names instead of a predictor.
  • Rows with missing values in any modeling column are removed before training.
  • Character predictors are automatically converted to factors.
  • In auto mode, a numeric target with more than 10 unique values is treated as regression; otherwise it is treated as classification.
  • At least 5 complete rows are required after filtering.

Example input:

csv
study_hours,sleep_hours,attendance,score_band
3.5,7.0,0.88,medium
5.0,6.5,0.95,high
2.0,8.0,0.75,low

Minimal Workflow

  1. Confirm the input file exists and the target column name is correct.
  2. Run scripts/main.R with the target column and optional modeling parameters.
  3. Check the output directory for feature importance tables under table/ and the ranking plot under figure/.

If you omit --data_file or --target_var, the script exits with SKILL_MISSING_INPUT.

Outputs

Expected output structure:

text
<output_dir>/
├── data/
├── table/
└── figure/

Primary result files:

  • table/decision_tree_feature_importance.<csv|txt>
  • table/decision_tree_metrics.csv
  • figure/decision_tree_feature_importance.pdf

Additional files:

  • data/decision_tree_predictions.csv
  • data/decision_tree_model.rds

Notes:

  • Exactly one feature-importance table is written per run. The file extension is controlled by --output_format.
  • Evaluation metrics are saved to table/decision_tree_metrics.csv.
  • If the fitted tree does not split, the run completes but emits a warning because feature importances and predictions may be degenerate on very small training sets.

Feature importance result fields include:

  • rank
  • feature
  • importance
  • relative_importance

Choose the Task Type

  • Use classification for categorical targets such as yes/no, risk_level, or species.
  • Use regression for continuous numeric targets such as price, score, or yield.
  • Use auto when the target type is obvious and you want the script to infer it.

Read These Files When Needed

NeedFile
Decision tree method and feature importance detailsreferences/algorithm.md
More CLI examplesreferences/cli-guide.md
Error diagnosisreferences/troubleshooting.md
Main execution entry pointscripts/main.R
Sample test datatests/data/

Test Data

  • tests/data/dt_sample1.csv: CSV classification sample with an unnamed first column automatically recognized as row names. Suggested target: fustat.
  • tests/data/dt_sample2.csv: CSV classification sample with an unnamed first column automatically recognized as row names. Suggested target: fustat.
  • tests/data/dt_sample3.txt: Tab-delimited high-dimensional classification sample with an unnamed first column automatically recognized as row names. Suggested target: Group.

Quick Examples

Classification:

bash
Rscript scripts/main.R \
  --data_file tests/data/dt_sample1.csv \
  --target_var fustat \
  --task_type classification \
  --max_depth 4 \
  --output_dir tests/output_dt_sample1_classification

Classification on a second CSV sample:

bash
Rscript scripts/main.R \
  --data_file tests/data/dt_sample2.csv \
  --target_var fustat \
  --task_type classification \
  --output_dir tests/output_dt_sample2_classification

TXT input example:

bash
Rscript scripts/main.R \
  --data_file tests/data/dt_sample3.txt \
  --target_var Group \
  --task_type classification \
  --max_depth 4 \
  --output_dir tests/output_dt_sample3_classification

Validation

bash
Rscript scripts/main.R --help
bash
Rscript scripts/main.R \
  --data_file tests/data/dt_sample1.csv \
  --target_var fustat \
  --task_type classification \
  --output_dir tests/validation_dt_sample1
bash
Rscript scripts/main.R \
  --data_file tests/data/dt_sample2.csv \
  --target_var fustat \
  --task_type classification \
  --output_dir tests/validation_dt_sample2
bash
Rscript scripts/main.R \
  --data_file tests/data/dt_sample3.txt \
  --target_var Group \
  --task_type classification \
  --output_dir tests/validation_dt_sample3

After running analysis, verify that the following exist:

  • tests/validation_dt_sample1/table/decision_tree_feature_importance.csv
  • tests/validation_dt_sample1/table/decision_tree_metrics.csv
  • tests/validation_dt_sample1/figure/decision_tree_feature_importance.pdf
  • tests/validation_dt_sample2/table/decision_tree_feature_importance.csv
  • tests/validation_dt_sample2/table/decision_tree_metrics.csv
  • tests/validation_dt_sample2/figure/decision_tree_feature_importance.pdf
  • tests/validation_dt_sample3/table/decision_tree_feature_importance.csv
  • tests/validation_dt_sample3/table/decision_tree_metrics.csv
  • tests/validation_dt_sample3/figure/decision_tree_feature_importance.pdf

Common Errors

  • SKILL_FILE_NOT_FOUND: Input file path is wrong or inaccessible.
  • SKILL_MISSING_COLUMNS: The target column or requested excluded columns are missing.
  • SKILL_INVALID_DATA: Input data is malformed or unsuitable for model training.
  • SKILL_INVALID_PARAMETER: An argument value is invalid.
  • SKILL_INSUFFICIENT_DATA: Too few usable rows or classes remain after filtering.
  • SKILL_DEPENDENCY_MISSING: A required R package such as optparse, data.table, or rpart is unavailable.

If a run succeeds but logs that the decision tree did not split, lower --minsplit and --minbucket or provide more training rows before trusting the ranking output.

If the issue is not obvious, read references/troubleshooting.md.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Decision Tree Analysis AI skill do?

Use when building a decision tree model in R and generating feature importance ranking outputs. Supports classification and regression, automatic task detection, parameter validation, model evaluation summaries, and exports of feature-importance tables and figures.

Why use Decision Tree Analysis on TypingMind?

Because you install it once and use it with any model. Decision Tree Analysis is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Decision Tree Analysis in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/aipoch/medical-research-skills/tree/main/awesome-med-research-skills/Data%20Analysis/decision-tree-analysis. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Decision Tree Analysis?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Decision Tree Analysis?

As many as you like. As long as a model supports skills, you can use Decision Tree Analysis with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Decision Tree Analysis AI skill free?

Yes. It is published on GitHub by aipoch under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇