notbulubula commited on
Commit
45b152e
·
1 Parent(s): bb382f3

rankingowanie modeli

Browse files
Files changed (1) hide show
  1. app.py +71 -32
app.py CHANGED
@@ -41,35 +41,74 @@ option = st.sidebar.radio(
41
 
42
  df = fetch_runs_to_df(api, projects, selected_project)
43
 
44
- # Streamlit UI
45
- st.title("W&B Data in Streamlit")
46
-
47
- # Sidebar filter options
48
- st.sidebar.header("Filter Options")
49
- run_name_filter = st.sidebar.text_input("Filter by Run Name", "")
50
- state_filter = st.sidebar.selectbox("Filter by State", ["All"] + df["State"].unique().tolist())
51
- tag_filter = st.sidebar.text_input("Filter by Tags (comma separated)", "")
52
-
53
- # Apply filters
54
- if run_name_filter:
55
- df = df[df["Run Name"].str.contains(run_name_filter, case=False, na=False)]
56
- if state_filter != "All":
57
- df = df[df["State"] == state_filter]
58
- if tag_filter:
59
- tag_list = [tag.strip() for tag in tag_filter.split(",")]
60
- df = df[df["Tags"].apply(lambda tags: any(tag in tags for tag in tag_list))]
61
-
62
- # Display the filtered DataFrame
63
- st.dataframe(df)
64
-
65
- # Display details of selected run
66
- if not df.empty:
67
- selected_run_id = st.selectbox("Select a Run ID to see details", df["ID"].tolist())
68
- run = fetch_run(api, projects, selected_project, selected_run_id)
69
-
70
- if run:
71
- run_df = run.history()
72
- st.write(f"Details for run: {run.name}")
73
- st.dataframe(run_df)
74
- else:
75
- st.warning("No runs available to select.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  df = fetch_runs_to_df(api, projects, selected_project)
43
 
44
+ if option == "General":
45
+ # Streamlit UI
46
+ st.title("W&B Data in Streamlit")
47
+
48
+ # Sidebar filter options
49
+ st.sidebar.header("Filter Options")
50
+ run_name_filter = st.sidebar.text_input("Filter by Run Name", "")
51
+ state_filter = st.sidebar.selectbox("Filter by State", ["All"] + df["State"].unique().tolist())
52
+ tag_filter = st.sidebar.text_input("Filter by Tags (comma separated)", "")
53
+
54
+ # Apply filters
55
+ if run_name_filter:
56
+ df = df[df["Run Name"].str.contains(run_name_filter, case=False, na=False)]
57
+ if state_filter != "All":
58
+ df = df[df["State"] == state_filter]
59
+ if tag_filter:
60
+ tag_list = [tag.strip() for tag in tag_filter.split(",")]
61
+ df = df[df["Tags"].apply(lambda tags: any(tag in tags for tag in tag_list))]
62
+
63
+ # Display the filtered DataFrame
64
+ st.dataframe(df)
65
+
66
+ # Display details of selected run
67
+ if not df.empty:
68
+ selected_run_id = st.selectbox("Select a Run ID to see details", df["ID"].tolist())
69
+ run = fetch_run(api, projects, selected_project, selected_run_id)
70
+
71
+ if run:
72
+ run_df = run.history()
73
+ st.write(f"Details for run: {run.name}")
74
+ st.dataframe(run_df)
75
+ else:
76
+ st.warning("No runs available to select.")
77
+
78
+
79
+
80
+ if option == "Models":
81
+ st.subheader("Model Ranking")
82
+
83
+ # Ensure the DataFrame is not empty
84
+ if not df.empty:
85
+ # Fetch metrics for ranking (e.g., accuracy or loss)
86
+ ranking_data = []
87
+ for index, row in df.iterrows():
88
+ try:
89
+ # Fetch the run details
90
+ run = api.run(f"{projects[selected_project]['entity']}/{projects[selected_project]['project']}/{row['ID']}")
91
+ metrics = run.summary
92
+ model_name = run.config.get("model_name", "Unknown") # Fetch model name from the config, defaulting to "Unknown"
93
+
94
+ ranking_data.append({
95
+ "Model Name": model_name, # Add model name to the table
96
+ "Run Name": row["Run Name"],
97
+ "ID": row["ID"],
98
+ "Accuracy": metrics.get("accuracy"), # Example metric
99
+ "Loss": metrics.get("loss") # Example metric
100
+ })
101
+ except wandb.errors.CommError:
102
+ continue
103
+
104
+ # Convert to DataFrame
105
+ ranking_df = pd.DataFrame(ranking_data)
106
+
107
+ # Rank by Accuracy (or another metric)
108
+ ranking_df = ranking_df.sort_values(by="Accuracy", ascending=False).reset_index(drop=True)
109
+ ranking_df.index += 1 # Start ranking from 1
110
+
111
+ # Display the ranking table
112
+ st.dataframe(ranking_df)
113
+ else:
114
+ st.warning("No runs available for ranking.")