Skip to content

Fix warnings emitted by the application scorecard full suite - #561

Merged
cachafla merged 2 commits into
mainfrom
andres/fix-scorecard-notebook-warnings
Sep 3, 2026
Merged

cachafla merged 2 commits into
mainfrom
andres/fix-scorecard-notebook-warnings

Conversation

@cachafla

@cachafla cachafla commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request Description

What and why?

Running application_scorecard_full_suite.ipynb on validmind 2.13.12 prints roughly 600 warning lines. This removes all of them except one template mismatch (see below).

Warning Count Fix
scorecardpy FutureWarning / UserWarning (pandas deprecations inside woebin, woebin_ply, condition_fun) ~480 lending_club: warnings.catch_warnings() around the two scorecardpy calls. Third-party code, unmaintained upstream.
TypeError: custom_recall() got an unexpected keyword argument 'needs_proba' plus sklearn "Scoring failed" / "non-finite test scores" ~85 HyperParametersTuning: make_scorer(..., response_method="predict_proba"). needs_proba was removed in scikit-learn 1.6, so the recall scorer had been silently failing. response_method exists from 1.4, so pyproject.toml now requires scikit-learn>=1.4 (base) and >=1.4,<1.8 (extras).
SettingWithCopyWarning in WeakspotsDiagnosis 12 .copy() the column slices before assigning the bin column.
FutureWarning: The default of observed=False is deprecated in ScoreProbabilityAlignment 1 groupby(..., observed=True). Bins come from qcut, so no empty categories are dropped.
Failed to generate description for HyperParametersTuning: Object of type DataFrame is not JSON serializable 1 generate_description: round-trip params through NumpyEncoder before the request. The demo config passes fit_params={"eval_set": [(x_test, y_test)]}.

Not addressed: Config key 'validmind.model_validation.ModelMetadata' does not match a test_id in the template. The demo config is shared by several notebooks and that test exists in other templates; the model's documentation template on the platform decides this.

How to test

  • uv run python -m unittest tests.test_test_descriptions tests.unit_tests.model_validation.sklearn.test_WeakspotsDiagnosis — includes the new test_generate_description_params_are_json_serializable.
  • _create_scoring_dict(["roc_auc", "recall"], ..., 0.3) fed to GridSearchCV on scikit-learn 1.7.2 returns finite recall and roc_auc scores.
  • lending_club.feature_engineering on a 5k-row sample of the offline dataset emits zero scorecardpy warnings in the parent process.
  • Rerun the notebook on JupyterHub and compare the output against the previous run.

What needs special review?

  • The scikit-learn floor. >=1.4 matches the library's Python 3.9 minimum; the lock refresh only changed the three specifier lines.
  • scorecardpy bins in a multiprocessing pool. On Linux the workers fork and inherit the suppression; on macOS they spawn fresh and a few warnings can still leak from workers.

Dependencies, breaking changes, and deployment notes

Adds a lower bound scikit-learn>=1.4 (January 2024). Environments on older scikit-learn will now fail at install time rather than with a TypeError in HyperParametersTuning.

Release notes

  • Fixed HyperParametersTuning recall scoring on scikit-learn 1.6 and later; recall scores were reported as non-finite.
  • Fixed AI description generation for tests whose params contain DataFrames, such as HyperParametersTuning with fit_params.
  • Removed pandas and scikit-learn deprecation warnings from WeakspotsDiagnosis, ScoreProbabilityAlignment and the lending_club demo dataset.
  • The library now requires scikit-learn 1.4 or newer.

Checklist

  • What and why
  • Screenshots or videos (Frontend)
  • How to test
  • What needs special review
  • Dependencies, breaking changes, and deployment notes
  • Labels applied
  • PR linked to Shortcut
  • Unit tests added (Backend)
  • Tested locally
  • Documentation updated (if required)
  • Environment variable additions/changes documented (if required)

🤖 Generated with Claude Code

- HyperParametersTuning: make_scorer(needs_proba=...) was removed in
  scikit-learn 1.6, so every recall scorer failed and GridSearchCV reported
  non-finite scores. Use response_method="predict_proba".
- Test descriptions: round-trip params through NumpyEncoder so params holding
  DataFrames (fit_params eval_set) no longer fail JSON serialization, which
  fell back to the default description.
- WeakspotsDiagnosis: copy the column slices before adding the bin column
  (SettingWithCopyWarning).
- ScoreProbabilityAlignment: pass observed=True to groupby (pandas
  FutureWarning).
- lending_club: silence scorecardpy's pandas FutureWarnings at its two call
  sites; they are third-party and hundreds of lines long in the notebook.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Pull requests must include at least one of the required labels: internal, highlight, enhancement, bug, deprecation, documentation. Except for internal, pull requests must also include a description in the release notes section.

@cachafla cachafla added the bug Something isn't working label Sep 3, 2026
make_scorer(response_method=...) exists from scikit-learn 1.4, the release
that deprecated needs_proba. Make the floor explicit so an older environment
fails at install time rather than with a TypeError at test time.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Pull requests must include a description in the release notes section.

2 similar comments
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Pull requests must include a description in the release notes section.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Pull requests must include a description in the release notes section.

@cachafla
cachafla requested a review from juanmleng September 3, 2026 19:13
@cachafla cachafla added the dependencies Pull requests that update a dependency file label Sep 3, 2026
@cachafla
cachafla requested a review from hannes-vm September 3, 2026 20:40

@gtagle gtagle left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

@cachafla
cachafla merged commit 6e79e65 into main Sep 3, 2026
28 of 30 checks passed
@cachafla
cachafla deleted the andres/fix-scorecard-notebook-warnings branch September 3, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants