Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
# Load Hackathon and Team Data from CSV
|
| 5 |
+
hackathon_csv = "Hackathon_Dataset.csv"
|
| 6 |
+
team_csv = "Team_Dataset.csv"
|
| 7 |
+
|
| 8 |
+
df_hackathons = pd.read_csv(hackathon_csv)
|
| 9 |
+
df_teams = pd.read_csv(team_csv)
|
| 10 |
+
|
| 11 |
+
# Convert Event Date and Registration Deadline to datetime
|
| 12 |
+
df_hackathons["Event Date"] = pd.to_datetime(df_hackathons["Event Date"], errors='coerce')
|
| 13 |
+
df_hackathons["Registration Deadline"] = pd.to_datetime(df_hackathons["Registration Deadline"], errors='coerce')
|
| 14 |
+
|
| 15 |
+
# Ensure numerical columns are correctly formatted
|
| 16 |
+
df_hackathons["Prize Pool"] = pd.to_numeric(df_hackathons["Prize Pool"], errors='coerce')
|
| 17 |
+
|
| 18 |
+
# Get unique team names
|
| 19 |
+
team_list = df_teams["Team Name"].unique()
|
| 20 |
+
|
| 21 |
+
# Streamlit UI Setup
|
| 22 |
+
st.set_page_config(page_title="Hackathon Finder", layout="wide")
|
| 23 |
+
|
| 24 |
+
# Sidebar - Filters
|
| 25 |
+
st.sidebar.header("🔍 Filter Hackathons")
|
| 26 |
+
difficulty = st.sidebar.selectbox("Select Difficulty", ["All"] + df_hackathons["Difficulty Level"].dropna().unique().tolist())
|
| 27 |
+
mode = st.sidebar.selectbox("Select Mode", ["All", "Online", "Offline"])
|
| 28 |
+
date_range = st.sidebar.slider("Select Event Date Range",
|
| 29 |
+
min_value=df_hackathons["Event Date"].min().date(),
|
| 30 |
+
max_value=df_hackathons["Event Date"].max().date(),
|
| 31 |
+
value=(df_hackathons["Event Date"].min().date(), df_hackathons["Event Date"].max().date()))
|
| 32 |
+
|
| 33 |
+
# Sorting Option
|
| 34 |
+
sort_option = st.sidebar.selectbox("Sort Hackathons By:",
|
| 35 |
+
["Prize Pool (High to Low)", "Registration Deadline (Soonest First)"])
|
| 36 |
+
|
| 37 |
+
# Team Selection
|
| 38 |
+
st.title("🚀 Hackathon Recommendation System")
|
| 39 |
+
st.write("**Select your team to find the best hackathons for you!**")
|
| 40 |
+
selected_team = st.selectbox("Select Team:", team_list)
|
| 41 |
+
|
| 42 |
+
# Fetch Skills of Selected Team
|
| 43 |
+
team_skills = df_teams[df_teams["Team Name"] == selected_team]["Skills"].tolist()
|
| 44 |
+
unique_skills = list(set(skill.strip() for sublist in team_skills for skill in sublist.split(",")))
|
| 45 |
+
|
| 46 |
+
# Function to Recommend Hackathons
|
| 47 |
+
def recommend_hackathons(skills, hackathon_data, difficulty, mode, date_range, sort_option):
|
| 48 |
+
recommendations = []
|
| 49 |
+
for _, row in hackathon_data.iterrows():
|
| 50 |
+
required_skills = row["Required Skills"].split(",")
|
| 51 |
+
required_skills = [skill.strip().title() for skill in required_skills]
|
| 52 |
+
|
| 53 |
+
matched_skills = [skill for skill in skills if skill in required_skills]
|
| 54 |
+
if matched_skills:
|
| 55 |
+
# Apply Filters
|
| 56 |
+
if difficulty != "All" and row["Difficulty Level"] != difficulty:
|
| 57 |
+
continue
|
| 58 |
+
if mode != "All" and row["Mode"] != mode:
|
| 59 |
+
continue
|
| 60 |
+
if not (date_range[0] <= row["Event Date"].date() <= date_range[1]):
|
| 61 |
+
continue
|
| 62 |
+
|
| 63 |
+
recommendations.append({
|
| 64 |
+
"Hackathon Name": row["Hackathon Name"],
|
| 65 |
+
"Organizer": row["Organizer"],
|
| 66 |
+
"Prize Pool ($)": f"${row['Prize Pool']:,.0f}",
|
| 67 |
+
"Registration Deadline": row["Registration Deadline"].strftime('%Y-%m-%d'),
|
| 68 |
+
"Matched Skills": len(matched_skills) # Used for sorting but not displayed
|
| 69 |
+
})
|
| 70 |
+
|
| 71 |
+
# Sorting by Matched Skills (Highest First)
|
| 72 |
+
recommendations.sort(key=lambda x: x["Matched Skills"], reverse=True)
|
| 73 |
+
|
| 74 |
+
# Apply additional sorting if needed
|
| 75 |
+
if sort_option == "Prize Pool (High to Low)":
|
| 76 |
+
recommendations.sort(key=lambda x: float(x["Prize Pool ($)"].replace("$", "").replace(",", "")), reverse=True)
|
| 77 |
+
elif sort_option == "Registration Deadline (Soonest First)":
|
| 78 |
+
recommendations.sort(key=lambda x: x["Registration Deadline"])
|
| 79 |
+
|
| 80 |
+
# Convert to DataFrame and Remove Matched Skills Column
|
| 81 |
+
df_recommendations = pd.DataFrame(recommendations).drop(columns=["Matched Skills"])
|
| 82 |
+
|
| 83 |
+
# Show only the top 10 hackathons
|
| 84 |
+
return df_recommendations.head(10)
|
| 85 |
+
|
| 86 |
+
# Display Recommendations as Table
|
| 87 |
+
if unique_skills:
|
| 88 |
+
recommendations_df = recommend_hackathons(unique_skills, df_hackathons, difficulty, mode, date_range, sort_option)
|
| 89 |
+
if not recommendations_df.empty:
|
| 90 |
+
st.success(f"### ✅ Recommended Hackathons for **{selected_team}**")
|
| 91 |
+
st.dataframe(recommendations_df)
|
| 92 |
+
else:
|
| 93 |
+
st.warning("⚠️ No matching hackathons found. Try different filters.")
|
| 94 |
+
else:
|
| 95 |
+
st.warning("⚠️ No skills found for this team.")
|
| 96 |
+
|
| 97 |
+
# Footer
|
| 98 |
+
st.markdown("---")
|
| 99 |
+
st.write("🎯 **Built with Streamlit | AI-Powered Hackathon Finder**")
|