SuperAPI AI Directory

model-code-and-result-generator

Data & analytics

View repository

Updated 10-16 09:16

About this skill

Modeling code and results evidence generator

Global workflow collaboration constraints (long-dialogue drift prevention)

  • This skill must not be used as an isolated entry point. When the user requests a complete paper, Word generation, continuing the workflow, or is unsure of the stage, first return to paper-workflow-orchestrator to determine the current S0-S8 stage.
  • Before starting or continuing a formal task for this skill, you must run:
    python .claude/skills/paper-workflow-orchestrator/scripts/workflow_guard.py --skill model-code-and-result-generator
    
  • If the output is [WORKFLOW FAIL] or it reports status != "PASS", stop this skill, and backfill the prerequisite stages according to the failed items in paper_output/qa/workflow_guard_report.json . Do not continue from memory.
  • This skill only writes the paper_output/ artifacts within its own contract scope; after completion, you must return to paper-workflow-orchestrator to determine the next step, and use context-memory-keeper to record completed artifacts, blockers, and next steps.
  • In a long dialogue, if the context grows long, the stage is uncertain, or the user invokes skills separately, first run:
    python .claude/skills/paper-workflow-orchestrator/scripts/workflow_guard.py --status
    
    then read paper_output/qa/workflow_guard_report.json、paper_output/preflight_report.json、paper_output/input_manifest.json、paper_output/results/run_manifest.json and this skill's upstream JSON contract, and continue according to the report's recommended_skill and next_action .
  • Before continuing the workflow, paper_output/context/workflow_memory.json must be treated as a long-term checkpoint record; if its current_step、next_step、recommended_skill and workflow_guard.py --status are inconsistent, the guard report takes precedence.
  • After completing this skill's artifacts each time, first return to paper-workflow-orchestrator or run workflow_guard.py --status, then update workflow memory:
    python .claude/skills/context-memory-keeper/scripts/update_workflow_memory.py
    
    after updating, read paper_output/context/workflow_memory.json / .md, and confirm that the next step and recommended skill have been recorded.

Objective

This skill is not an all-purpose automated modeling system. Its role is to give the Agent a stable "results evidence layer" and a runnable starting point for competition-problem-specific modeling code, avoiding a main text written only from the model route in the abstract, and avoiding the Agent flailing around when faced with data.

In a real competition problem, the Agent must, based on model_route.json, the data fields, the problem constraints, and the scoring requirements, secondarily modify the generated q*_model.py. Generated code is fixed in paper_output/code/modeling/; do not write it back to the skill package's scripts/。

Execution contract

  • Upstream input: preferentially read paper_output/plan/model_route.json、data_plan.json、visualization_plan.json, and scan paper_output/data_cleaned/。
  • Must output:paper_output/results/model_results.json、metrics.json、conclusions.json、run_manifest.json、paper_output/tables/table_index.json、paper_output/tables/*.csv。
  • Modeling code output:paper_output/code/modeling/result_contract_io.py、run_modeling.py、q1_model.py、q2_model.py、q3_model.py or the question_id corresponding to q*_model.py。
  • Downstream handoff:quality-assurance-auditor After reading the results and table evidence, write into tasks.json;paper-micro-unit-generator Reference results, metrics, tables, and conclusions through the task list.
  • Failure fallback: if there is no cleaned data or real modeling code, still generate the contract skeleton, and use needs_real_modeling to mark it, without pretending it is a final competition result.

Script

  • scripts/build_result_contracts.py
    • When to use: when a model route already exists and it is necessary to generate the results contract, table index, and q1/q2/q3 modeling code scaffolding for the current competition problem.
    • What it does: scan model_route.json for each question_id, generate the results contract skeleton, basic field profile tables,paper_output/code/modeling/README.md, and generate a runnable q*_model.py。
    • Overwrite rules: generated files carry a managed marker; if the Agent has already manually rewritten and removed the marker, this script will preserve the user's file and not overwrite it.
  • scripts/result_contract_templates.py
    • When to use: when you need to understand which metrics, tables, and conclusion fields should be produced for different task types.
    • What to do: provide contract templates for forecasting, optimization, evaluation, classification, clustering, simulation, and general modeling.

Task Type Dispatch

  • Forecasting/regression/time series -> forecasting scaffold: generate the target column, feature columns, predicted values, residuals, RMSE, MAE, MAPE.
  • Optimization/planning/scheduling/site selection/routing -> optimization scaffold: generate a surrogate objective function, solution ranking, and constraint satisfaction rate items to be completed.
  • Evaluation/ranking/weighting/TOPSIS/AHP/entropy weight -> evaluation scaffold: generate metric normalization, composite scores, ranking, and weight sensitivity items to be completed.
  • Classification/recognition/discrimination -> classification scaffold: generate surrogate classification labels, accuracy/F1 items to be completed.
  • Clustering/segmentation -> clustering scaffold: generate surrogate cluster labels, number of clusters, and intra-cluster compactness.
  • Simulation/mechanism/dynamics/differential -> simulation scaffold: generate trend surrogates, scenario results, fitting error, and sensitivity parameters.
  • Other -> general scaffold: generate a statistical summary of numeric fields and a general results table.

Output Location

paper_output/
|-- code/
|   `-- modeling/
|       |-- run_modeling.py
|       |-- result_contract_io.py
|       |-- q1_model.py
|       |-- q2_model.py
|       |-- q3_model.py
|       `-- README.md
|-- results/
|   |-- model_results.json
|   |-- metrics.json
|   `-- conclusions.json
`-- tables/
    |-- table_index.json
    |-- table_q1_result_skeleton.csv
    |-- table_q1_forecasting_scaffold.csv
    `-- ...

Unified Rules:

  • All paths use relative paths.
  • All JSON contains schema_version、generated_by、generated_at。
  • Every result, metric, conclusion, and table should carry question_id。
  • Draft or scaffold results must use status or evidence_status markers.
  • Official results must carry execution_provenance, including source_code_path、run_command、run_exit_code and output_artifacts; the unified entry point run_modeling.py must also write paper_output/results/run_manifest.json, recording the script command, exit code, input file hash, and output artifact hash. The official evidence gate will reject results that have no real code execution source or no corresponding run record in run_manifest.
  • Tables cited in the main text must be findable in paper_output/tables/table_index.json .

How to Use

Recommended to be called by paper-workflow-orchestrator after data cleaning and visualization. It can also be run manually:

python .claude/skills/model-code-and-result-generator/scripts/build_result_contracts.py

After generating the scaffold, the Agent should execute according to the real competition problem:

python paper_output/code/modeling/run_modeling.py

This entry point will write paper_output/results/run_manifest.json. Then rerun QA to let paper_output/tasks.json read the refreshed model_results.json、metrics.json、conclusions.json、run_manifest.json and table_index.json。

Principles for Using Real Competition Problems

  • Do not directly treat placeholder metrics or surrogate results as final competition results.
  • Prefer to modify paper_output/code/modeling/q*_model.py, and do not modify scripts/。
  • inside the skill package. After formal modeling is complete, the modeling code must actually run and write the real output back to paper_output/results/ and paper_output/tables/; do not handwrite model_results.json to pass it off as run results. Without run_manifest.json corresponding run records, it cannot enter the official evidence gate.
  • If a question has no real results, QA should keep the warning, and the main text must not describe that question as having completed precise calculations.