Clementio commited on
Commit
10a72dd
ยท
verified ยท
1 Parent(s): 8c20960

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -239,16 +239,21 @@ def main():
239
  seq_length=st.slider('Sequence Length',10,200,50)
240
  seed=st.number_input('Student Seed',1,1000,42,1)
241
  np.random.seed(int(seed))
242
- sim_skills=np.random.randint(0,config['num_skills'],seq_length).tolist()
243
- sim_corrects=np.random.randint(0,2,seq_length).tolist()
244
- skill_probs=run_sakt_inference(model,config,sim_skills,sim_corrects,device)
245
- mastery_vector=build_mastery_vector(skill_probs,graph,skill_encoder,domain_key,threshold,soft_threshold)
246
- st.success(f'SAKT inference complete โ€” {len(skill_probs)} skill predictions generated')
247
- real_skills, real_probs, seq_len = get_attention_weights(model,config,sim_skills,sim_corrects,device)
248
- if len(real_probs) > 0:
249
- st.markdown('**๐Ÿ“ˆ SAKT Mastery Signal (last 10 interactions):**')
250
- attn_df = pd.DataFrame({'Interaction Step': [f'Step {seq_len-len(real_probs)+i+1}' for i in range(len(real_probs))], 'Predicted Mastery': [round(float(p),3) for p in real_probs]})
251
- st.bar_chart(attn_df.set_index('Interaction Step'))
 
 
 
 
 
252
  if st.button('๐Ÿš€ Generate Recommendations', type='primary'):
253
  output=pipeline.run(mastery_vector)
254
  summary=mastery_vector.get_mastery_summary()
 
239
  seq_length=st.slider('Sequence Length',10,200,50)
240
  seed=st.number_input('Student Seed',1,1000,42,1)
241
  np.random.seed(int(seed))
242
+ topic_nodes = list(graph.nodes)
243
+ n_topics = len(topic_nodes)
244
+ raw_scores = np.random.beta(1.5, 3.0, size=n_topics)
245
+ scale = min(seq_length / 200.0 * 1.4, 1.0)
246
+ scores = np.clip(raw_scores * scale, 0.0, 1.0)
247
+ for topic_id, score in zip(topic_nodes, scores):
248
+ mastery_vector.update(topic_id, float(score))
249
+ mastery_df = pd.DataFrame({
250
+ 'Topic': [graph.nodes[t].get('label', t)[:25] for t in topic_nodes],
251
+ 'Mastery': [round(float(s), 3) for s in scores]
252
+ }).sort_values('Mastery', ascending=False).head(10)
253
+ st.markdown('**๐Ÿ“ˆ Simulated Learner Mastery Signal (top 10 topics):**')
254
+ st.bar_chart(mastery_df.set_index('Topic'))
255
+ n_mastered = sum(1 for s in scores if s >= threshold)
256
+ st.success(f'Learner simulation complete โ€” {n_mastered}/{n_topics} topics above mastery threshold')
257
  if st.button('๐Ÿš€ Generate Recommendations', type='primary'):
258
  output=pipeline.run(mastery_vector)
259
  summary=mastery_vector.get_mastery_summary()