Update app.py
Browse files
app.py
CHANGED
|
@@ -51,6 +51,9 @@ def extract_features(sequence: str) -> pd.DataFrame:
|
|
| 51 |
return df
|
| 52 |
|
| 53 |
# --- Prediction function ---
|
|
|
|
|
|
|
|
|
|
| 54 |
def predict_peptide(sequence: str):
|
| 55 |
seq = "".join(sequence.split()).upper()
|
| 56 |
if not seq:
|
|
@@ -59,12 +62,14 @@ def predict_peptide(sequence: str):
|
|
| 59 |
X = extract_features(seq)
|
| 60 |
probs_list = model.predict_proba(X) # list of arrays per target cell
|
| 61 |
|
| 62 |
-
# Format output
|
| 63 |
table = []
|
| 64 |
-
for i, target in enumerate(
|
| 65 |
-
|
|
|
|
| 66 |
return table
|
| 67 |
|
|
|
|
| 68 |
# --- Gradio Interface ---
|
| 69 |
custom_css = """
|
| 70 |
footer, .footer {display:none !important;}
|
|
|
|
| 51 |
return df
|
| 52 |
|
| 53 |
# --- Prediction function ---
|
| 54 |
+
TARGET_CELLS = ["Gram+", "Fungus", "Mammalian Cell", "Cancer", "Gram-"]
|
| 55 |
+
|
| 56 |
+
|
| 57 |
def predict_peptide(sequence: str):
|
| 58 |
seq = "".join(sequence.split()).upper()
|
| 59 |
if not seq:
|
|
|
|
| 62 |
X = extract_features(seq)
|
| 63 |
probs_list = model.predict_proba(X) # list of arrays per target cell
|
| 64 |
|
| 65 |
+
# Format output with 4 decimal places
|
| 66 |
table = []
|
| 67 |
+
for i, target in enumerate(TARGET_CELLS):
|
| 68 |
+
prob = float(probs_list[i][0][1])
|
| 69 |
+
table.append([target, round(prob, 4)])
|
| 70 |
return table
|
| 71 |
|
| 72 |
+
|
| 73 |
# --- Gradio Interface ---
|
| 74 |
custom_css = """
|
| 75 |
footer, .footer {display:none !important;}
|