summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/analyze-archive.py4
-rwxr-xr-xbin/analyze-kconfig.py4
-rwxr-xr-xbin/analyze-log.py4
-rw-r--r--lib/cli.py35
4 files changed, 24 insertions, 23 deletions
diff --git a/bin/analyze-archive.py b/bin/analyze-archive.py
index bbf2efa..9cdf42c 100755
--- a/bin/analyze-archive.py
+++ b/bin/analyze-archive.py
@@ -791,8 +791,8 @@ if __name__ == "__main__":
]
)
- if args.show_model_size:
- dfatool.cli.print_model_size(model)
+ if args.show_model_complexity:
+ dfatool.cli.print_model_complexity(model)
if args.boxplot_param:
dfatool.cli.boxplot_param(args, model)
diff --git a/bin/analyze-kconfig.py b/bin/analyze-kconfig.py
index ebbb1a5..716cab4 100755
--- a/bin/analyze-kconfig.py
+++ b/bin/analyze-kconfig.py
@@ -530,8 +530,8 @@ def main():
error_metric=args.error_metric,
)
- if args.show_model_size:
- dfatool.cli.print_model_size(model)
+ if args.show_model_complexity:
+ dfatool.cli.print_model_complexity(model)
if args.export_webconf:
attributes = KConfigAttributes(args.kconfig_path, None)
diff --git a/bin/analyze-log.py b/bin/analyze-log.py
index 129e311..f3e819a 100755
--- a/bin/analyze-log.py
+++ b/bin/analyze-log.py
@@ -227,8 +227,8 @@ def main():
error_metric=args.error_metric,
)
- if args.show_model_size:
- dfatool.cli.print_model_size(model)
+ if args.show_model_complexity:
+ dfatool.cli.print_model_complexity(model)
if args.export_model:
print(f"Exportding model to {args.export_model}")
diff --git a/lib/cli.py b/lib/cli.py
index 86e9bc8..28e2004 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -150,23 +150,25 @@ def print_model(prefix, info, feature_names):
print(f"{prefix}: {type(info)} UNIMPLEMENTED")
-def print_model_size(model):
+def print_model_complexity(model):
+ key_len = len("Key")
+ attr_len = len("Attribute")
+ for name in model.names:
+ if len(name) > key_len:
+ key_len = len(name)
+ for attr in model.attributes(name):
+ if len(attr) > attr_len:
+ attr_len = len(attr)
for name in model.names:
for attribute in model.attributes(name):
+ mf = model.attr_by_name[name][attribute].model_function
+ prefix = f"{name:{key_len}s} {attribute:{attr_len}s}: {mf.get_complexity_score():7d}"
try:
- num_nodes = model.attr_by_name[name][
- attribute
- ].model_function.get_number_of_nodes()
- max_depth = model.attr_by_name[name][
- attribute
- ].model_function.get_max_depth()
- print(
- f"{name:15s} {attribute:20s}: {num_nodes:6d} nodes @ {max_depth:3d} max depth"
- )
+ num_nodes = mf.get_number_of_nodes()
+ max_depth = mf.get_max_depth()
+ print(f"{prefix} ({num_nodes:6d} nodes @ {max_depth:3d} max depth)")
except AttributeError:
- print(
- f"{name:15s} {attribute:20s}: {model.attr_by_name[name][attribute].model_function}"
- )
+ print(prefix)
def format_quality_measures(result, error_metric="smape", col_len=8):
@@ -483,16 +485,15 @@ def add_standard_arguments(parser):
help="Show model error compared to LUT (lower bound) and static (reference) models",
)
parser.add_argument(
- "--show-model-size",
+ "--show-model-complexity",
action="store_true",
- help="Show model size (e.g. regression tree height and node count)",
+ help="Show model complexity score and details (e.g. regression tree height and node count)",
)
parser.add_argument(
"--cross-validate",
metavar="<method>:<count>",
type=str,
- help="Perform cross validation when computing model quality. "
- "Only works with --show-quality=table at the moment.",
+ help="Perform cross validation when computing model quality",
)
parser.add_argument(
"--parameter-aware-cross-validation",