basilboy commited on
Commit
088cb01
·
verified ·
1 Parent(s): 9ff1365

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -9,13 +9,14 @@ def main():
9
  st.set_page_config(layout="wide") # Keep the wide layout for overall flexibility
10
  st.title("AA Property Inference Demo", anchor=None)
11
 
12
- # Styling for the app to use monospace font
13
  st.markdown("""
14
  <style>
15
  .reportview-container {
16
  font-family: 'Courier New', monospace;
17
  }
18
  </style>
 
19
  """, unsafe_allow_html=True)
20
 
21
  # Input section in the sidebar
@@ -56,7 +57,11 @@ def main():
56
  plot_prediction_graphs(all_data)
57
 
58
  def plot_prediction_graphs(data):
59
- # Function to plot graphs for predictions, divided by prediction value
 
 
 
 
60
  for model_name in models.keys():
61
  fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(16, 6), sharey=True)
62
  for prediction_val in [0, 1]:
@@ -66,7 +71,8 @@ def plot_prediction_graphs(data):
66
  sorted_sequences = sorted(filtered_data.items(), key=lambda x: x[1][1], reverse=True)
67
  sequences = [x[0] for x in sorted_sequences]
68
  conf_values = [x[1][1] for x in sorted_sequences]
69
- sns.barplot(x=sequences, y=conf_values, palette="coolwarm" if prediction_val == 0 else "cubehelix", ax=ax)
 
70
  ax.set_title(f'Confidence Scores for {model_name.capitalize()} (Prediction {prediction_val})')
71
  ax.set_xlabel('Sequences')
72
  ax.set_ylabel('Confidence')
 
9
  st.set_page_config(layout="wide") # Keep the wide layout for overall flexibility
10
  st.title("AA Property Inference Demo", anchor=None)
11
 
12
+ # Instructional text below title
13
  st.markdown("""
14
  <style>
15
  .reportview-container {
16
  font-family: 'Courier New', monospace;
17
  }
18
  </style>
19
+ <p style='font-size:16px;'><span style='font-size:24px;'>&larr;</span> Don't know where to start? Open tab to input a sequence.</p>
20
  """, unsafe_allow_html=True)
21
 
22
  # Input section in the sidebar
 
57
  plot_prediction_graphs(all_data)
58
 
59
  def plot_prediction_graphs(data):
60
+ # Create a color palette that is consistent across graphs
61
+ unique_sequences = sorted(set(seq for seq in data))
62
+ palette = sns.color_palette("hsv", len(unique_sequences))
63
+ color_dict = {seq: color for seq, color in zip(unique_sequences, palette)}
64
+
65
  for model_name in models.keys():
66
  fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(16, 6), sharey=True)
67
  for prediction_val in [0, 1]:
 
71
  sorted_sequences = sorted(filtered_data.items(), key=lambda x: x[1][1], reverse=True)
72
  sequences = [x[0] for x in sorted_sequences]
73
  conf_values = [x[1][1] for x in sorted_sequences]
74
+ colors = [color_dict[seq] for seq in sequences]
75
+ sns.barplot(x=sequences, y=conf_values, palette=colors, ax=ax)
76
  ax.set_title(f'Confidence Scores for {model_name.capitalize()} (Prediction {prediction_val})')
77
  ax.set_xlabel('Sequences')
78
  ax.set_ylabel('Confidence')