Spaces:
Sleeping
Sleeping
Update app.py with transformer embeddings and prediction pipeline
Browse files
app.py
CHANGED
@@ -80,7 +80,8 @@ def predict_with_gpflow(model, X):
|
|
80 |
return mean.numpy().flatten(), variance.numpy().flatten()
|
81 |
|
82 |
|
83 |
-
|
|
|
84 |
"""
|
85 |
Process a single target for prediction using transformer embeddings and the specified model.
|
86 |
"""
|
@@ -101,6 +102,7 @@ def process_target(target):
|
|
101 |
y_pred, y_uncertainty = predict_with_gpflow(model, embedding)
|
102 |
return target, round(y_pred[0], 2), round(y_uncertainty[0], 2)
|
103 |
|
|
|
104 |
def predict(sequence, prediction_type):
|
105 |
"""
|
106 |
Predicts Specificity, kcatC, and KC for the given sequence and prediction type.
|
@@ -110,7 +112,12 @@ def predict(sequence, prediction_type):
|
|
110 |
|
111 |
# Predict for all targets in parallel
|
112 |
with ThreadPoolExecutor() as executor:
|
113 |
-
results = list(
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
# Format results
|
116 |
if prediction_type == "Plant-Specific":
|
|
|
80 |
return mean.numpy().flatten(), variance.numpy().flatten()
|
81 |
|
82 |
|
83 |
+
|
84 |
+
def process_target(target, selected_models, sequence, prediction_type):
|
85 |
"""
|
86 |
Process a single target for prediction using transformer embeddings and the specified model.
|
87 |
"""
|
|
|
102 |
y_pred, y_uncertainty = predict_with_gpflow(model, embedding)
|
103 |
return target, round(y_pred[0], 2), round(y_uncertainty[0], 2)
|
104 |
|
105 |
+
|
106 |
def predict(sequence, prediction_type):
|
107 |
"""
|
108 |
Predicts Specificity, kcatC, and KC for the given sequence and prediction type.
|
|
|
112 |
|
113 |
# Predict for all targets in parallel
|
114 |
with ThreadPoolExecutor() as executor:
|
115 |
+
results = list(
|
116 |
+
executor.map(
|
117 |
+
lambda target: process_target(target, selected_models, sequence, prediction_type),
|
118 |
+
selected_models.keys()
|
119 |
+
)
|
120 |
+
)
|
121 |
|
122 |
# Format results
|
123 |
if prediction_type == "Plant-Specific":
|