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:
@ -340,6 +340,7 @@ DEFAULT_MODEL_PARAMS = {
|
||||
DEFAULT_MAX_NUMBER_OF_NODES = 50
|
||||
DEFAULT_MAX_DEPTH = 8
|
||||
DEFAULT_MODEL_THRESHOLD = 0.25
|
||||
BATCH_PREDICT_MAX_COMPOUNDS = 150
|
||||
|
||||
# Loading Plugins
|
||||
PLUGINS_ENABLED = os.environ.get("PLUGINS_ENABLED", "False") == "True"
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -37,7 +37,8 @@
|
||||
class="text-xs text-base-content/50 border-t border-base-300 pt-3"
|
||||
>
|
||||
<strong>Format:</strong> First column = SMILES, Second column =
|
||||
Name (headers optional) • Maximum 30 rows
|
||||
Name (headers optional) • Maximum
|
||||
{{ batch_predict_max_compoundss|default:150 }} rows
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -195,8 +196,7 @@
|
||||
// Function to populate table from CSV data
|
||||
function populateTableFromCSV(csvData) {
|
||||
const lines = csvData.trim().split("\n");
|
||||
const maxRows = 30;
|
||||
|
||||
const maxRows = Number("{{ batch_predict_max_compounds|default:150 }}");
|
||||
// Clear existing table
|
||||
clearTable();
|
||||
|
||||
|
||||
@ -51,7 +51,10 @@
|
||||
</svg>
|
||||
Go Home
|
||||
</a>
|
||||
<button onclick="window.history.back()" class="btn btn-outline">
|
||||
<button
|
||||
onclick="window.location.href = document.referrer"
|
||||
class="btn btn-outline"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="mr-2 h-5 w-5"
|
||||
|
||||
Reference in New Issue
Block a user