codegen-classroom 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/PKG-INFO +176 -154
- codegen_classroom-0.1.2/README.md +255 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/__init__.py +1 -1
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/agent_config.py +42 -6
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/agents.py +97 -18
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/agents_test.py +178 -4
- codegen_classroom-0.1.2/codegen_classroom/classroom_integration_test.py +301 -0
- codegen_classroom-0.1.2/codegen_classroom/data_utils.py +556 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/data_utils_test.py +177 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/plotting.py +477 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/reporting.py +290 -142
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/student_learning.py +1 -1
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/student_learning_test.py +37 -2
- codegen_classroom-0.1.2/codegen_classroom/tasks/AGENTS.md +116 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/README.md +303 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/__init__.py +15 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/config.py +670 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/data_loader.py +788 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/efficiency.py +868 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/esc50.ipynb +536 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/extract_embeddings.py +326 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/leaderboard.tsv +17 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/run_esc50.py +1629 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/run_esc50_test.py +1890 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/solutions/efficient/esc50_efficient_5s_10c_r1_20261117.md +986 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/solutions/efficient/esc50_efficient_5s_12c_r4_20261119.md +1459 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/solutions/efficient/esc50_efficient_5s_8c_r3_20261118.md +1114 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/solutions/fm/esc50_fm_5s_12c_r1_20261117.md +570 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/solutions/fm/esc50_fm_5s_6c_r2_20261117.md +671 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/solutions/fm/esc50_fm_5s_8c_r3_20261118.md +820 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/README.md +235 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/__init__.py +15 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/config.py +406 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/data_loader.py +511 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/fashion_mnist.ipynb +434 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/leaderboard.tsv +10 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/run_fashion_mnist.py +1184 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/run_fashion_mnist_test.py +1289 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/solutions/fashion_mnist_4s_6c_r2_20261117.md +741 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/solutions/fashion_mnist_5s_12c_r4_20261119.md +817 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/solutions/fashion_mnist_5s_8c_r3_20261118.md +1082 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/README.md +142 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/__init__.py +15 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/config.py +364 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/data_loader.py +119 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/housing.ipynb +415 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/leaderboard.tsv +19 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/run_housing.py +1030 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/run_housing_test.py +242 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/solutions/housing_5s_12c_r3_20261118.md +1635 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/solutions/housing_5s_8c_r2_20261118.md +1888 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/solutions/housing_6s_12c_v2_20261022.md +1918 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/template/README.md +86 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/config.py +22 -30
- codegen_classroom-0.1.2/codegen_classroom/tasks/template/leaderboard.tsv +7 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/template/run_template.py +620 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/run_template_test.py +49 -10
- codegen_classroom-0.1.2/codegen_classroom/tasks/template/solutions/template_5s_12c_r1_20261119.md +1451 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/template/solutions/template_5s_15c_r2_20261119.md +954 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/template/solutions/template_6s_12c_20261023.md +1148 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/template/task_example.ipynb +377 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/README.md +157 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/__init__.py +15 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/config.py +398 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/data_loader.py +225 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/leaderboard.tsv +12 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/run_wearable.py +899 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/run_wearable_test.py +280 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/solutions/wearable_5s_12c_r3_20261119.md +752 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/solutions/wearable_6s_12c_20261105.md +737 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/solutions/wearable_6s_12c_v4_20261105.md +689 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/wearable.ipynb +442 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/verify_task.py +5 -1
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/verify_task_test.py +4 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom.egg-info/PKG-INFO +176 -154
- codegen_classroom-0.1.2/codegen_classroom.egg-info/SOURCES.txt +89 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom.egg-info/requires.txt +8 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/pyproject.toml +34 -4
- codegen_classroom-0.1.0/README.md +0 -248
- codegen_classroom-0.1.0/codegen_classroom/classroom_integration_test.py +0 -152
- codegen_classroom-0.1.0/codegen_classroom/data_utils.py +0 -252
- codegen_classroom-0.1.0/codegen_classroom/tasks/AGENTS.md +0 -103
- codegen_classroom-0.1.0/codegen_classroom/tasks/template/README.md +0 -64
- codegen_classroom-0.1.0/codegen_classroom/tasks/template/leaderboard.tsv +0 -3
- codegen_classroom-0.1.0/codegen_classroom/tasks/template/run_template.py +0 -530
- codegen_classroom-0.1.0/codegen_classroom/tasks/template/solutions/template_4s_10c_student_2_gemini_3_5_flash_c8_r2_0p976_20261015.md +0 -904
- codegen_classroom-0.1.0/codegen_classroom/tasks/template/solutions/template_5s_12c_student_2_gemini_3_1_pro_preview_c5_r2_0p985_20261015.md +0 -865
- codegen_classroom-0.1.0/codegen_classroom/tasks/template/task_example.ipynb +0 -359
- codegen_classroom-0.1.0/codegen_classroom.egg-info/SOURCES.txt +0 -39
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/LICENSE +0 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/code_execution.py +0 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/code_execution_test.py +0 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/metrics.py +0 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/metrics_test.py +0 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/scoring.py +0 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/scoring_test.py +0 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/tasks/__init__.py +0 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/__init__.py +0 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/data_loader.py +0 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom.egg-info/dependency_links.txt +0 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/codegen_classroom.egg-info/top_level.txt +0 -0
- {codegen_classroom-0.1.0 → codegen_classroom-0.1.2}/setup.cfg +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codegen-classroom
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: A framework for iterative code generation
|
|
5
|
-
Author: Google LLC
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A framework for iterative code generation and recursive self-improvement (RSI) on ML and data analysis tasks using parallel LLM agents, optimized for local and Colab deployments.
|
|
5
|
+
Author: Google LLC, Jake Garrison
|
|
6
6
|
License:
|
|
7
7
|
Apache License
|
|
8
8
|
Version 2.0, January 2004
|
|
@@ -207,10 +207,18 @@ License:
|
|
|
207
207
|
limitations under the License.
|
|
208
208
|
|
|
209
209
|
Project-URL: Homepage, https://github.com/google-research/codegen-classroom
|
|
210
|
-
|
|
210
|
+
Project-URL: Repository, https://github.com/google-research/codegen-classroom
|
|
211
|
+
Project-URL: Issues, https://github.com/google-research/codegen-classroom/issues
|
|
212
|
+
Keywords: machine-learning,automated-research,autoresearch,self-improvement,recursive-self-improvement,rsi,code-generation,llm-agents,multi-agent,automl,gemini,gemma
|
|
213
|
+
Classifier: Development Status :: 4 - Beta
|
|
214
|
+
Classifier: Intended Audience :: Developers
|
|
215
|
+
Classifier: Intended Audience :: Science/Research
|
|
211
216
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
212
217
|
Classifier: Operating System :: OS Independent
|
|
218
|
+
Classifier: Programming Language :: Python :: 3
|
|
213
219
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
220
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
221
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
214
222
|
Requires-Python: >=3.9
|
|
215
223
|
Description-Content-Type: text/markdown
|
|
216
224
|
License-File: LICENSE
|
|
@@ -230,6 +238,7 @@ Requires-Dist: pyarrow
|
|
|
230
238
|
Provides-Extra: notebook
|
|
231
239
|
Requires-Dist: plotly; extra == "notebook"
|
|
232
240
|
Requires-Dist: ipython; extra == "notebook"
|
|
241
|
+
Requires-Dist: rich; extra == "notebook"
|
|
233
242
|
Provides-Extra: torch
|
|
234
243
|
Requires-Dist: torch; extra == "torch"
|
|
235
244
|
Requires-Dist: torchvision; extra == "torch"
|
|
@@ -237,137 +246,216 @@ Provides-Extra: jax
|
|
|
237
246
|
Requires-Dist: jax; extra == "jax"
|
|
238
247
|
Provides-Extra: lightgbm
|
|
239
248
|
Requires-Dist: lightgbm; extra == "lightgbm"
|
|
249
|
+
Provides-Extra: audio
|
|
250
|
+
Requires-Dist: librosa; extra == "audio"
|
|
251
|
+
Requires-Dist: resampy; extra == "audio"
|
|
240
252
|
Provides-Extra: dev
|
|
241
253
|
Requires-Dist: pytest; extra == "dev"
|
|
242
254
|
Requires-Dist: pytest-mock; extra == "dev"
|
|
243
255
|
Provides-Extra: all
|
|
244
256
|
Requires-Dist: plotly; extra == "all"
|
|
245
257
|
Requires-Dist: ipython; extra == "all"
|
|
258
|
+
Requires-Dist: rich; extra == "all"
|
|
246
259
|
Requires-Dist: torch; extra == "all"
|
|
247
260
|
Requires-Dist: torchvision; extra == "all"
|
|
248
261
|
Requires-Dist: jax; extra == "all"
|
|
249
262
|
Requires-Dist: lightgbm; extra == "all"
|
|
263
|
+
Requires-Dist: librosa; extra == "all"
|
|
264
|
+
Requires-Dist: resampy; extra == "all"
|
|
250
265
|
Requires-Dist: pytest; extra == "all"
|
|
251
266
|
Requires-Dist: pytest-mock; extra == "all"
|
|
252
267
|
Dynamic: license-file
|
|
253
268
|
|
|
254
269
|
# Codegen Classroom 🎓
|
|
255
270
|
|
|
256
|
-
### A framework for iterative code generation for ML and data analysis tasks
|
|
271
|
+
### A framework for iterative code generation for ML and data analysis tasks using parallel LLM agents.
|
|
272
|
+
|
|
273
|
+
[](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/template/task_example.ipynb)
|
|
274
|
+
[](https://www.python.org/downloads/)
|
|
275
|
+
[](https://ai.google.dev/gemini-api/docs)
|
|
276
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
277
|
+
[](https://github.com/google-research/codegen-classroom/stargazers)
|
|
257
278
|
|
|
258
|
-
|
|
279
|
+
**Authors:** [Jake Garrison](https://github.com/jake-g),
|
|
280
|
+
[Zhihan Zhang](https://github.com/iamZhihanZhang),
|
|
281
|
+
[Deon Kouatchou](https://github.com/dkouatch),
|
|
282
|
+
[Girish Narayanswamy](https://github.com/girishvn)
|
|
259
283
|
|
|
260
|
-
**
|
|
284
|
+
**Created:** August 2025
|
|
261
285
|
|
|
262
286
|
--------------------------------------------------------------------------------
|
|
263
287
|
|
|
264
288
|
## Overview
|
|
265
289
|
|
|
266
290
|
Codegen Classroom **automates code generation** for tasks that can be scored
|
|
267
|
-
(e.g., regression, classification, signal processing) using
|
|
268
|
-
[Gemini](https://ai.google.dev/gemini-api/docs/models)
|
|
269
|
-
|
|
270
|
-
a language model iteratively. It is best suited for tasks where solution quality
|
|
271
|
-
can be **scored numerically**. Agents **iteratively write, test, and refine**
|
|
272
|
-
solutions in a learning loop where code is **executed and scored** against
|
|
273
|
-
quantitative metrics.
|
|
291
|
+
quantitatively (e.g., regression, classification, signal processing) using
|
|
292
|
+
**parallel [Gemini](https://ai.google.dev/gemini-api/docs/models) and
|
|
293
|
+
[Gemma](https://ai.google.dev/gemma) agents**.
|
|
274
294
|
|
|
275
|
-
|
|
276
|
-
|
|
295
|
+
Instead of single-shot prompting, multiple student agents **iteratively write,
|
|
296
|
+
execute, debug, and refine** Python solutions in a sandboxed **recursive
|
|
297
|
+
self-improvement (RSI)** loop. Agents learn from execution feedback (validation
|
|
298
|
+
scores, runtime errors, diagnostic metrics) and **collaborate via peer
|
|
299
|
+
crossover** to share high-performing ideas and escape local optima.
|
|
277
300
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
301
|
+
Whether you define the data splits and scoring metrics directly or prompt an
|
|
302
|
+
agent to set up the task, the classroom handles implementation and iterative
|
|
303
|
+
optimization.
|
|
281
304
|
|
|
282
305
|
--------------------------------------------------------------------------------
|
|
283
306
|
|
|
284
|
-
##
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
*
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
307
|
+
## Classroom Learning Method
|
|
308
|
+
|
|
309
|
+
Each cycle evolves parallel **Student Agents** across four stages:
|
|
310
|
+
|
|
311
|
+
1. **Generate, Self-Debug, and Execute**: Each student writes a Python
|
|
312
|
+
`solution(x_train, y_train, x_val)` function executed in a timed sandbox,
|
|
313
|
+
automatically repairing runtime or output contract errors before returning
|
|
314
|
+
predictions and diagnostic `feedback` (e.g., CV scores or feature
|
|
315
|
+
importances).
|
|
316
|
+
2. **Multi-Objective Scoring**: Predictions are evaluated against weighted task
|
|
317
|
+
metrics (e.g., R², MAPE, Macro-F1) and execution time, updating each
|
|
318
|
+
student's `best_score` and `best_solution`.
|
|
319
|
+
3. **Guided Refinement and Peer Crossover**: Students refine their code using
|
|
320
|
+
domain prompts and self-logged `feedback`. After `early_stopping_patience`
|
|
321
|
+
stagnant cycles, a student applies a **Mutation Strategy** (retiring after
|
|
322
|
+
`max_mutation_count` mutations):
|
|
323
|
+
* `SELF_BEST_CODE`: Re-anchors on the student's own best solution.
|
|
324
|
+
* `BEST_PEER_CROSSOVER` / `BEST_PEER_REPLACEMENT`: Adopts feature
|
|
325
|
+
engineering and modeling ideas from top-scoring peers.
|
|
326
|
+
* `CONTRASTIVE_PEER_CROSSOVER`: Contrasts top peer solutions against
|
|
327
|
+
weaker attempts to combine winning patterns and avoid failure modes.
|
|
328
|
+
4. **Final Evaluation and Analysis**: Each student's `first`, `last`, and
|
|
329
|
+
`best` validation solutions are retrained on the full learning split and
|
|
330
|
+
evaluated once on the held-out test set, while `SolutionAnalysisAgent`
|
|
331
|
+
synthesizes results into `report.md` and `leaderboard.tsv`.
|
|
332
|
+
|
|
333
|
+

|
|
334
|
+
|
|
335
|
+
*Four student agents over four cycles (illustrative scores): each student
|
|
336
|
+
writes, runs, and scores its own solution, refines from its own feedback, and
|
|
337
|
+
borrows ideas from the top peer when it stalls.*
|
|
309
338
|
|
|
310
|
-
|
|
311
|
-
.venv\Scripts\activate
|
|
312
|
-
```
|
|
339
|
+
--------------------------------------------------------------------------------
|
|
313
340
|
|
|
314
|
-
|
|
341
|
+
## Tasks
|
|
342
|
+
|
|
343
|
+
Self-contained benchmark suites live under
|
|
344
|
+
[`codegen_classroom/tasks/<task>/`](./codegen_classroom/tasks/). Each task
|
|
345
|
+
includes a shared configuration (`config.py`), dataset loader
|
|
346
|
+
(`data_loader.py`), headless runner (`run_<task>.py`), unit tests
|
|
347
|
+
(`run_<task>_test.py`), companion notebook (`<task>.ipynb`), `leaderboard.tsv`,
|
|
348
|
+
and archived top solutions (`solutions/`). To add a new task, copy
|
|
349
|
+
[`tasks/template/`](./codegen_classroom/tasks/template/) or prompt a coding
|
|
350
|
+
agent with [`tasks/AGENTS.md`](./codegen_classroom/tasks/AGENTS.md).
|
|
351
|
+
|
|
352
|
+
| Task | Summary | Notebook |
|
|
353
|
+
| :--- | :--- | :---: |
|
|
354
|
+
| [`template`](./codegen_classroom/tasks/template/) *(Thermal Load Prediction)* | Synthetic multi-regime thermal load regression template (`N = 1,500`, 10 features) scored on R², MAE, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/template/task_example.ipynb) |
|
|
355
|
+
| [`housing`](./codegen_classroom/tasks/housing/) *(California Housing Prices)* | California housing price tabular regression (`N = 20,433`, 12 features) scored on R², MAPE, Pearson, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/housing/housing.ipynb) |
|
|
356
|
+
| [`wearable`](./codegen_classroom/tasks/wearable/) *(Physical Activity Recognition)* | Multi-class physiological activity classification from Apple Watch and Fitbit sensors (`N = 6,264`, 17 features, 6 classes) scored on Macro-F1, Accuracy, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/wearable/wearable.ipynb) |
|
|
357
|
+
| [`fashion_mnist`](./codegen_classroom/tasks/fashion_mnist/) *(Clothing Image Classification)* | 10-class garment image classification (`N = 70,000`, 28x28 grayscale images) scored on Accuracy, Macro-F1, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/fashion_mnist/fashion_mnist.ipynb) |
|
|
358
|
+
| [`esc50`](./codegen_classroom/tasks/esc50/) *(Environmental Sound Classification)* | 50-class environmental audio classification (`N = 2,000`, 5-second clips) across `fm` embedding probe and `efficient` compact CNN variants. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/esc50/esc50.ipynb) |
|
|
359
|
+
|
|
360
|
+

|
|
361
|
+
|
|
362
|
+
*Method families used by the winning solution of each of the 18 cohort runs on
|
|
363
|
+
the five tasks above: counts stacked by task (left) and the share of each
|
|
364
|
+
task's runs using each family (right). Calibration / reweighting (`14/18`),
|
|
365
|
+
neural networks (`13/18`), domain / spectral feature engineering (`12/18`), and
|
|
366
|
+
cross-validation / out-of-fold training (`9/18`) appear most often.*
|
|
315
367
|
|
|
316
|
-
|
|
317
|
-
# Standard installation (core library - matplotlib included)
|
|
318
|
-
pip install -e .
|
|
368
|
+
--------------------------------------------------------------------------------
|
|
319
369
|
|
|
320
|
-
|
|
321
|
-
pip install -e ".[notebook]" # or pip install codegen_classroom[notebook]
|
|
370
|
+
## Installation
|
|
322
371
|
|
|
323
|
-
|
|
324
|
-
pip install -e ".[lightgbm]"
|
|
372
|
+
Requires Python 3.9+ and a [`GEMINI_API_KEY`](https://ai.google.dev/gemini-api/docs/api-key):
|
|
325
373
|
|
|
326
|
-
|
|
327
|
-
|
|
374
|
+
```bash
|
|
375
|
+
# 1. Create and activate a virtual environment
|
|
376
|
+
python3 -m venv .venv
|
|
377
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
378
|
+
|
|
379
|
+
# 2. Install from PyPI
|
|
380
|
+
pip install codegen-classroom
|
|
381
|
+
# Or latest from GitHub: pip install "codegen-classroom @ git+https://github.com/google-research/codegen-classroom.git"
|
|
382
|
+
|
|
383
|
+
# Optional extras:
|
|
384
|
+
pip install "codegen-classroom[lightgbm]" # LightGBM
|
|
385
|
+
pip install "codegen-classroom[notebook]" # Plotly and IPython for notebooks
|
|
386
|
+
pip install "codegen-classroom[torch]" # PyTorch and TorchVision
|
|
387
|
+
pip install "codegen-classroom[jax]" # JAX
|
|
388
|
+
pip install "codegen-classroom[audio]" # Audio processing (librosa, resampy)
|
|
389
|
+
pip install "codegen-classroom[all]" # All optional dependencies and pytest
|
|
390
|
+
|
|
391
|
+
# 3. Configure GEMINI_API_KEY
|
|
392
|
+
export GEMINI_API_KEY="your-api-key" # Or copy .env.example to .env
|
|
393
|
+
```
|
|
328
394
|
|
|
329
|
-
|
|
330
|
-
|
|
395
|
+
For Gemini Developer API key clients, the library defaults to API version
|
|
396
|
+
`v1beta` (to support preview models alongside stable models). Set
|
|
397
|
+
`GOOGLE_GENAI_API_VERSION` to override this default (for example `v1`); it is
|
|
398
|
+
left unset automatically when Vertex AI mode is selected via
|
|
399
|
+
`GOOGLE_GENAI_USE_VERTEXAI` or `GOOGLE_GENAI_USE_ENTERPRISE`.
|
|
331
400
|
|
|
332
|
-
|
|
333
|
-
pip install -e ".[all]"
|
|
334
|
-
```
|
|
401
|
+
--------------------------------------------------------------------------------
|
|
335
402
|
|
|
336
|
-
|
|
337
|
-
in the `[notebook]` extra (`pip install codegen_classroom[notebook]`).
|
|
338
|
-
`lightgbm` is the approved gradient boosting framework; `xgboost` is not
|
|
339
|
-
supported.
|
|
403
|
+
## Library Structure
|
|
340
404
|
|
|
341
|
-
|
|
342
|
-
|
|
405
|
+
* [agent_config.py](./codegen_classroom/agent_config.py): Default model
|
|
406
|
+
configurations, generation parameters, pricing, environment resolution, and
|
|
407
|
+
execution timeouts.
|
|
408
|
+
* [agents.py](./codegen_classroom/agents.py): `StudentAgent` and
|
|
409
|
+
`SolutionAnalysisAgent` state management, token/cost tracking, refinement
|
|
410
|
+
prompts, and peer mutation strategies.
|
|
411
|
+
* [code_execution.py](./codegen_classroom/code_execution.py): Python code
|
|
412
|
+
extraction and timed subprocess execution capturing `stdout`, `stderr`, and
|
|
413
|
+
return values.
|
|
414
|
+
* [data_utils.py](./codegen_classroom/data_utils.py): Data loading, file
|
|
415
|
+
operations (`etils.epath`), run ID generation, and `leaderboard.tsv`
|
|
416
|
+
tracking.
|
|
417
|
+
* [metrics.py](./codegen_classroom/metrics.py): Performance metrics (MAE, R²,
|
|
418
|
+
Pearson, Macro-F1, Worst-Group Accuracy) and score normalization.
|
|
419
|
+
* [plotting.py](./codegen_classroom/plotting.py): Progress and final
|
|
420
|
+
evaluation plots via Matplotlib (headless PNG export) or Plotly (notebooks).
|
|
421
|
+
* [reporting.py](./codegen_classroom/reporting.py): Structured logging,
|
|
422
|
+
Markdown table formatting, and report export (`report.md`).
|
|
423
|
+
* [scoring.py](./codegen_classroom/scoring.py): Prediction validation (shape,
|
|
424
|
+
index, NaN checks) and weighted composite scoring.
|
|
425
|
+
* [student_learning.py](./codegen_classroom/student_learning.py): Parallel
|
|
426
|
+
classroom cycle orchestration and final test evaluation across `first`,
|
|
427
|
+
`last`, and `best` strategies.
|
|
428
|
+
* [verify_task.py](./codegen_classroom/verify_task.py): Automated structural,
|
|
429
|
+
notebook, solution report, and prompt hygiene verifier.
|
|
430
|
+
* [tasks/](./codegen_classroom/tasks/): Benchmark task suites,
|
|
431
|
+
[Task Authoring Guide](./codegen_classroom/tasks/AGENTS.md), and
|
|
432
|
+
[canonical template](./codegen_classroom/tasks/template/).
|
|
343
433
|
|
|
344
|
-
|
|
345
|
-
cp .env.example .env
|
|
346
|
-
```
|
|
434
|
+
--------------------------------------------------------------------------------
|
|
347
435
|
|
|
348
|
-
|
|
436
|
+
## Quickstart
|
|
349
437
|
|
|
350
|
-
|
|
351
|
-
pytest
|
|
352
|
-
```
|
|
438
|
+
### Run a Built-In Benchmark Task
|
|
353
439
|
|
|
354
|
-
|
|
440
|
+
```bash
|
|
441
|
+
# Run a benchmark task headlessly (evaluates held-out test split, writes report.md,
|
|
442
|
+
# appends to leaderboard.tsv, and exports top runs to solutions/):
|
|
443
|
+
python -m codegen_classroom.tasks.template.run_template
|
|
355
444
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
python -m ipykernel install --user --name=codegen-classroom --display-name "Python (Codegen Classroom)"
|
|
359
|
-
```
|
|
445
|
+
# Rebuild report.md for an existing run without re-executing student code:
|
|
446
|
+
python -m codegen_classroom.tasks.template.run_template --report_only=latest
|
|
360
447
|
|
|
361
|
-
|
|
448
|
+
# Verify a single task or all tasks:
|
|
449
|
+
python -m codegen_classroom.verify_task --task template --strict
|
|
450
|
+
python -m codegen_classroom.verify_task --all
|
|
451
|
+
```
|
|
362
452
|
|
|
363
|
-
|
|
453
|
+
### Run on a Custom Dataset in Python
|
|
364
454
|
|
|
365
|
-
|
|
366
|
-
customized for any scorable machine learning or data science task.
|
|
455
|
+
Run an iterative classroom loop on any custom `pandas` dataset:
|
|
367
456
|
|
|
368
457
|
```python
|
|
369
458
|
import os
|
|
370
|
-
from codegen_classroom import agent_config
|
|
371
459
|
from codegen_classroom import agents
|
|
372
460
|
from codegen_classroom import student_learning
|
|
373
461
|
import pandas as pd
|
|
@@ -383,7 +471,7 @@ y_test = pd.DataFrame({"target": [14.0]})
|
|
|
383
471
|
# 2. Configure student agents
|
|
384
472
|
student_configs = student_learning.get_classroom_student_configs(
|
|
385
473
|
system_instruction="You are an expert ML engineer.",
|
|
386
|
-
model_names=["gemini-
|
|
474
|
+
model_names=["gemini-3.8-flash"],
|
|
387
475
|
api_key=os.environ.get("GEMINI_API_KEY"),
|
|
388
476
|
)
|
|
389
477
|
classroom = [agents.StudentAgent(cfg) for cfg in student_configs]
|
|
@@ -394,7 +482,7 @@ Write a python function `solution(x_train, y_train, x_val)` that trains a regres
|
|
|
394
482
|
model on (x_train, y_train) and returns predictions on x_val as a pandas DataFrame with column 'target'.
|
|
395
483
|
"""
|
|
396
484
|
for cycle in range(3):
|
|
397
|
-
|
|
485
|
+
student_learning.run_parallel_classroom_learning_cycle(
|
|
398
486
|
current_classroom=classroom,
|
|
399
487
|
x_train=x_train,
|
|
400
488
|
y_train=y_train,
|
|
@@ -426,76 +514,10 @@ print("Final evaluation completed:", eval_results)
|
|
|
426
514
|
|
|
427
515
|
--------------------------------------------------------------------------------
|
|
428
516
|
|
|
429
|
-
## Library Structure
|
|
430
|
-
|
|
431
|
-
The core library is organized into the following modules:
|
|
432
|
-
|
|
433
|
-
* [agent_config.py](./codegen_classroom/agent_config.py): Global configuration
|
|
434
|
-
defaults for models, generation parameters, and execution timeouts.
|
|
435
|
-
* [agents.py](./codegen_classroom/agents.py): Defines the `StudentAgent`,
|
|
436
|
-
including **state management** (`best_score`, `best_solution`), **refinement
|
|
437
|
-
logic**, and **mutation strategies** (self-reflection, peer crossover).
|
|
438
|
-
* [code_execution.py](./codegen_classroom/code_execution.py): Handles
|
|
439
|
-
**extraction of Python code** blocks from LLM responses and **executes the
|
|
440
|
-
code** in a sandboxed environment, capturing `stdout`, `stderr`, and
|
|
441
|
-
results.
|
|
442
|
-
* [data_utils.py](./codegen_classroom/data_utils.py): Helpers for **data
|
|
443
|
-
loading**, generic file operations via `etils.epath`, **run ID generation**,
|
|
444
|
-
and local leaderboard tracking.
|
|
445
|
-
* [metrics.py](./codegen_classroom/metrics.py): Contains definitions for
|
|
446
|
-
individual **performance metrics** (e.g., MAE, R², Pearson, Worst-Group
|
|
447
|
-
Accuracy), including computation and **normalization logic**.
|
|
448
|
-
* [plotting.py](./codegen_classroom/plotting.py): Progress and final
|
|
449
|
-
evaluation charts using Matplotlib (headless image export) or Plotly
|
|
450
|
-
(interactive notebooks).
|
|
451
|
-
* [reporting.py](./codegen_classroom/reporting.py): Centralized logging setup,
|
|
452
|
-
markdown table rendering with configurable decimal precision,
|
|
453
|
-
`ReportSection` structured models, and dual sinks: interactive inline
|
|
454
|
-
display and disk export (`report.md`).
|
|
455
|
-
* [scoring.py](./codegen_classroom/scoring.py): Implements **solution
|
|
456
|
-
validation** (e.g., checking prediction shapes, NaNs) and calculates the
|
|
457
|
-
overall **weighted score** based on metrics.
|
|
458
|
-
* [student_learning.py](./codegen_classroom/student_learning.py):
|
|
459
|
-
**Orchestrates** the entire agent learning process. Contains the main
|
|
460
|
-
`run_learning_cycle` function and helpers to **run agents in parallel** and
|
|
461
|
-
perform final evaluations across strategies (`first`, `last`, `best`).
|
|
462
|
-
* [tasks/](./codegen_classroom/tasks/): Domain-specific benchmark suites and
|
|
463
|
-
reference scaffolding. See the
|
|
464
|
-
[Task Authoring Guide](./codegen_classroom/tasks/AGENTS.md) and the
|
|
465
|
-
[canonical template task](./codegen_classroom/tasks/template/).
|
|
466
|
-
|
|
467
|
-
--------------------------------------------------------------------------------
|
|
468
|
-
|
|
469
|
-
## Benchmark Tasks
|
|
470
|
-
|
|
471
|
-
Each benchmark task under
|
|
472
|
-
[`codegen_classroom/tasks/<task>/`](./codegen_classroom/tasks/) is a
|
|
473
|
-
self-contained package providing a shared configuration and prompt module
|
|
474
|
-
(`config.py`), a dataset loader (`data_loader.py`), a headless runner
|
|
475
|
-
(`run_<task>.py`), unit tests (`run_<task>_test.py`), a companion notebook
|
|
476
|
-
(`<task>.ipynb`), a `leaderboard.tsv`, and archived top solutions
|
|
477
|
-
(`solutions/`).
|
|
478
|
-
|
|
479
|
-
```bash
|
|
480
|
-
# Run a benchmark task headlessly:
|
|
481
|
-
python -m codegen_classroom.tasks.template.run_template
|
|
482
|
-
|
|
483
|
-
# Verify a single task or all tasks before contributing:
|
|
484
|
-
python -m codegen_classroom.verify_task --task template --strict
|
|
485
|
-
python -m codegen_classroom.verify_task --all
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
To create a new benchmark task, copy
|
|
489
|
-
[`tasks/template/`](./codegen_classroom/tasks/template/) and follow
|
|
490
|
-
[`tasks/AGENTS.md`](./codegen_classroom/tasks/AGENTS.md).
|
|
491
|
-
|
|
492
|
-
--------------------------------------------------------------------------------
|
|
493
|
-
|
|
494
517
|
## Disclaimer
|
|
495
518
|
|
|
496
519
|
**This is not an officially supported Google product.**
|
|
497
520
|
|
|
498
521
|
The agents powered by Gemini are experimental and may generate inaccurate,
|
|
499
522
|
hallucinated, or unoptimized code. Always execute the agent loop inside a
|
|
500
|
-
sandboxed environment
|
|
501
|
-
from code execution.
|
|
523
|
+
sandboxed environment to prevent unexpected side effects from code execution.
|