Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -109,18 +109,26 @@ def predictmic(sequence):
|
|
109 |
# Combined Output as Single String
|
110 |
def full_prediction(sequence):
|
111 |
features = extract_features(sequence)
|
112 |
-
if isinstance(features, str):
|
113 |
return features
|
114 |
prediction = model.predict(features)[0]
|
115 |
probabilities = model.predict_proba(features)[0]
|
116 |
amp_result = "Antimicrobial Peptide (AMP)" if prediction == 0 else "Non-AMP"
|
117 |
confidence = round(probabilities[0 if prediction == 0 else 1] * 100, 2)
|
118 |
-
|
119 |
-
result = f"Prediction: {amp_result}\nConfidence: {confidence}%\n
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
return result
|
123 |
|
|
|
124 |
# Gradio Interface (Single Label Output)
|
125 |
iface = gr.Interface(
|
126 |
fn=full_prediction,
|
|
|
109 |
# Combined Output as Single String
|
110 |
def full_prediction(sequence):
|
111 |
features = extract_features(sequence)
|
112 |
+
if isinstance(features, str): # error message returned
|
113 |
return features
|
114 |
prediction = model.predict(features)[0]
|
115 |
probabilities = model.predict_proba(features)[0]
|
116 |
amp_result = "Antimicrobial Peptide (AMP)" if prediction == 0 else "Non-AMP"
|
117 |
confidence = round(probabilities[0 if prediction == 0 else 1] * 100, 2)
|
118 |
+
|
119 |
+
result = f"Prediction: {amp_result}\nConfidence: {confidence}%\n"
|
120 |
+
|
121 |
+
if prediction == 0: # only predict MIC if AMP
|
122 |
+
mic_values = predictmic(sequence)
|
123 |
+
result += "\nPredicted MIC Values (µM):\n"
|
124 |
+
for organism, mic in mic_values.items():
|
125 |
+
result += f"- {organism}: {mic}\n"
|
126 |
+
else:
|
127 |
+
result += "\nMIC prediction is not available because sequence is Non-AMP."
|
128 |
+
|
129 |
return result
|
130 |
|
131 |
+
|
132 |
# Gradio Interface (Single Label Output)
|
133 |
iface = gr.Interface(
|
134 |
fn=full_prediction,
|