Corey Morris
commited on
Commit
•
337b761
1
Parent(s):
ba99486
fixed reversed plot. extracted making chart into a method
Browse files
app.py
CHANGED
@@ -75,27 +75,35 @@ selected_models = st.multiselect(
|
|
75 |
filtered_data = data_provider.get_data(selected_models)
|
76 |
st.dataframe(filtered_data)
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
df[
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
st.plotly_chart(fig)
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
75 |
filtered_data = data_provider.get_data(selected_models)
|
76 |
st.dataframe(filtered_data)
|
77 |
|
78 |
+
def create_plot(df, model_column, arc_column, moral_column, models=None):
|
79 |
+
# Filter the dataframe if specific models are provided
|
80 |
+
if models is not None:
|
81 |
+
df = df[df[model_column].isin(models)]
|
82 |
+
|
83 |
+
# Create a plot with new data
|
84 |
+
plot_data = pd.DataFrame({
|
85 |
+
'Model': list(df[model_column]),
|
86 |
+
arc_column: list(df[arc_column]),
|
87 |
+
moral_column: list(df[moral_column]),
|
88 |
+
})
|
89 |
+
|
90 |
+
# Calculate color column
|
91 |
+
plot_data['color'] = 'purple'
|
92 |
+
plot_data.loc[plot_data[moral_column] < plot_data[arc_column], 'color'] = 'red'
|
93 |
+
plot_data.loc[plot_data[moral_column] > plot_data[arc_column], 'color'] = 'blue'
|
94 |
+
|
95 |
+
# Create the scatter plot
|
96 |
+
fig = px.scatter(plot_data, x=arc_column, y=moral_column, color='color', hover_data=['Model'])
|
97 |
+
fig.update_layout(showlegend=False, # hide legend
|
98 |
+
xaxis_title='ARC Accuracy',
|
99 |
+
yaxis_title='Moral Scenarios Accuracy',
|
100 |
+
xaxis = dict(),
|
101 |
+
yaxis = dict())
|
102 |
+
|
103 |
+
return fig
|
104 |
+
|
105 |
+
# models_to_plot = ['Model1', 'Model2', 'Model3']
|
106 |
+
# fig = create_plot(filtered_data, 'Model Name', 'arc:challenge|25', 'moral_scenarios|5', models=models_to_plot)
|
107 |
+
|
108 |
+
fig = create_plot(filtered_data, 'Model Name', 'arc:challenge|25', 'moral_scenarios|5')
|
109 |
st.plotly_chart(fig)
|
|
|
|
|
|