Guide for creating DAAF agent definition files. Covers 12-section template, hook registration, skills-in-frontmatter, integration checklist. Use when adding or revising agents. For SKILL.md files, use skill-authoring instead.
中文简介正在准备中。当前显示原文说明。
R machine learning with tidymodels: recipes (preprocessing), parsnip (model specs), workflows (fit pipelines), tune (hyperparameters), rsample (resampling). Engines: ranger (RF), glmnet (lasso/ridge), xgboost, kknn. Model interpretation (permutation importance, PDP/ICE, SHAP via DALEX/iml/kernelshap) and fairness assessment (fairmodels). UMAP via uwot. Use when execution language is R. Python equivalent: scikit-learn. For econometric regression use fixest or r-stats.
中文简介正在准备中。当前显示原文说明。
实测评分 未实测
查看安装方法安装前可以查看交给 AI 代理的指令内容。
R machine learning with the tidymodels ecosystem. Covers recipes for preprocessing (normalization, dummy encoding, imputation, interactions), parsnip for model specifications (linear_reg, logistic_reg, rand_forest, boost_tree, nearest_neighbor), workflows for combining recipe + model into a single fit/predict pipeline, tune for hyperparameter optimization via grid search and cross-validation, rsample for resampling (v-fold CV, bootstrap, LOO), and yardstick for evaluation metrics (rmse, accuracy, roc_auc, confusion matrix). Engines: ranger (random forest), glmnet (lasso/ridge/elasticnet), xgboost (gradient boosting), kknn (k-nearest neighbors). Also covers model interpretation (permutation importance, PDP/ICE, SHAP via DALEX, iml, and kernelshap) and fairness assessment (fairmodels). UMAP via uwot (not part of tidymodels). Use when execution language is R and the task involves classification, prediction, clustering via recipes, or preprocessing for ML. Python equivalent: scikit-learn. For econometric regression (OLS, FE, IV, DiD) use fixest or r-stats.
Comprehensive skill for machine learning in R with tidymodels. Covers supervised methods (classification, regression), preprocessing (recipes), hyperparameter tuning, resampling, evaluation, and unsupervised dimension reduction. Use decision trees below to find the right guidance, then load detailed references.
tidymodels (Kuhn & Wickham) is R's unified machine learning framework, designed as the successor to caret:
set_engine() decouples model type from implementation
(e.g., rand_forest() |> set_engine("ranger") vs set_engine("randomForest"))fit(), predict(), augment() --
same verbs regardless of engineThis skill targets tidymodels 1.4.1 (R 4.5.3). Key package versions:
| Package | Version | Role |
|---|---|---|
| recipes | 1.3.2 | Preprocessing step definitions |
| parsnip | 1.5.0 | Model specifications + engine bindings |
| workflows | 1.3.0 | Recipe + model bundling |
| tune | 2.0.1 | Hyperparameter tuning infrastructure |
| rsample | 1.3.2 | Resampling (CV, bootstrap, etc.) |
| yardstick | 1.4.0 | Evaluation metrics |
| dials | 1.4.3 | Parameter ranges for tuning |
| ranger | 0.18.0 | Random forest engine |
| glmnet | 4.1-10 | Regularized regression engine |
| xgboost | 3.2.1.1 | Gradient boosting engine |
| kknn | 1.4.1 | K-nearest neighbors engine |
| uwot | 0.2.4 | UMAP (not tidymodels, standalone) |
| vip | 0.4.5 | Variable importance plots |
| DALEX | 2.5.3 | Model interpretation framework |
| iml | 0.11.4 | Model interpretation framework |
| kernelshap | 0.9.1 | Kernel SHAP |
| fairmodels | 1.2.2 | Fairness assessment |
Each topic in ./references/ contains focused documentation:
| File | Purpose | When to Read |
|---|---|---|
quickstart.md | Full tidymodels workflow: recipe, model spec, workflow, fit, predict | First use of tidymodels |
recipes.md | step_normalize, step_dummy, step_impute_*, step_interact, roles | Preprocessing tasks |
models.md | parsnip model specs: linear_reg, logistic_reg, rand_forest, boost_tree, nearest_neighbor | Choosing and configuring models |
workflows.md | workflow() + add_recipe + add_model, fit(), predict(), augment() | Building ML pipelines |
tuning.md | tune(), tune_grid(), collect_metrics(), select_best(), finalize_workflow | Hyperparameter optimization |
resampling.md | vfold_cv, bootstraps, loo_cv, group_vfold_cv, strata, assessment/analysis | Creating resamples |
engines.md | ranger, glmnet, xgboost, kknn: engine-specific args, installation, tuning params | Engine configuration |
unsupervised.md | PCA via recipes::step_pca, UMAP via uwot::umap(), k-means via stats::kmeans | Dimension reduction, clustering |
evaluation.md | yardstick metrics: rmse, accuracy, roc_auc, conf_mat, metric_set() | Evaluating model performance |
interpretation.md | Permutation importance, PDP/ICE, SHAP via DALEX/iml/kernelshap, vip, native engine importance | Explaining model predictions |
fairness.md | fairness_check() via fairmodels + DALEX, yardstick group metrics, reweight/roc_pivot mitigation | Fairness assessment of classifiers |
gotchas.md | Recipe baking order, data leakage, parsnip mode, engine args, tidymodels vs caret | Debugging common mistakes |
quickstart.md then workflows.mdrecipes.mdmodels.md then engines.mdtuning.md then resampling.mdevaluation.mdinterpretation.mdfairness.mdunsupervised.mdquickstart.md then gotchas.mdgotchas.md first| Skill | Relationship |
|---|---|
scikit-learn | Python equivalent -- Pipeline/estimator pattern vs tidymodels recipe/workflow pattern. Load when execution language is Python. |
data-scientist | Methodology guidance -- load for "when and why" behind methods |
r-python-translation | Cross-language mappings for R tidymodels vs Python scikit-learn |
fixest | Econometric regression with FE/IV/DiD in R. Use instead of tidymodels for causal inference. |
r-stats | Base R stats for OLS/GLM without FE. Use instead of tidymodels for simple regression without regularization or tuning. |
ggplot2 | Visualization of model results. tidymodels objects are tidy -- pipe directly to ggplot2. |
Routing guidance:
fixest or r-stats -- not tidymodelsexploratory-unsupervised.md in the data-scientist skillr-statstidyverseWhat kind of prediction?
+-- Continuous outcome (regression)
| +-- Simple linear --> linear_reg() (./references/models.md)
| +-- Regularized (lasso/ridge) --> linear_reg(penalty, mixture) with glmnet
| | (./references/models.md + ./references/engines.md)
| +-- Tree-based --> rand_forest() or boost_tree()
| | (./references/models.md)
| +-- Need to tune hyperparameters --> ./references/tuning.md
| +-- NOTE: For econometric regression (causal inference, SEs),
| use fixest or r-stats instead
+-- Categorical outcome (classification)
| +-- Binary --> logistic_reg() (./references/models.md)
| +-- Multi-class --> multinom_reg() or rand_forest()
| | (./references/models.md; logistic_reg() is binary-only)
| +-- Best performance --> boost_tree() with xgboost
| | (./references/models.md + ./references/engines.md)
| +-- Need tuning --> ./references/tuning.md
What preprocessing?
+-- Normalize numeric features --> step_normalize() (./references/recipes.md)
+-- Create dummy variables --> step_dummy() (./references/recipes.md)
+-- Handle missing values --> step_impute_mean/median/knn (./references/recipes.md)
+-- Create interactions --> step_interact() (./references/recipes.md)
+-- PCA / dimension reduction --> step_pca() (./references/unsupervised.md)
+-- Mixed types (numeric + categorical) --> recipe with multiple steps
| (./references/recipes.md)
+-- Feature engineering --> step_mutate(), step_log() (./references/recipes.md)
What evaluation?
+-- Regression metrics
| +-- RMSE, MAE, R-squared --> ./references/evaluation.md
+-- Classification metrics
| +-- Accuracy, ROC-AUC, confusion matrix --> ./references/evaluation.md
| +-- Precision, recall, F1 --> ./references/evaluation.md
+-- Cross-validated performance
| +-- collect_metrics() from tune_grid --> ./references/tuning.md
+-- Compare multiple models
| +-- collect_metrics() + bind_rows --> ./references/evaluation.md
What do I need?
+-- Feature importance (permutation, model-agnostic) --> DALEX model_parts()
| or iml FeatureImp (./references/interpretation.md)
+-- Feature importance (engine-native, fast) --> ranger/xgboost importance + vip
| (./references/interpretation.md; ranger needs importance= in set_engine)
+-- Feature effects (PDP / ICE) --> DALEX model_profile() or iml FeatureEffect
| (./references/interpretation.md)
+-- SHAP values --> kernelshap (many rows) or predict_parts/Shapley (single row)
| (./references/interpretation.md)
+-- Fairness metrics by protected group --> fairmodels fairness_check()
| (./references/fairness.md)
+-- NOTE: methodology (when to interpret, causal caveats, fairness criteria)
--> data-scientist skill: supervised-ml.md
Tuning approach?
+-- Grid search (exhaustive) --> tune_grid() (./references/tuning.md)
+-- Which parameters to tune --> tune() placeholder + dials ranges
| (./references/tuning.md)
+-- Select best model --> select_best() + finalize_workflow()
| (./references/tuning.md)
+-- Resampling for tuning --> vfold_cv() (./references/resampling.md)
What unsupervised method?
+-- PCA (within a recipe) --> step_pca() (./references/unsupervised.md)
+-- UMAP --> uwot::umap() (./references/unsupervised.md)
+-- K-means clustering --> stats::kmeans() (./references/unsupervised.md)
+-- NOTE: tidymodels focuses on supervised learning. For advanced
clustering, see data-scientist skill methodology guidance.
Common issues?
+-- "recipe must be prepped" --> ./references/gotchas.md
+-- "set mode" error --> ./references/gotchas.md
+-- Engine-specific args not working --> ./references/gotchas.md
+-- Predictions wrong type --> ./references/gotchas.md
+-- Data leakage concerns --> ./references/gotchas.md
+-- tidymodels vs caret migration --> ./references/gotchas.md
Important: In DAAF research pipelines, tidymodels analyses are executed through script files, not interactively. This ensures auditability and reproducibility.
The pattern:
scripts/stage8_analysis/{step}_{task-name}.RClosely read agent_reference/SCRIPT_EXECUTION_REFERENCE.md for the mandatory
file-first execution protocol covering complete code file writing, output capture,
and file versioning rules. All ML scripts must follow the Inline Audit Trail (IAT)
standard -- see agent_reference/INLINE_AUDIT_TRAIL.md. For ML code, document
model selection rationale (why this algorithm, why these hyperparameters, what
assumptions) with # INTENT:, # REASONING:, and # ASSUMES: comments.
See:
agent_reference/WORKFLOW_PHASE4_ANALYSIS.md -- Stage 8 (Analysis & Visualization)agent_reference/INLINE_AUDIT_TRAIL.md -- IAT documentation standardThe examples below show tidymodels syntax. In research workflows, wrap them in scripts following the file-first pattern.
library(tidymodels) # Loads recipes, parsnip, workflows, tune, rsample, yardstick, dials
library(arrow) # For parquet I/O (DAAF convention)
# 1. Define recipe (preprocessing)
rec <- recipe(outcome ~ ., data = train_data) |>
step_normalize(all_numeric_predictors()) |>
step_dummy(all_nominal_predictors())
# 2. Define model specification
spec <- rand_forest(trees = 500) |>
set_engine("ranger") |>
set_mode("classification")
# 3. Bundle into workflow
wf <- workflow() |>
add_recipe(rec) |>
add_model(spec)
# 4. Fit
fit <- wf |> fit(data = train_data)
# 5. Predict
preds <- fit |> predict(new_data = test_data)
| Operation | Code |
|---|---|
| Create recipe | recipe(y ~ ., data = df) |
| Normalize numeric | step_normalize(all_numeric_predictors()) |
| Dummy encode | step_dummy(all_nominal_predictors()) |
| Impute missing | step_impute_median(all_numeric_predictors()) |
| Random forest | rand_forest(trees = 500) |> set_engine("ranger") |
| Logistic regression | logistic_reg() |> set_engine("glm") |
| Lasso | linear_reg(penalty = 0.01, mixture = 1) |> set_engine("glmnet") |
| Ridge | linear_reg(penalty = 0.01, mixture = 0) |> set_engine("glmnet") |
| XGBoost | boost_tree(trees = 500) |> set_engine("xgboost") |
| Build workflow | workflow() |> add_recipe(rec) |> add_model(spec) |
| Fit workflow | wf |> fit(data = train_data) |
| Predict | fit |> predict(new_data = test_data) |
| Augment | fit |> augment(new_data = test_data) |
| V-fold CV | vfold_cv(train_data, v = 10, strata = outcome) |
| Tune grid | tune_grid(wf, resamples = folds, grid = 20) |
| Best params | select_best(tune_results, metric = "rmse") |
| Finalize | finalize_workflow(wf, best_params) |
| RMSE | rmse(results, truth = y, estimate = .pred) |
| Accuracy | accuracy(results, truth = y, estimate = .pred_class) |
| ROC AUC | roc_auc(results, truth = y, .pred_class1) |
| Confusion matrix | conf_mat(results, truth = y, estimate = .pred_class) |
| Topic | Reference File |
|---|---|
| First tidymodels workflow | ./references/quickstart.md |
| recipe + spec + workflow pattern | ./references/quickstart.md |
| fit() and predict() | ./references/quickstart.md |
| train/test split | ./references/quickstart.md |
| step_normalize | ./references/recipes.md |
| step_dummy | ./references/recipes.md |
| step_impute_mean / median / knn | ./references/recipes.md |
| step_interact | ./references/recipes.md |
| step_mutate / step_log | ./references/recipes.md |
| Role assignment (update_role) | ./references/recipes.md |
| prep() and bake() | ./references/recipes.md |
| Selector functions | ./references/recipes.md |
| linear_reg | ./references/models.md |
| logistic_reg | ./references/models.md |
| multinom_reg (multiclass) | ./references/models.md |
| rand_forest | ./references/models.md |
| boost_tree | ./references/models.md |
| nearest_neighbor | ./references/models.md |
| set_engine() | ./references/models.md |
| set_mode() | ./references/models.md |
| workflow() construction | ./references/workflows.md |
| add_recipe / add_model | ./references/workflows.md |
| fit() on workflow | ./references/workflows.md |
| predict() on workflow | ./references/workflows.md |
| augment() | ./references/workflows.md |
| extract_fit_parsnip | ./references/workflows.md |
| tune() placeholder | ./references/tuning.md |
| tune_grid() | ./references/tuning.md |
| collect_metrics() | ./references/tuning.md |
| select_best() | ./references/tuning.md |
| finalize_workflow() | ./references/tuning.md |
| show_best() | ./references/tuning.md |
| dials parameter ranges | ./references/tuning.md |
| grid_space_filling / grid types | ./references/tuning.md |
| Parallel tuning (future backend) | ./references/tuning.md |
| vfold_cv | ./references/resampling.md |
| bootstraps | ./references/resampling.md |
| loo_cv | ./references/resampling.md |
| group_vfold_cv | ./references/resampling.md |
| strata argument | ./references/resampling.md |
| analysis() / assessment() | ./references/resampling.md |
| initial_split / training / testing | ./references/resampling.md |
| initial_validation_split / validation_set | ./references/resampling.md |
| ranger (random forest) | ./references/engines.md |
| glmnet (lasso / ridge / elasticnet) | ./references/engines.md |
| xgboost (gradient boosting) | ./references/engines.md |
| kknn (k-nearest neighbors) | ./references/engines.md |
| Engine-specific arguments | ./references/engines.md |
| PCA via step_pca | ./references/unsupervised.md |
| UMAP via uwot | ./references/unsupervised.md |
| K-means via stats::kmeans | ./references/unsupervised.md |
| rmse, mae, rsq | ./references/evaluation.md |
| accuracy, precision, recall, f_meas | ./references/evaluation.md |
| roc_auc, roc_curve | ./references/evaluation.md |
| conf_mat | ./references/evaluation.md |
| metric_set() | ./references/evaluation.md |
| Permutation importance (DALEX / iml) | ./references/interpretation.md |
| PDP / ICE plots | ./references/interpretation.md |
| SHAP (kernelshap, predict_parts, Shapley) | ./references/interpretation.md |
| vip / engine-native importance | ./references/interpretation.md |
| fairness_check (fairmodels) | ./references/fairness.md |
| Group-wise yardstick metrics | ./references/fairness.md |
| Fairness mitigation (reweight, roc_pivot) | ./references/fairness.md |
| Recipe baking order | ./references/gotchas.md |
| Data leakage in recipes | ./references/gotchas.md |
| parsnip mode requirement | ./references/gotchas.md |
| Engine-specific args (set_engine) | ./references/gotchas.md |
| tidymodels vs caret | ./references/gotchas.md |
| Prediction type (.pred vs .pred_class) | ./references/gotchas.md |
When this framework is used as a primary analytical tool, include in the report's Software & Tools references:
Kuhn, M. & Wickham, H. (2020). Tidymodels: a collection of packages for modeling and machine learning using tidyverse principles. https://www.tidymodels.org
Cite when: tidymodels is used for model fitting, preprocessing, tuning, or evaluation central to the analysis. Do not cite when: Only loaded but no modeling performed.
For engine-specific citations:
Wright, M.N. & Ziegler, A. (2017). "ranger: A Fast Implementation of Random Forests for High Dimensional Data in C++ and R." Journal of Statistical Software, 77(1), 1-17. (ranger engine)
Friedman, J., Hastie, T., & Tibshirani, R. (2010). "Regularization Paths for Generalized Linear Models via Coordinate Descent." Journal of Statistical Software, 33(1), 1-22. (glmnet engine)
Chen, T. & Guestrin, C. (2016). "XGBoost: A Scalable Tree Boosting System." Proceedings of the 22nd ACM SIGKDD, 785-794. (xgboost engine)
For method-specific citations, consult the reference files in this skill and
agent_reference/CITATION_REFERENCE.md.
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Guide for creating DAAF agent definition files. Covers 12-section template, hook registration, skills-in-frontmatter, integration checklist. Use when adding or revising agents. For SKILL.md files, use skill-authoring instead.
中文简介正在准备中。当前显示原文说明。
Researcher-facing analytic triangulation ("creative verification") for stress-testing provisional findings and designing pre-specified challenges before an analysis runs. Turns a researcher's concern or focal claim into competing explanations, bounded discriminating tests, audited diagnostic artifacts, and evidence-calibrated interpretations in a hypothesis/evidence ledger — behavioral, output-level verification replacing line-by-line code review. Covers 12 challenge families organized by Shadish-Cook-Campbell validity type, named sensitivity statistics, pre-committed interpretation rules, anti-fishing guardrails, and interactive diagnostic-artifact QA. Use in Ad Hoc Collaboration to verify, challenge, or stress-test a result, or to design discriminating tests before an analysis runs. Not code-change verification (verify skill / code review) and not final adjudication or re-execution (data-verifier, Reproducibility Verification) — prospective, hypothesis-driven challenge design of analytic claims.
中文简介正在准备中。当前显示原文说明。
In-situ smoke testing that verifies a LIVE DAAF deployment functions end-to-end in whatever provider route it is configured for. Auto-detects the active install route (anthropic-subscription, openrouter, chatgpt-subscription shim, openai-api shim) and runs tiered probes: Tier 0 free preflight (route/env coherence, hooks, statuslines, shim health); Tier 1 one live round-trip (~cents); Tier 2 a six-probe functional battery (dispatch, coding, web, skill loading, isolation-strip, nested-dispatch deny); Tier D a zero-cost deterministic battery (bats, Pester, lint, safety-hook tests). Use after install, after a rebuild or update, after any provider/config change (new API key, model remap, shim change), for pre-release validation, or when asked "is my install working" or to "smoke test the deployment/config." Requires the DAAF_DEV=1 dev image; a contributor tool, not end-user-facing. NOT DAAFBench (model behavioral-adherence evaluation under benchmarks/) and NOT scripts/smoke_tests/ (R/Python library-package smoke tests).
中文简介正在准备中。当前显示原文说明。
Operational framework for the DAAF orchestrator. Defines engagement modes, confirmation protocol, subagent dispatch, context budget, and reference-loading. Loaded exclusively by the orchestrator — not for subagents or user questions.
中文简介正在准备中。当前显示原文说明。
Data science methodology and method-selection routing for quantitative research. Covers EDA, data validation, descriptive analysis, causal inference (IV, DiD, RD, synthetic control), clustering/PCA/UMAP, supervised ML, geospatial analysis, network analysis, and visualization design. Contains the canonical method-to-library routing tree, routed by execution language — Python: statsmodels (OLS/GLM/time series), pyfixest (FE/DiD), linearmodels (RE/GMM/SUR), svy (complex surveys), scikit-learn (clustering/prediction ML), geopandas (spatial), igraph (network analysis); R: r-stats (OLS/GLM/time series), fixest (FE/DiD), plm (panel/RE/IV), survey-r (complex surveys), tidymodels (ML), sf-terra (spatial), igraph-r (network analysis). Load the routed tool-specific skill before giving tool-specific advice or writing code — library skills encode environment constraints and curated caveats absent from general knowledge.
中文简介正在准备中。当前显示原文说明。
Interpretation guidance for Urban Institute Education Data Portal datasets. The Portal is a curation layer over federal data: lowercase variable names, integer-encoded categoricals, standardized missing codes (-1 missing, -2 not applicable, -3 suppressed). Covers year definitions, grade encoding (grade=-1 is Pre-K, not missing), suppression rates, ODC-By licensing, and cross-source join identifiers. Load before analyzing any Portal data. Routes to source-specific deep-dive skills for individual datasets.
中文简介正在准备中。当前显示原文说明。