forked from enviPath/enviPy
minor
This commit is contained in:
@ -2815,18 +2815,55 @@ class PackageBasedModel(EPModel):
|
|||||||
)
|
)
|
||||||
multigen_eval = models.BooleanField(null=False, blank=False, default=False)
|
multigen_eval = models.BooleanField(null=False, blank=False, default=False)
|
||||||
|
|
||||||
|
def parameters(self):
|
||||||
|
params = {
|
||||||
|
"Model Evaluation Threshold": f"{self.threshold:.2f}",
|
||||||
|
"Multi Gen Evaluation": "Yes" if self.multigen_eval else "No",
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.app_domain:
|
||||||
|
params["Applicability Domain Num Neighbors"] = f"{self.app_domain.num_neighbours:.2f}"
|
||||||
|
params["Applicability Domain Reliability Threshold"] = (
|
||||||
|
f"{self.app_domain.reliability_threshold:.2f}"
|
||||||
|
)
|
||||||
|
params["Applicability Domain Local Compatibility Threshold"] = (
|
||||||
|
f"{self.app_domain.local_compatibilty_threshold:.2f}"
|
||||||
|
)
|
||||||
|
|
||||||
|
return params
|
||||||
|
|
||||||
def statistics(self):
|
def statistics(self):
|
||||||
|
from sklearn.metrics import auc
|
||||||
|
|
||||||
|
recall = list(self.eval_results["average_recall_per_threshold"].values())
|
||||||
|
precision = list(self.eval_results["average_precision_per_threshold"].values())
|
||||||
|
mg_recall = list(
|
||||||
|
self.eval_results.get("multigen_average_recall_per_threshold", {}).values()
|
||||||
|
)
|
||||||
|
mg_precision = list(
|
||||||
|
self.eval_results.get("multigen_average_precision_per_threshold", {}).values()
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'accuracy': [
|
"accuracy": [
|
||||||
self.eval_results["average_accuracy"],
|
self.eval_results["average_accuracy"],
|
||||||
self.eval_results.get("multigen_average_accuracy")],
|
self.eval_results.get("multigen_average_accuracy"),
|
||||||
'precision': [
|
|
||||||
self.eval_results["average_precision_per_threshold"][f"{self.threshold:.2f}"],
|
|
||||||
self.eval_results.get("multigen_average_precision_per_threshold", {}).get(f"{self.threshold:.2f}")
|
|
||||||
],
|
],
|
||||||
'recall': [
|
"precision": [
|
||||||
|
self.eval_results["average_precision_per_threshold"][f"{self.threshold:.2f}"],
|
||||||
|
self.eval_results.get("multigen_average_precision_per_threshold", {}).get(
|
||||||
|
f"{self.threshold:.2f}"
|
||||||
|
),
|
||||||
|
],
|
||||||
|
"recall": [
|
||||||
self.eval_results["average_recall_per_threshold"][f"{self.threshold:.2f}"],
|
self.eval_results["average_recall_per_threshold"][f"{self.threshold:.2f}"],
|
||||||
self.eval_results.get("multigen_average_recall_per_threshold", {}).get(f"{self.threshold:.2f}")
|
self.eval_results.get("multigen_average_recall_per_threshold", {}).get(
|
||||||
|
f"{self.threshold:.2f}"
|
||||||
|
),
|
||||||
|
],
|
||||||
|
"Area under PR Curve": [
|
||||||
|
auc(recall, precision),
|
||||||
|
auc(mg_recall, mg_precision) if self.multigen_eval else None,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3053,8 +3090,6 @@ class PackageBasedModel(EPModel):
|
|||||||
thresholds.append(np.float64(threshold))
|
thresholds.append(np.float64(threshold))
|
||||||
thresholds.sort()
|
thresholds.sort()
|
||||||
|
|
||||||
logger.info(f"Thresholds: {thresholds}")
|
|
||||||
|
|
||||||
precision = {f"{t:.2f}": [] for t in thresholds}
|
precision = {f"{t:.2f}": [] for t in thresholds}
|
||||||
recall = {f"{t:.2f}": [] for t in thresholds}
|
recall = {f"{t:.2f}": [] for t in thresholds}
|
||||||
|
|
||||||
@ -3103,14 +3138,18 @@ class PackageBasedModel(EPModel):
|
|||||||
for t in thresholds:
|
for t in thresholds:
|
||||||
for true, pred in zip(pathways, pred_pathways):
|
for true, pred in zip(pathways, pred_pathways):
|
||||||
acc, pre, rec = multigen_eval(true, pred, t)
|
acc, pre, rec = multigen_eval(true, pred, t)
|
||||||
if abs(t - threshold) < 0.01:
|
|
||||||
mg_acc = acc
|
if f"{t:.2f}" == f"{threshold:.2f}":
|
||||||
|
mg_acc += acc
|
||||||
|
|
||||||
precision[f"{t:.2f}"].append(pre)
|
precision[f"{t:.2f}"].append(pre)
|
||||||
recall[f"{t:.2f}"].append(rec)
|
recall[f"{t:.2f}"].append(rec)
|
||||||
|
|
||||||
|
avg_mg_acc = mg_acc / len(root_compounds)
|
||||||
precision = {k: sum(v) / len(v) if len(v) > 0 else 0 for k, v in precision.items()}
|
precision = {k: sum(v) / len(v) if len(v) > 0 else 0 for k, v in precision.items()}
|
||||||
recall = {k: sum(v) / len(v) if len(v) > 0 else 0 for k, v in recall.items()}
|
recall = {k: sum(v) / len(v) if len(v) > 0 else 0 for k, v in recall.items()}
|
||||||
return mg_acc, precision, recall
|
logger.info("Average Multigen Accuracy: {:.2f}".format(avg_mg_acc))
|
||||||
|
return avg_mg_acc, precision, recall
|
||||||
|
|
||||||
# If there are eval packages perform single generation evaluation on them instead of random splits
|
# If there are eval packages perform single generation evaluation on them instead of random splits
|
||||||
if self.eval_packages.count() > 0:
|
if self.eval_packages.count() > 0:
|
||||||
|
|||||||
@ -477,8 +477,7 @@ def batch_predict(
|
|||||||
limit=None,
|
limit=None,
|
||||||
setting_overrides={
|
setting_overrides={
|
||||||
"max_nodes": num_tps,
|
"max_nodes": num_tps,
|
||||||
"max_depth": num_tps,
|
"model_threshold": 0.0,
|
||||||
"model_threshold": 0.001,
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -117,6 +117,38 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<!-- Model Parameters Panel -->
|
||||||
|
<div class="collapse-arrow bg-base-200 collapse">
|
||||||
|
<input type="checkbox" checked />
|
||||||
|
<div class="collapse-title text-xl font-medium">Model Parameters</div>
|
||||||
|
<div class="collapse-content">
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<div
|
||||||
|
id="model-stats"
|
||||||
|
class="overflow-x-auto rounded-box shadow-md bg-base-100"
|
||||||
|
>
|
||||||
|
<table class="table table-fixed w-full">
|
||||||
|
<thead class="text-base">
|
||||||
|
<tr>
|
||||||
|
<th class="w-3/5">Parameter</th>
|
||||||
|
<th>Value</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for param, value in model.parameters.items %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ param }}</td>
|
||||||
|
<td>{{ value }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block usemodel %}
|
{% block usemodel %}
|
||||||
|
|||||||
@ -537,7 +537,7 @@
|
|||||||
<input type="checkbox" />
|
<input type="checkbox" />
|
||||||
<div class="collapse-title text-xl font-medium">Setting</div>
|
<div class="collapse-title text-xl font-medium">Setting</div>
|
||||||
<div class="collapse-content">
|
<div class="collapse-content">
|
||||||
{% with setting_to_render=pathway.setting can_be_default=False %}
|
{% with setting_to_render=pathway.setting_with_overrides can_be_default=False %}
|
||||||
{% include "objects/setting_template.html" %}
|
{% include "objects/setting_template.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -95,6 +95,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Other Prediction Settings -->
|
<!-- Other Prediction Settings -->
|
||||||
|
{% if meta.available_settings|length > 1 %}
|
||||||
<div class="collapse-arrow bg-base-200 collapse">
|
<div class="collapse-arrow bg-base-200 collapse">
|
||||||
<input type="checkbox" />
|
<input type="checkbox" />
|
||||||
<div class="collapse-title text-xl font-medium">
|
<div class="collapse-title text-xl font-medium">
|
||||||
@ -110,6 +111,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
Reference in New Issue
Block a user