File size: 3,456 Bytes
3f8e57d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import streamlit as st
import pandas as pd

# Load Hackathon and Team Data
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
if "Prize Pool" in df_hackathons.columns:
    df_hackathons.drop(columns=["Prize Pool"], inplace=True)  # Remove Prize Pool Column

# 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")
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 (Keep only this)
sort_option = st.sidebar.selectbox("Sort Hackathons By:", ["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):
    recommendations = []
    for _, row in df_hackathons.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 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"],
                "Registration Deadline": row["Registration Deadline"].strftime('%Y-%m-%d'),
            })

    # Sorting by Registration Deadline
    recommendations.sort(key=lambda x: x["Registration Deadline"])

    return pd.DataFrame(recommendations).head(10)  # Show only top 10 results

# Display Recommendations
if unique_skills:
    recommendations_df = recommend_hackathons(unique_skills)
    if not recommendations_df.empty:
        st.success(f"### โœ… Recommended Hackathons for **{selected_team}**")
        st.dataframe(recommendations_df)
    else:
        st.warning("โš ๏ธ No matching hackathons found.")
else:
    st.warning("โš ๏ธ No skills found for this team.")

st.markdown("---")
st.write("๐ŸŽฏ **Built with Streamlit | AI-Powered Hackathon Finder**")