Commit 401d96d
committed
Address gemini and Copilot review on PR #923
Fixes the medium-severity comments raised on the differentiable_input
regressor path:
1. Feature instances per column: replace
`[Feature(...)] * n_features` with a list comprehension so each
column has its own dataclass and a later in-place update on one
column does not leak across all columns.
2. y stats numerical robustness: switch `y_float.std()` (PyTorch's
default `correction=1`, which differs from `np.std` and returns
NaN for N=1) to `clamp(y_float.std(correction=0), min=1e-20)`.
This matches the standard `fit()` path's `np.std` semantics and
stays finite for single-sample input.
3. Constant-target guard: a constant y collapses the bardist borders
to a single point and trips
`FullSupportBarDistribution`'s strictly-increasing assertion.
`fit()` short-circuits this with `is_constant_target_`; the
differentiable path has no analogue, so reject up front with a
clear ValueError pointing users at `fit()`.
4. Sequential preprocessing for diff input: force
`n_preprocessing_jobs=1` inside `fit_with_differentiable_input`.
When X carries an autograd graph, joblib's process-boundary
pickling breaks the graph; sequential execution preserves it.
The detach-then-`.item()` of `y_train_mean_/std_` is intentional and
not changed: `raw_space_bardist_` is a frozen lookup buffer that
should not hold a y-grad graph; users wanting fully differentiable
target scaling should z-normalise y externally so mean/std become
constants here. Documented inline.
New tests:
- feature_schema_columns_are_independent: catches the alias bug.
- std_matches_population_definition: locks in `np.std` semantics.
- constant_target_rejected: locks in the explicit guard.
- single_sample_y_does_not_nan: confirms N=1 hits the guard cleanly
rather than producing NaN deep in the bardist.
All 9 differentiable_input tests pass on CPU and CUDA.1 parent 2b91390 commit 401d96d
2 files changed
Lines changed: 102 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
667 | 667 | | |
668 | 668 | | |
669 | 669 | | |
670 | | - | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
671 | 688 | | |
672 | 689 | | |
673 | 690 | | |
| |||
705 | 722 | | |
706 | 723 | | |
707 | 724 | | |
708 | | - | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
709 | 732 | | |
710 | 733 | | |
711 | 734 | | |
| |||
920 | 943 | | |
921 | 944 | | |
922 | 945 | | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
923 | 949 | | |
924 | 950 | | |
925 | 951 | | |
926 | 952 | | |
927 | 953 | | |
928 | | - | |
| 954 | + | |
929 | 955 | | |
930 | 956 | | |
931 | 957 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1052 | 1052 | | |
1053 | 1053 | | |
1054 | 1054 | | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
1055 | 1128 | | |
1056 | 1129 | | |
1057 | 1130 | | |
| |||
0 commit comments