Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/elenacarino-max/Pildora4_ext_StarWars/llms.txt

Use this file to discover all available pages before exploring further.

After sealing all six chambers, a team is ready for the missions — three increasingly difficult challenges that reconstruct real Random Forest experiments on the scikit-learn Digits dataset. Each mission asks the student to write (or repair) the complete MLflow tracking block for one training run: five parameters, four core metrics, two artifact files, and one serialised model, following the 5–4–2–1 Jedi Code. The three missions use different hyperparameter combinations (n_estimators 50 → 100 → 300; max_depth 8 → 10 → None) so the resulting metrics differ and meaningful comparison is possible in the Consejo screen. Every mission awards 30 points; completing all three adds a further 15-point bonus.

The canonical template

All three missions share the same structural template. The only elements that change between missions are the run_name value and the hyperparameters in parametros.
with mlflow.start_run(run_name="Mision_{name}"):
    mlflow.log_params(parametros)
    mlflow.log_metrics(metricas)
    mlflow.log_artifact("matriz_confusion.png")
    mlflow.log_artifact("classification_report.json")
    mlflow.sklearn.log_model(
        sk_model=modelo,
        artifact_path="modelo_digits",
    )

Parameters available in all missions

The parametros dictionary is pre-populated in the guided and sabotaged missions and must be constructed by the student in the autonomous mission. It always contains these five keys, drawn from execute_safe_mission in mlflow_engine.py:
params = {
    "dataset": "digits",
    "n_estimators": mission["n_estimators"],  # 50 / 100 / 300
    "max_depth": "None" if mission["max_depth"] is None else mission["max_depth"],  # 8 / 10 / None
    "test_size": 0.20,
    "random_state": 42,
}
Note that max_depth=None is serialised as the string "None" so it stores cleanly in MLflow’s parameter store.

Metrics computed

The metricas dictionary is computed by execute_safe_mission after training and always contains these six keys:
KeyComputation
accuracyaccuracy_score(y_test, predictions)
precision_weightedprecision_score(..., average="weighted")
recall_weightedrecall_score(..., average="weighted")
f1_weightedf1_score(..., average="weighted")
recall_1Recall for digit class "1" from classification_report
recall_8Recall for digit class "8" from classification_report
The four weighted-average metrics are the core summary; recall_1 and recall_8 are surfaced specifically in the Consejo screen to prompt a deeper, per-class analysis.

Mission 1 — Tatooine

PropertyValue
ModeMisión guiada
n_estimators50
max_depth8
Accent colour#d9a441
Brief: Completa una estructura preparada y recupera el primer expediente. Theory: Una run reúne la configuración usada, los resultados obtenidos, los archivos de diagnóstico y el modelo. Aquí practicarás el patrón completo sin ejecutar tu texto: la app valida su estructura y después utiliza una plantilla interna segura. Starter code:
# 🛰️ MISIÓN GUIADA: completa las cinco piezas dentro de la run
with mlflow.start_run(run_name="Mision_Tatooine"):
    # ⚙️ 1. Registra parametros
    # 📡 2. Registra metricas
    # 🔷 3. Registra los dos artefactos
    # 🤖 4. Registra modelo
    pass
Context provided to students:
parametros = {"dataset": "digits", "n_estimators": 50, "max_depth": 8, "test_size": 0.2, "random_state": 42}
metricas = {"accuracy": accuracy, "precision_weighted": precision_weighted, "recall_weighted": recall_weighted, "f1_weighted": f1_weighted}
# También existen modelo, matriz_confusion.png y classification_report.json
Indicative results (actual values depend on the random split, but these are the expected orientative figures):
MetricValue
accuracy0.9556
precision_weighted0.9562
recall_weighted0.9556
f1_weighted0.9554
recall_10.9167
recall_80.8571
Difficulty notes: All five tracking calls are signposted with comment markers. The student fills in the blanks; the structural skeleton is already correct.

Mission 2 — Coruscant

PropertyValue
ModeMisión saboteada
n_estimators100
max_depth10
Accent colour#43c8d8
Brief: Corrige el intercambio entre parámetros, métricas y artefactos. Theory: Los parámetros describen decisiones anteriores al entrenamiento; las métricas son resultados numéricos posteriores; los artefactos son archivos. Coruscant contiene llamadas válidas colocadas en la categoría equivocada. Starter code:
# ⚔️ MISIÓN SABOTEADA: corrige las categorías y completa las evidencias
with mlflow.start_run(run_name="Mision_Coruscant"):
    mlflow.log_metrics(parametros)  # BUG: decisiones previas
    mlflow.log_params(metricas)    # BUG: resultados
    mlflow.log_artifact("matriz_confusion.png")
    # 🔷 Falta el segundo artefacto
    # 🤖 Falta conservar el modelo
