alisrbdni commited on
Commit
0bf1a6a
·
verified ·
1 Parent(s): e3bf7fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -0
app.py CHANGED
@@ -535,6 +535,57 @@ def main():
535
  for round_num in range(NUM_ROUNDS):
536
  st.write(f"### Round {round_num + 1}")
537
  st.markdown(read_log_file2())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
538
  plot_placeholders = [st.empty() for _ in range(NUM_CLIENTS)]
539
 
540
  fl.simulation.start_simulation(
 
535
  for round_num in range(NUM_ROUNDS):
536
  st.write(f"### Round {round_num + 1}")
537
  st.markdown(read_log_file2())
538
+ logs = read_log_file2()
539
+ import re
540
+ import plotly.graph_objects as go
541
+ import streamlit as st
542
+ import pandas as pd
543
+
544
+ # Log data
545
+ log_data = logs
546
+
547
+ # Extract relevant data
548
+ accuracy_pattern = re.compile(r"'accuracy': \((\d+),([\d.]+)\)\((\d+), ([\d.]+)\)")
549
+ loss_pattern = re.compile(r"'loss': \((\d+),([\d.]+)\)\((\d+), ([\d.]+)\)")
550
+
551
+ accuracy_matches = accuracy_pattern.findall(log_data)
552
+ loss_matches = loss_pattern.findall(log_data)
553
+
554
+ rounds = [int(match[0]) for match in accuracy_matches]
555
+ accuracies = [float(match[1]) for match in accuracy_matches]
556
+ losses = [float(match[1]) for match in loss_matches]
557
+
558
+ # Create accuracy plot
559
+ accuracy_fig = go.Figure()
560
+ accuracy_fig.add_trace(go.Scatter(x=rounds, y=accuracies, mode='lines+markers', name='Accuracy'))
561
+ accuracy_fig.update_layout(title='Accuracy over Rounds', xaxis_title='Round', yaxis_title='Accuracy')
562
+
563
+ # Create loss plot
564
+ loss_fig = go.Figure()
565
+ loss_fig.add_trace(go.Scatter(x=rounds, y=losses, mode='lines+markers', name='Loss'))
566
+ loss_fig.update_layout(title='Loss over Rounds', xaxis_title='Round', yaxis_title='Loss')
567
+
568
+ # Display plots in Streamlit
569
+ st.plotly_chart(accuracy_fig)
570
+ st.plotly_chart(loss_fig)
571
+
572
+ # Display data table
573
+ data = {
574
+ 'Round': rounds,
575
+ 'Accuracy': accuracies,
576
+ 'Loss': losses
577
+ }
578
+
579
+ df = pd.DataFrame(data)
580
+ st.write("## Training Metrics")
581
+ st.table(df)
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
  plot_placeholders = [st.empty() for _ in range(NUM_CLIENTS)]
590
 
591
  fl.simulation.start_simulation(