skanderovitch commited on
Commit
e2cefa5
·
verified ·
1 Parent(s): ab5b386

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -112,11 +112,13 @@ def get_strange(n=4):
112
  labels = st.session_state.labels
113
  preds = pd.Series(st.session_state.preds,index=embeddings.index).loc[labels.index].rename('pred')
114
  data = pd.concat([labels, preds],axis=1)
115
-
116
 
117
  data['diff'] = data['pred'] - data['label']
118
- data = data.sort_values('diff')['diff']
119
- return data.iloc[:n].to_dict(),data.iloc[-n:].to_dict()
 
 
120
 
121
 
122
 
@@ -160,18 +162,18 @@ if st.session_state.name:
160
 
161
  cc1.subheader('Where you confused me')
162
 
163
- best,worst = get_strange()
164
 
165
  cc1.write("You didn't like my picks")
166
- cs = cc1.columns(len(best))
167
- for c,(file,pred) in zip(cs,best.items()):
168
- c.metric("", "",f'{pred:.0%}')
169
  c.image(get_s3_url(file), width = 100)
170
 
171
  cc1.write("You liked these more than I thought")
172
- cs = cc1.columns(len(worst))
173
- for c,(file,pred) in zip(cs,worst.items()):
174
- c.metric("","", f'{pred:.0%}')
175
  c.image(get_s3_url(file), width = 100)
176
 
177
 
 
112
  labels = st.session_state.labels
113
  preds = pd.Series(st.session_state.preds,index=embeddings.index).loc[labels.index].rename('pred')
114
  data = pd.concat([labels, preds],axis=1)
115
+ st.toast(data.columns)
116
 
117
  data['diff'] = data['pred'] - data['label']
118
+ data = data.sort_values('diff',ascending=False)['diff']
119
+ surprising_dislikes = data.iloc[:n].to_dict()
120
+ surprising_likes = data.iloc[-n:].to_dict()
121
+ return surprising_dislikes,surprising_likes
122
 
123
 
124
 
 
162
 
163
  cc1.subheader('Where you confused me')
164
 
165
+ surprising_dislikes,surprising_likes = get_strange()
166
 
167
  cc1.write("You didn't like my picks")
168
+ cs = cc1.columns(len(surprising_dislikes))
169
+ for c,(file,pred) in zip(cs,surprising_dislikes.items()):
170
+ c.metric("", "",f'{-pred:.0%}')
171
  c.image(get_s3_url(file), width = 100)
172
 
173
  cc1.write("You liked these more than I thought")
174
+ cs = cc1.columns(len(surprising_likes))
175
+ for c,(file,pred) in zip(cs,surprising_likes.items()):
176
+ c.metric("","", f'{-pred:.0%}')
177
  c.image(get_s3_url(file), width = 100)
178
 
179