Context provided to students:
parametros = {"dataset": "digits", "n_estimators": 100, "max_depth": 10, "test_size": 0.2, "random_state": 42}
metricas = {"accuracy": accuracy, "precision_weighted": precision_weighted, "recall_weighted": recall_weighted, "f1_weighted": f1_weighted}
# Repara el sabotaje y conserva dos artefactos y el modelo.
Indicative results:
MetricValue
accuracy0.9611
precision_weighted0.9620
recall_weighted0.9611
f1_weighted0.9609
recall_10.9722
recall_80.8571
Difficulty notes: The sabotage swaps log_params and log_metrics — the most common conceptual confusion. Students must also add the missing second artifact and the model registration.

Mission 3 — Mustafar

PropertyValue
ModeMisión autónoma
n_estimators300
max_depthNone (unlimited)
Accent colour#df6548
Brief: Escribe el tracking 5–4–2–1 con la mínima ayuda del Archivo. Theory: En una run completa registrarás cinco parámetros, cuatro métricas, dos artefactos y un modelo. MLflow no entrena: documenta lo que scikit-learn ya ha producido para poder comparar y reutilizar. Starter code:
# 🌋 MISIÓN AUTÓNOMA · CÓDIGO JEDI 5–4–2–1
# ✦ Abre la run Mision_Mustafar y escribe aquí el tracking completo.
pass
Context provided to students:
# Dispones de: parametros, metricas, modelo, matriz_confusion.png y classification_report.json.
# La run debe llamarse Mision_Mustafar y contener todas las llamadas.
Indicative results:
MetricValue
accuracy0.9694
precision_weighted0.9701
recall_weighted0.9694
f1_weighted0.9692
recall_11.0000
recall_80.8571
Difficulty notes: No scaffolding is provided. The student must reproduce the full canonical template from memory, choosing the correct run name and including all seven tracking calls. max_depth=None (unlimited trees) produces the highest accuracy of the three missions and a perfect recall_1, giving teams something meaningful to note in their Consejo recommendation.

Validation rules

validate_mission_submission in code_validator.py applies the following checks in order. All checks are purely structural (AST-based — no code is executed).
1

Required calls present

The submission must contain all five distinct MLflow calls: mlflow.start_run, mlflow.log_params, mlflow.log_metrics, mlflow.log_artifact, and mlflow.sklearn.log_model. Any missing call triggers: “Faltan piezas del Código Jedi 5–4–2–1: <missing>”
2

Two artifact calls

mlflow.log_artifact must appear at least twice. A single artifact call is rejected with: “La misión necesita dos artefactos de evidencia.”
3

log_params argument is named parametros

The first argument to mlflow.log_params must be the bare name parametros (an ast.Name node with id == "parametros"). Any other argument — including an inline dict literal — is rejected with: “log_params debe recibir parametros: son decisiones anteriores al entrenamiento.”
4

log_metrics argument is named metricas

The first argument to mlflow.log_metrics must be the bare name metricas. Rejected with: “log_metrics debe recibir metricas: son resultados de evaluación.”
5

Artifact filenames are exact

The two log_artifact calls must use exactly "matriz_confusion.png" and "classification_report.json" as string literals. Any other filenames trigger: “Registra exactamente matriz_confusion.png y classification_report.json.”
6

Model keywords present

mlflow.sklearn.log_model must include both sk_model and artifact_path as keyword arguments. Missing either triggers: “El modelo necesita sk_model=modelo y artifact_path=“modelo_digits”.”
7

run_name matches the mission

When a mission_id is provided, the run_name keyword in mlflow.start_run must match exactly:
  • tatooine"Mision_Tatooine"
  • coruscant"Mision_Coruscant"
  • mustafar"Mision_Mustafar"
A mismatch triggers: “La run debe llamarse exactamente <expected>.”
After validation passes, the app trains and tracks using its own internal safe template (execute_safe_mission) — the student’s submitted code is never executed. This design means the app is safe to use in any classroom environment without sandboxing concerns, and the results displayed are always reproducible from the same fixed random seed (42) and train/test split (80/20, stratified).

Build docs developers (and LLMs) love