comparison html_structure.py @ 15:d17e3a1b8659 draft default tip

planemo upload for repository https://github.com/goeckslab/gleam.git commit bc50fef8acb44aca15d0a1746e6c0c967da5bb17
author goeckslab
date Fri, 28 Nov 2025 15:45:49 +0000
parents bcfa2e234a80
children
comparison
equal deleted inserted replaced
14:94cd9ac4a9b1 15:d17e3a1b8659
20 split_info: Optional[str] = None, 20 split_info: Optional[str] = None,
21 training_progress: dict = None, 21 training_progress: dict = None,
22 output_type: Optional[str] = None, 22 output_type: Optional[str] = None,
23 ) -> str: 23 ) -> str:
24 display_keys = [ 24 display_keys = [
25 "architecture",
26 "pretrained",
27 "trainable",
28 "target_column",
25 "task_type", 29 "task_type",
26 "model_name", 30 "validation_metric",
31 "loss_function",
32 "threshold",
27 "epochs", 33 "epochs",
34 "total_epochs",
28 "batch_size", 35 "batch_size",
29 "fine_tune", 36 "fine_tune",
30 "use_pretrained", 37 "use_pretrained",
31 "learning_rate", 38 "learning_rate",
39 "optimizer",
32 "random_seed", 40 "random_seed",
33 "early_stop", 41 "early_stop",
34 "threshold", 42 "use_mixed_precision",
43 "gradient_clipping",
35 ] 44 ]
36 45
37 rows = [] 46 rows = []
38 47
39 for key in display_keys: 48 for key in display_keys:
49 val_str = "N/A"
40 val = config.get(key, None) 50 val = config.get(key, None)
41 if key == "threshold": 51 if key == "threshold":
42 if output_type != "binary": 52 if output_type != "binary":
43 continue 53 continue
44 val = val if val is not None else 0.5 54 val = val if val is not None else 0.5
47 val_str += " (default)" 57 val_str += " (default)"
48 else: 58 else:
49 if key == "task_type": 59 if key == "task_type":
50 val_str = val.title() if isinstance(val, str) else "N/A" 60 val_str = val.title() if isinstance(val, str) else "N/A"
51 elif key == "batch_size": 61 elif key == "batch_size":
52 if val is not None: 62 if isinstance(val, (int, float)):
53 val_str = int(val) 63 val_str = int(val)
54 else: 64 else:
55 val = "auto" 65 val = "auto"
56 val_str = "auto" 66 val_str = "auto"
57 resolved_val = None 67 resolved_val = None
118 f"Because of early stopping: the training " 128 f"Because of early stopping: the training "
119 f"stopped at epoch {training_progress['epoch']}" 129 f"stopped at epoch {training_progress['epoch']}"
120 ) 130 )
121 else: 131 else:
122 val_str = val 132 val_str = val
133 elif key == "pretrained":
134 if isinstance(val, bool):
135 val_str = "Yes (ImageNet)" if val else "No"
136 else:
137 val_str = val if val is not None else "N/A"
138 elif key == "trainable":
139 if isinstance(val, bool):
140 val_str = "Trainable" if val else "Frozen"
141 else:
142 val_str = val if val is not None else "N/A"
143 elif key == "use_mixed_precision":
144 if isinstance(val, bool):
145 val_str = "Yes" if val else "No"
146 else:
147 val_str = val if val is not None else "N/A"
123 else: 148 else:
124 val_str = val if val is not None else "N/A" 149 val_str = val if val is not None else "N/A"
125 if val_str == "N/A" and key not in ["task_type"]: 150 if val_str == "N/A" and key not in ["task_type"]:
126 continue 151 continue
127 rows.append( 152 rows.append(
153 f"<td style='padding: 6px 12px; border: 1px solid #ccc; text-align: center; " 178 f"<td style='padding: 6px 12px; border: 1px solid #ccc; text-align: center; "
154 f"white-space: normal; word-break: break-word; overflow-wrap: anywhere;'>{split_info}</td></tr>" 179 f"white-space: normal; word-break: break-word; overflow-wrap: anywhere;'>{split_info}</td></tr>"
155 ) 180 )
156 181
157 html = f""" 182 html = f"""
158 <h2 style="text-align: center;">Model and Training Summary</h2> 183 <h2 style="text-align: center;">Training Configuration (Model, Data, Metrics)</h2>
159 <div style="display: flex; justify-content: center;"> 184 <div style="display: flex; justify-content: center;">
160 <table style="border-collapse: collapse; width: 100%; table-layout: fixed;"> 185 <table style="border-collapse: collapse; width: 100%; table-layout: fixed;">
161 <thead><tr> 186 <thead><tr>
162 <th style="padding: 10px; border: 1px solid #ccc; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">Parameter</th> 187 <th style="padding: 10px; border: 1px solid #ccc; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">Parameter</th>
163 <th style="padding: 10px; border: 1px solid #ccc; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">Value</th> 188 <th style="padding: 10px; border: 1px solid #ccc; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">Value</th>
517 542
518 543
519 def build_tabbed_html(metrics_html: str, train_val_html: str, test_html: str) -> str: 544 def build_tabbed_html(metrics_html: str, train_val_html: str, test_html: str) -> str:
520 """ 545 """
521 Build a 3-tab interface: 546 Build a 3-tab interface:
522 - Config and Results Summary 547 - Config and Overall Performance Summary
523 - Train/Validation Results 548 - Train/Validation Results
524 - Test Results 549 - Test Results
525 Includes a persistent "Help" button that toggles the metrics modal. 550 Includes a persistent "Help" button that toggles the metrics modal.
526 """ 551 """
527 return f""" 552 return f"""
528 <div class="tabs"> 553 <div class="tabs">
529 <div class="tab active" onclick="showTab('metrics')">Config and Results Summary</div> 554 <div class="tab active" onclick="showTab('metrics')">Config and Overall Performance Summary</div>
530 <div class="tab" onclick="showTab('trainval')">Train/Validation Results</div> 555 <div class="tab" onclick="showTab('trainval')">Training and Validation Results</div>
531 <div class="tab" onclick="showTab('test')">Test Results</div> 556 <div class="tab" onclick="showTab('test')">Test Results</div>
532 <button id="openMetricsHelp" class="help-btn" title="Open metrics help">Help</button> 557 <button id="openMetricsHelp" class="help-btn" title="Open metrics help">Help</button>
533 </div> 558 </div>
534 559
535 <div id="metrics" class="tab-content active"> 560 <div id="metrics" class="tab-content active">