File size: 4,542 Bytes
f72feab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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**")