forked from enviPath/enviPy
[Fix] All thresholds, Increase Batch Predict Limit, Make "Back" Button on error page trigger a new pageload. (#432)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#432
This commit is contained in:
@ -44,7 +44,7 @@ class EPDBURLParser:
|
||||
MODEL_PATTERNS = {
|
||||
"epdb.User": re.compile(rf"^.*/user/{UUID_PATTERN}"),
|
||||
"epdb.Group": re.compile(rf"^.*/group/{UUID_PATTERN}"),
|
||||
"epdb.Package": re.compile(rf"^.*/package/{UUID_PATTERN}"),
|
||||
s.EPDB_PACKAGE_MODEL: re.compile(rf"^.*/package/{UUID_PATTERN}"),
|
||||
"epdb.Compound": re.compile(rf"^.*/package/{UUID_PATTERN}/compound/{UUID_PATTERN}"),
|
||||
"epdb.CompoundStructure": re.compile(
|
||||
rf"^.*/package/{UUID_PATTERN}/compound/{UUID_PATTERN}/structure/{UUID_PATTERN}"
|
||||
@ -94,7 +94,7 @@ class EPDBURLParser:
|
||||
|
||||
def contains_package_url(self):
|
||||
return (
|
||||
bool(self.MODEL_PATTERNS["epdb.Package"].findall(self.url))
|
||||
bool(self.MODEL_PATTERNS[s.EPDB_PACKAGE_MODEL].findall(self.url))
|
||||
and not self.is_package_url()
|
||||
)
|
||||
|
||||
@ -122,7 +122,7 @@ class EPDBURLParser:
|
||||
"epdb.EPModel",
|
||||
"epdb.Pathway",
|
||||
# 1st level
|
||||
"epdb.Package",
|
||||
s.EPDB_PACKAGE_MODEL,
|
||||
"epdb.Setting",
|
||||
"epdb.Group",
|
||||
"epdb.User",
|
||||
@ -144,7 +144,7 @@ class EPDBURLParser:
|
||||
|
||||
hierarchy_order = [
|
||||
# 1st level
|
||||
"epdb.Package",
|
||||
s.EPDB_PACKAGE_MODEL,
|
||||
"epdb.Setting",
|
||||
"epdb.Group",
|
||||
"epdb.User",
|
||||
|
||||
@ -3003,7 +3003,14 @@ class PackageBasedModel(EPModel):
|
||||
|
||||
prec, rec = dict(), dict()
|
||||
|
||||
for t in np.arange(0, 1.05, 0.05):
|
||||
thresholds = list(np.arange(0, 1.05, 0.05))
|
||||
|
||||
# Add specific threshold set during object creation if not already present
|
||||
if np.float64(threshold) not in thresholds:
|
||||
thresholds.append(np.float64(threshold))
|
||||
thresholds.sort()
|
||||
|
||||
for t in thresholds:
|
||||
temp_thresholded = (y_pred_filtered >= t).astype(int)
|
||||
prec[f"{t:.2f}"] = precision_score(
|
||||
y_test_filtered, temp_thresholded, zero_division=0
|
||||
@ -3013,7 +3020,14 @@ class PackageBasedModel(EPModel):
|
||||
return acc, prec, rec
|
||||
|
||||
def evaluate_mg(model, pathways: Union[QuerySet["Pathway"] | List["Pathway"]], threshold):
|
||||
thresholds = np.arange(0.1, 1.1, 0.1)
|
||||
thresholds = list(np.arange(0, 1.05, 0.05))
|
||||
|
||||
# Add specific threshold set during object creation if not already present
|
||||
if np.float64(threshold) not in thresholds:
|
||||
thresholds.append(np.float64(threshold))
|
||||
thresholds.sort()
|
||||
|
||||
logger.info(f"Thresholds: {thresholds}")
|
||||
|
||||
precision = {f"{t:.2f}": [] for t in thresholds}
|
||||
recall = {f"{t:.2f}": [] for t in thresholds}
|
||||
@ -3039,7 +3053,7 @@ class PackageBasedModel(EPModel):
|
||||
|
||||
s = Setting()
|
||||
s.model = mod
|
||||
s.model_threshold = thresholds.min()
|
||||
s.model_threshold = 0.0
|
||||
s.max_depth = 10
|
||||
s.max_nodes = 50
|
||||
|
||||
|
||||
@ -523,6 +523,7 @@ def batch_predict_pathway(request):
|
||||
context = get_base_context(request)
|
||||
context["title"] = "enviPath - Batch Predict Pathway"
|
||||
context["meta"]["current_package"] = context["meta"]["user"].default_package
|
||||
context["batch_predict_max_compounds"] = s.BATCH_PREDICT_MAX_COMPOUNDS
|
||||
|
||||
return render(request, "batch_predict_pathway.html", context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user