diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2024-01-10 09:41:50 +0100 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2024-01-10 09:41:50 +0100 |
commit | 5adc39c8de1fbda6e1ba9abcaaaf17516eb046ae (patch) | |
tree | f52dbe13e5cf9fa70f38a8d0e8d75020856ce781 /lib | |
parent | 72fc17a4dcff42bedb21b456f7da63065a72fd9f (diff) |
--show-model=param: add CART support
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cli.py | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -94,6 +94,26 @@ def print_staticinfo(prefix, info): print(f"{prefix}: {info.value}") +def print_cartinfo(prefix, info, feature_names): + _print_cartinfo(prefix, info.to_json(feature_names=feature_names), feature_names) + + +def _print_cartinfo(prefix, model, feature_names): + if model["type"] == "static": + print(f"""{prefix}: {model["value"]}""") + else: + _print_cartinfo( + f"""{prefix} {model["paramName"]}<{model["paramDecisionValue"]} """, + model["left"], + feature_names, + ) + _print_cartinfo( + f"""{prefix} {model["paramName"]}≥{model["paramDecisionValue"]} """, + model["right"], + feature_names, + ) + + def print_splitinfo(param_names, info, prefix=""): if type(info) is SplitFunction: for k, v in info.child.items(): |