Run and advise on a case-based reasoning analysis with the CaseBasedReasoning R package: prepare the data, choose and fit a distance (Cox/linear/logistic regression, gradient boosting with SHAP distance, random forest, Gower), check the model, retrieve and explain similar cases, predict outcomes or survival curves from the neighbours, choose k and compare distances on held-out data, and maintain the case base (noisy, pivotal, redundant cases). Use this skill whenever a user asks to find similar cases or patients, build a k-NN or CBR analysis in R, compare distances, interpret evaluate(), explain_match() or assess_cases() output, or decide which CaseBasedReasoning model fits their data.
Ships in casebasedreasoning. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill runs a complete loop: prepare → choose distance → fit and check → retrieve and explain → reuse → evaluate and compare → maintain. It uses only methods exported by the package; for the API inventory see the cbr-capabilities skill.
| Stage | What happens | Key calls |
|---|---|---|
| 1. Prepare | Complete cases, factors, train/test split | na.omit(), factor() |
| 2. Choose | Pick candidate distances for the endpoint and data | see reference/choosing-a-distance.md |
| 3. Fit and check | Fit, check the assumptions, select variables | $fit(), $check_ph(), $variable_selection() |
| 4. Retrieve | Similar cases and why they are similar | $get_similar_cases(), $explain_match() |
| 5. Reuse | Predictions and counterfactuals from the neighbours | $predict_outcome(), $predict_survival(), $get_counterfactual_cases() |
| 6. Evaluate and compare | Choose k and the distance on held-out data | $evaluate(), $evaluate_survival() |
| 7. Maintain | Add cases, find noisy and redundant cases | $add_cases(), $assess_cases(), $remove_cases() |
reference/workflow.md: concrete R code for each stage.reference/choosing-a-distance.md: a decision guide with the advantages and
disadvantages of each distance.reference/interpreting-results.md: how to read the outputs of explain_match(),
evaluate(), evaluate_survival() and assess_cases(), plus common pitfalls.Rscript -e '
library(CaseBasedReasoning); library(survival)
df <- na.omit(lung[, c("time", "status", "age", "sex", "ph.ecog")])
df$status <- df$status - 1
df$sex <- factor(df$sex, labels = c("male", "female"))
set.seed(1); idx <- sample(nrow(df), 0.75 * nrow(df))
m <- CoxModel$new(Surv(time, status) ~ rcs(age, 3) + sex + ph.ecog, df[idx, ])
m$fit()
print(m$get_similar_cases(df[-idx, ][1, ], k = 5))
print(m$explain_match(df[-idx, ][1, ], df[idx, ][1, ]))
str(m$evaluate_survival(df[-idx, ], k = 20)[c("c_index", "ibs")])
'
k and the same
seed. On small test sets, differences in C-index or accuracy of a few hundredths are
usually noise. Say so instead of declaring a winner.CoxModel, run
check_ph() before you trust its distance. For an RFModel, set a seed.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
2 skills in this plugin
/casebasedreasoning:cbr-advisorfrom casebasedreasoning
npx claudepluginhub sipemu/case-based-reasoning --plugin casebasedreasoning