ACA050 commited on
Commit
c3da054
·
verified ·
1 Parent(s): 27c507a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import gradio as gr
3
  import matplotlib.pyplot as plt
4
  import io
@@ -14,6 +13,11 @@ import json
14
  import pickle # Added for loading .pkl and .json files
15
  import os # Added for path checking
16
 
 
 
 
 
 
17
  # --- Device Configuration ---
18
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
19
 
@@ -226,13 +230,13 @@ except FileNotFoundError as e:
226
  raise SystemExit(f"Error loading global variables: {e}. Please ensure 'global_vars.json' is available.")
227
 
228
  # Unpack global variables
229
- label_encoder = LabelEncoder()
230
- label_encoder.classes_ = np.array(global_vars['label_encoder_classes'])
231
  num_classes = global_vars['num_classes']
232
  best_hyperparams = global_vars['best_hyperparams']
233
  expected_value_reg = global_vars['expected_value_reg']
234
  expected_value_cls = np.array(global_vars['expected_value_cls']) # Already converted to list, convert back to np array
235
- AA_PROPERTIES = global_vars['AA_PROPERTIES']
236
 
237
  # Load feature names
238
  try:
@@ -474,13 +478,12 @@ output_components = [
474
  gr.HTML(label="Top Global Feature Importance")
475
  ]
476
 
477
- # Create the Gradio Interface
478
  with gr.Blocks(theme=gr.themes.Soft()) as iface:
479
  gr.Markdown("# Protein Stability Change (ΔΔG) Prediction with Explainability")
480
  gr.Markdown(
481
  "Predict ΔΔG and mutation effect for single amino acid substitutions in proteins. "
482
  "Explore physicochemical changes, mutation structural context, and feature importance with SHAP explanations. "
483
- "Designed for researchers and doctors for practical applications."
484
  "All backend features are included and frontend template is professional and exceptional."
485
  )
486
 
 
 
1
  import gradio as gr
2
  import matplotlib.pyplot as plt
3
  import io
 
13
  import pickle # Added for loading .pkl and .json files
14
  import os # Added for path checking
15
 
16
+ from sklearn.preprocessing import LabelEncoder, StandardScaler, OneHotEncoder # Explicitly import LabelEncoder
17
+ from sklearn.impute import SimpleImputer
18
+ from sklearn.compose import ColumnTransformer
19
+ from sklearn.pipeline import Pipeline
20
+
21
  # --- Device Configuration ---
22
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
23
 
 
230
  raise SystemExit(f"Error loading global variables: {e}. Please ensure 'global_vars.json' is available.")
231
 
232
  # Unpack global variables
233
+ label_encoder = LabelEncoder() # Create an instance of LabelEncoder
234
+ label_encoder.classes_ = np.array(global_vars['label_encoder_classes']) # Assign classes from loaded data
235
  num_classes = global_vars['num_classes']
236
  best_hyperparams = global_vars['best_hyperparams']
237
  expected_value_reg = global_vars['expected_value_reg']
238
  expected_value_cls = np.array(global_vars['expected_value_cls']) # Already converted to list, convert back to np array
239
+ AA_PROPERTIES = global_vars['AA_PROPERTIES'] # Access global AA_PROPERTIES
240
 
241
  # Load feature names
242
  try:
 
478
  gr.HTML(label="Top Global Feature Importance")
479
  ]
480
 
 
481
  with gr.Blocks(theme=gr.themes.Soft()) as iface:
482
  gr.Markdown("# Protein Stability Change (ΔΔG) Prediction with Explainability")
483
  gr.Markdown(
484
  "Predict ΔΔG and mutation effect for single amino acid substitutions in proteins. "
485
  "Explore physicochemical changes, mutation structural context, and feature importance with SHAP explanations. "
486
+ "Designed for researchers and doctors for practical applications."
487
  "All backend features are included and frontend template is professional and exceptional."
488
  )
489