import streamlit as st import pandas as pd # Load Hackathon and Team Data from CSV hackathon_csv = "Hackathon_Dataset.csv" team_csv = "Team_Dataset.csv" df_hackathons = pd.read_csv(hackathon_csv) df_teams = pd.read_csv(team_csv) # Convert Event Date and Registration Deadline to datetime df_hackathons["Event Date"] = pd.to_datetime(df_hackathons["Event Date"], errors='coerce') df_hackathons["Registration Deadline"] = pd.to_datetime(df_hackathons["Registration Deadline"], errors='coerce') # Ensure numerical columns are correctly formatted df_hackathons["Prize Pool"] = pd.to_numeric(df_hackathons["Prize Pool"], errors='coerce') # Get unique team names team_list = df_teams["Team Name"].unique() # Streamlit UI Setup st.set_page_config(page_title="Hackathon Finder", layout="wide") # Sidebar - Filters st.sidebar.header("🔍 Filter Hackathons") difficulty = st.sidebar.selectbox("Select Difficulty", ["All"] + df_hackathons["Difficulty Level"].dropna().unique().tolist()) mode = st.sidebar.selectbox("Select Mode", ["All", "Online", "Offline"]) date_range = st.sidebar.slider("Select Event Date Range", min_value=df_hackathons["Event Date"].min().date(), max_value=df_hackathons["Event Date"].max().date(), value=(df_hackathons["Event Date"].min().date(), df_hackathons["Event Date"].max().date())) # Sorting Option sort_option = st.sidebar.selectbox("Sort Hackathons By:", ["Prize Pool (High to Low)", "Registration Deadline (Soonest First)"]) # Team Selection st.title("🚀 Hackathon Recommendation System") st.write("**Select your team to find the best hackathons for you!**") selected_team = st.selectbox("Select Team:", team_list) # Fetch Skills of Selected Team team_skills = df_teams[df_teams["Team Name"] == selected_team]["Skills"].tolist() unique_skills = list(set(skill.strip() for sublist in team_skills for skill in sublist.split(","))) # Function to Recommend Hackathons def recommend_hackathons(skills, hackathon_data, difficulty, mode, date_range, sort_option): recommendations = [] for _, row in hackathon_data.iterrows(): required_skills = row["Required Skills"].split(",") required_skills = [skill.strip().title() for skill in required_skills] matched_skills = [skill for skill in skills if skill in required_skills] if matched_skills: # Apply Filters if difficulty != "All" and row["Difficulty Level"] != difficulty: continue if mode != "All" and row["Mode"] != mode: continue if not (date_range[0] <= row["Event Date"].date() <= date_range[1]): continue recommendations.append({ "Hackathon Name": row["Hackathon Name"], "Organizer": row["Organizer"], "Prize Pool ($)": f"${row['Prize Pool']:,.0f}", "Registration Deadline": row["Registration Deadline"].strftime('%Y-%m-%d'), "Matched Skills": len(matched_skills) # Used for sorting but not displayed }) # Sorting by Matched Skills (Highest First) recommendations.sort(key=lambda x: x["Matched Skills"], reverse=True) # Apply additional sorting if needed if sort_option == "Prize Pool (High to Low)": recommendations.sort(key=lambda x: float(x["Prize Pool ($)"].replace("$", "").replace(",", "")), reverse=True) elif sort_option == "Registration Deadline (Soonest First)": recommendations.sort(key=lambda x: x["Registration Deadline"]) # Convert to DataFrame and Remove Matched Skills Column df_recommendations = pd.DataFrame(recommendations).drop(columns=["Matched Skills"]) # Show only the top 10 hackathons return df_recommendations.head(10) # Display Recommendations as Table if unique_skills: recommendations_df = recommend_hackathons(unique_skills, df_hackathons, difficulty, mode, date_range, sort_option) if not recommendations_df.empty: st.success(f"### ✅ Recommended Hackathons for **{selected_team}**") st.dataframe(recommendations_df) else: st.warning("⚠️ No matching hackathons found. Try different filters.") else: st.warning("⚠️ No skills found for this team.") # Footer st.markdown("---") st.write("🎯 **Built with Streamlit | AI-Powered Hackathon Finder**")