[BUG] fix sklearn feature names warning in `TimeSeriesDataSet.__getitem__` #2545
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.47) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 352 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.351
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #2545"
general
weight: 0.35
phoeenniixx
LLM generated content, by Claude Opus 5.5
Reference Issues/PRs
Fixes #1303.
What does this implement/fix? Explain your changes.
With
add_target_scales=True(and withconstant_fill_strategyorset_overwrite_valueson a scaled real), every__getitem__call emittedUserWarning: X does not have valid feature names, but StandardScaler was fitted with feature names. That's two warnings per sample, so a short training run prints dozens of them.The default
StandardScalers were fitted on a DataFrame (data[[name]]), buttransform_valuespasses them a bare array for array/tensor input, such as theEncoderNormalizercenter and scale in__getitem__.Changes:
StandardScalerfor each real is now fitted ondata[[name]].to_numpy().transform_valuesgives a scaler the same kind of input it was fitted on:- a Series is converted to an array if the scaler was fitted without feature names;
- an array is wrapped in a DataFrame with
feature_names_in_if the scaler was fitted with them (user-supplied scalers, or datasets pickled before this change).__getitem__, the transformed center and scale are converted withfloat(...)before they are assigned into the tensor, so a float32 result from the DataFrame path can also be assigned.For the default scalers, the samples are bit-identical to
main.__getitem__is also slightly faster, since the warnings are no longer raised (0.62 s vs 0.78 s for 1000 samples in a small example).What should a reviewer concentrate their feedback on?
dataset.get_transformer(name).feature_names_in_no longer exists for these scalers. Calling.transformon them directly with a DataFrame now warns the other way round. Inside the library, all transforms go throughtransform_values.data[[name]]as before, so custom transformers that need a DataFrame keep working.Did you add any tests for the change?
Yes,
test_no_feature_names_warning_with_encoder_normalizer_target_scalesintests/test_data/test_timeseries.py:EncoderNormalizerwithadd_target_scales=True,constant_fill_strategyandset_overwrite_values;StandardScalerand one prefitted on a DataFrame;x_conthas the expected value.All 3 cases fail on
mainand pass with this change.tests/test_datapasses (185), and so do the TFT, DeepAR, N-BEATS and RNN model tests.PR checklist