Commit f8a3fc7
Train a cross-validated run through the units, unless it is nested
FitModelOverFoldsUnit is FitModelUnit's sibling: it takes a list of partition
sets instead of one, which is a different REQUIRES and so a different unit.
Everything around the fit is the shared mixin; what is written here is the
objective the search measures -- the whole fold loop, so one trial costs k fits
-- and what happens once the search is over.
ModelJob composes it for a fold run that is not nested. Nested cross-validation
still trains through the strategy: its inner splitter is a required component
field, and a component field cannot be made optional without leaving the user
without a selector, so it is a further sibling rather than a flag on this one.
Three decisions worth naming.
The per-fold scores are published rather than aggregated in the unit. A summary
row carries a standard deviation, and a unit may not write domain rows -- the
one sanctioned write in the domain layer has nowhere to put one. So the unit
hands the numbers over and the job does the arithmetic and the writing, where
every other row it persists is written. A single fold gets a deviation of zero
rather than none, because none is what the reserved-rows measurement carries
and the two say different things.
A trial records one row per split holding the mean over its folds, not one per
fold: the folds of a trial measure a hyperparameter setting rather than the
model that gets kept, and recording each would bury the rows that describe it.
That write is guarded on the run, which _save_metrics does not guard for
itself -- a caller with no run would write rows against a foreign key pointing
at nothing, and they insert without complaint because nothing enforces it.
Scoring the reserved rows is not the unit's. It is an ordinary LAST metric, so
it is EvaluateModelUnit, the same one a holdout run uses, and whether there is
anything to score is the caller's to know: a session that reserved nothing
leaves that partition empty rather than absent.
calculate_metrics now returns what it wrote, so a caller that wants both the
row and the number scores the split once instead of twice.
The assertion that the optimizer gave back the model it was handed caught a
real gap while this was written: with the data attached at fit time rather than
at build time, nothing had pointed the model at anything during a fold search.
It does now, per fold, the same as the scoring loop.
1001 passed across units, dag, spike, api and evaluation; both nets unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 9c6ac25 commit f8a3fc7
5 files changed
Lines changed: 399 additions & 6 deletions
File tree
- DashAI/back
- job
- models
- units
- tests/back/api
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
| 527 | + | |
527 | 528 | | |
528 | 529 | | |
529 | 530 | | |
| |||
732 | 733 | | |
733 | 734 | | |
734 | 735 | | |
| 736 | + | |
735 | 737 | | |
736 | 738 | | |
737 | 739 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
9 | 15 | | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| 22 | + | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
| |||
224 | 231 | | |
225 | 232 | | |
226 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
227 | 270 | | |
228 | | - | |
229 | | - | |
230 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
231 | 275 | | |
232 | 276 | | |
233 | 277 | | |
| |||
295 | 339 | | |
296 | 340 | | |
297 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
298 | 401 | | |
299 | 402 | | |
300 | 403 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
352 | 359 | | |
353 | 360 | | |
354 | 361 | | |
| |||
366 | 373 | | |
367 | 374 | | |
368 | 375 | | |
369 | | - | |
| 376 | + | |
370 | 377 | | |
371 | 378 | | |
372 | 379 | | |
373 | | - | |
| 380 | + | |
374 | 381 | | |
375 | 382 | | |
376 | 383 | | |
| |||
392 | 399 | | |
393 | 400 | | |
394 | 401 | | |
| 402 | + | |
| 403 | + | |
395 | 404 | | |
396 | 405 | | |
397 | 406 | | |
| |||
0 commit comments