Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly retrieve votes distribution for float target trees #45

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions sklearn_pmml_model/tree/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,13 @@ def construct_tree(node, classes, field_mapping, i=0, rescale_factor=1):
i += 1

def votes_for(field):
distribution = node.find(f"ScoreDistribution[@value='{field}']")

# Deal with case where target field is a double, but ScoreDistribution value is an integer.
if isinstance(field, float) and field.is_integer():
return node.find(f"ScoreDistribution[@value='{field}']") or node.find(f"ScoreDistribution[@value='{int(field)}']")
if distribution is None and isinstance(field, float) and field.is_integer():
return node.find(f"ScoreDistribution[@value='{int(field)}']")

return node.find(f"ScoreDistribution[@value='{field}']")
return distribution

if not child_nodes:
record_count = node.get('recordCount')
Expand Down