Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
|
| 2 |
import gradio as gr
|
| 3 |
import pandas as pd
|
| 4 |
-
import numpy as np
|
| 5 |
|
| 6 |
# Sample data: Courses and categories
|
| 7 |
courses = pd.DataFrame({
|
|
@@ -17,21 +16,23 @@ courses = pd.DataFrame({
|
|
| 17 |
]
|
| 18 |
})
|
| 19 |
|
| 20 |
-
#
|
| 21 |
def recommend_courses(favorite_subject):
|
| 22 |
-
|
| 23 |
-
recommended = courses[courses["Category"].str.contains(favorite_subject, case=False)]
|
| 24 |
if recommended.empty:
|
| 25 |
return "No courses found for this subject."
|
| 26 |
-
return recommended["Course"].tolist()
|
| 27 |
|
| 28 |
-
# Gradio interface
|
| 29 |
iface = gr.Interface(
|
| 30 |
fn=recommend_courses,
|
| 31 |
-
inputs=gr.
|
|
|
|
|
|
|
|
|
|
| 32 |
outputs=gr.Textbox(label="Recommended Courses"),
|
| 33 |
title="University Course Recommendation System",
|
| 34 |
-
description="
|
| 35 |
)
|
| 36 |
|
| 37 |
# Launch the app
|
|
|
|
| 1 |
|
| 2 |
import gradio as gr
|
| 3 |
import pandas as pd
|
|
|
|
| 4 |
|
| 5 |
# Sample data: Courses and categories
|
| 6 |
courses = pd.DataFrame({
|
|
|
|
| 16 |
]
|
| 17 |
})
|
| 18 |
|
| 19 |
+
# Function to recommend courses based on subject
|
| 20 |
def recommend_courses(favorite_subject):
|
| 21 |
+
recommended = courses[courses["Category"] == favorite_subject]
|
|
|
|
| 22 |
if recommended.empty:
|
| 23 |
return "No courses found for this subject."
|
| 24 |
+
return "\n".join(recommended["Course"].tolist())
|
| 25 |
|
| 26 |
+
# Gradio interface with dropdown menu
|
| 27 |
iface = gr.Interface(
|
| 28 |
fn=recommend_courses,
|
| 29 |
+
inputs=gr.Dropdown(
|
| 30 |
+
choices=["Mathematics", "Physics", "Computer Science", "Chemistry"],
|
| 31 |
+
label="Select your favorite subject"
|
| 32 |
+
),
|
| 33 |
outputs=gr.Textbox(label="Recommended Courses"),
|
| 34 |
title="University Course Recommendation System",
|
| 35 |
+
description="Select your favorite subject to get course recommendations!"
|
| 36 |
)
|
| 37 |
|
| 38 |
# Launch the app
|