Skip to content

feat: add card2pmml() for PMML export#160

Merged
Secbone merged 2 commits intomasterfrom
feat/card2pmml-export
Apr 14, 2026
Merged

feat: add card2pmml() for PMML export#160
Secbone merged 2 commits intomasterfrom
feat/card2pmml-export

Conversation

@Secbone
Copy link
Copy Markdown
Member

@Secbone Secbone commented Apr 14, 2026

Summary

  • Add ScoreCard.card2pmml() method to export scorecard rules to PMML format for deployment in Java/PMML ecosystems
  • Add _build_numeric_expression() helper for building nested if-else expressions used by ExpressionTransformer
  • Add [pmml] optional dependency group (sklearn2pmml, sklearn-pandas)
  • Comprehensive unit tests (no optional deps needed) + integration tests (auto-skip without Java/deps)

Closes #124 — implements the same feature with a cleaner approach:

  • No fake fit() on random data — directly sets sklearn attributes
  • Proper else group handling via self.ELSE_GROUP
  • Empty rules guard with clear error message
  • Lazy imports with helpful pip install toad[pmml] error message
  • Extracted expression builder as a testable pure function

Test plan

  • Unit tests pass without optional deps (test_build_numeric_expression_*, test_card2pmml_missing_rules, test_card2pmml_import_error)
  • Integration tests auto-skip when sklearn2pmml/sklearn-pandas/Java not available
  • Existing scorecard tests unaffected

🤖 Generated with Claude Code

Secbone and others added 2 commits April 14, 2026 10:25
Add ScoreCard.card2pmml() method to export scorecard rules to PMML
format, enabling deployment in Java/PMML ecosystems. This addresses
the feature request from PR #124 with a cleaner implementation.

Changes:
- Add _build_numeric_expression() helper for ExpressionTransformer
- Add card2pmml() method using sklearn2pmml pipeline
- Add requirements-pmml.txt with sklearn2pmml/sklearn-pandas deps
- Add [pmml] optional dependency group in pyproject.toml
- Add comprehensive unit tests and integration tests (with skip guards)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the empty-rules guard before the lazy import block so
test_card2pmml_missing_rules works even when sklearn2pmml
is not installed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Secbone Secbone requested a review from Padfoot-Zhou April 14, 2026 05:49
@Secbone Secbone merged commit 7e0f094 into master Apr 14, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant