Commit 159db1b
authored
`RadialBasisFunctionRegressionTests.ScalingEquivariance_ScalingTargets_ScalesPredictions`
was flaky in CI: the test creates two model instances on the same X with
y scaled by k=100 and asserts pred2/pred1 ≈ k. Reported failure was
ratio = 49.66 (pred_original=8.7966, pred_scaled=436.7967 — model1's
prediction was ~2× model2's, so the ratio drifted below 100).
root cause: SelectCenters used new Random()-style seeding via
`_options.Seed.HasValue ? CreateSeededRandom : CreateSecureRandom()`,
so two RBF models built from the same X picked different starting
centers, ran k-means to different local minima, and produced different
weights. That broke the algebra: with a deterministic feature matrix Φ
the solve w = (ΦᵀΦ + λI)⁻¹ Φᵀy is linear in y, so pred2 = k·pred1
exactly. With random Φ, that linearity goes away.
fix: replace the random init + random empty-cluster fallback with a
purely deterministic k-means++ farthest-point seeding (centers[0]=x[0],
each next center = argmax of min-distance² to existing centers), and
make the empty-cluster fallback also a farthest-point pick. The whole
SelectCenters path is now a pure function of X, so two models trained
on the same X get identical Φ and identical-up-to-y-scale weights.
This also removes the hidden non-determinism that made debugging RBF
behavior frustrating in unrelated tests.
Closes #1407
1 parent 2ce0b30 commit 159db1b
1 file changed
Lines changed: 74 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
274 | 273 | | |
275 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
276 | 288 | | |
277 | | - | |
278 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
279 | 292 | | |
280 | | - | |
281 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
282 | 296 | | |
283 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
284 | 325 | | |
285 | 326 | | |
286 | 327 | | |
287 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
288 | 331 | | |
289 | 332 | | |
290 | 333 | | |
| |||
343 | 386 | | |
344 | 387 | | |
345 | 388 | | |
346 | | - | |
347 | | - | |
348 | | - | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
349 | 412 | | |
350 | 413 | | |
351 | 414 | | |
| |||
0 commit comments