← Back to Pull requests

[BUG] fix sklearn feature names warning in `TimeSeriesDataSet.__getitem__` #2545

Open
unknown opened this pull request with 352 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 25, 2026 16:02 UTC
Author

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 with constant_fill_strategy or set_overwrite_values on a scaled real), every __getitem__ call emitted UserWarning: 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]]), but transform_values passes them a bare array for array/tensor input, such as the EncoderNormalizer center and scale in __getitem__.

Changes:

  • The default StandardScaler for each real is now fitted on data[[name]].to_numpy().

  • transform_values gives 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).
  • In __getitem__, the transformed center and scale are converted with float(...) 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?


  • Fitting the default scaler on an array: dataset.get_transformer(name).feature_names_in_ no longer exists for these scalers. Calling .transform on them directly with a DataFrame now warns the other way round. Inside the library, all transforms go through transform_values.

  • User-supplied scalers are still fitted on 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_scales in tests/test_data/test_timeseries.py:
  • it uses EncoderNormalizer with add_target_scales=True, constant_fill_strategy and set_overwrite_values;

  • it is parametrized over the default scaler, an unfitted user StandardScaler and one prefitted on a DataFrame;

  • it checks that no feature-names warning is raised and that the scale feature in x_cont has the expected value.
  • All 3 cases fail on main and pass with this change. tests/test_data passes (185), and so do the TFT, DeepAR, N-BEATS and RNN model tests.

    PR checklist


  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG].

  • Added/modified tests

  • Used pre-commit hooks when committing to ensure that code is compliant with hooks.
  • Diff: 352 lines (+264 / -88) across 4 files Reviewer: phoeenniixx Review duration: 7232m
    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
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.5% (MEDIUM) · Higher = larger blast radius
    47.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.3% · Safe to merge
    25.3%