Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,209 +1,49 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
# import streamlit as st
|
| 4 |
-
# import numpy as np
|
| 5 |
-
# import pandas as pd
|
| 6 |
-
|
| 7 |
-
# # -------------------------------
|
| 8 |
-
# # PAGE CONFIG
|
| 9 |
-
# # -------------------------------
|
| 10 |
-
# st.set_page_config(page_title="Smart Study Planner", page_icon="๐", layout="centered")
|
| 11 |
-
|
| 12 |
-
# st.title("๐ Smart Study Planner with Performance Prediction")
|
| 13 |
-
# st.markdown("Track your study progress and predict performance smartly ๐")
|
| 14 |
-
|
| 15 |
-
# # -------------------------------
|
| 16 |
-
# # OOP CLASSES
|
| 17 |
-
# # -------------------------------
|
| 18 |
-
|
| 19 |
-
# class Subject:
|
| 20 |
-
# def __init__(self, name, hours, marks):
|
| 21 |
-
# self.name = name
|
| 22 |
-
# self.hours = hours
|
| 23 |
-
# self.marks = marks
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
# class Student:
|
| 27 |
-
# def __init__(self, name):
|
| 28 |
-
# self.name = name
|
| 29 |
-
# self.subjects = []
|
| 30 |
-
|
| 31 |
-
# def add_subject(self, subject):
|
| 32 |
-
# self.subjects.append(subject)
|
| 33 |
-
|
| 34 |
-
# def get_dataframe(self):
|
| 35 |
-
# return pd.DataFrame({
|
| 36 |
-
# "Subject": [s.name for s in self.subjects],
|
| 37 |
-
# "Study Hours": [s.hours for s in self.subjects],
|
| 38 |
-
# "Marks": [s.marks for s in self.subjects]
|
| 39 |
-
# })
|
| 40 |
-
|
| 41 |
-
# def calculate_average(self):
|
| 42 |
-
# marks = [s.marks for s in self.subjects]
|
| 43 |
-
# return np.mean(marks) if marks else 0
|
| 44 |
-
|
| 45 |
-
# def get_max_min(self):
|
| 46 |
-
# marks = [s.marks for s in self.subjects]
|
| 47 |
-
# return np.max(marks), np.min(marks)
|
| 48 |
-
|
| 49 |
-
# def performance_trend(self):
|
| 50 |
-
# hours = [s.hours for s in self.subjects]
|
| 51 |
-
# marks = [s.marks for s in self.subjects]
|
| 52 |
-
|
| 53 |
-
# if len(hours) > 1:
|
| 54 |
-
# return np.corrcoef(hours, marks)[0][1]
|
| 55 |
-
# return 0
|
| 56 |
-
|
| 57 |
-
# def predict_performance(self):
|
| 58 |
-
# trend = self.performance_trend()
|
| 59 |
-
# predicted = []
|
| 60 |
-
|
| 61 |
-
# for s in self.subjects:
|
| 62 |
-
# boost = (2 * 4) + (trend * 5) # smart logic
|
| 63 |
-
# predicted.append(min(s.marks + boost, 100))
|
| 64 |
-
|
| 65 |
-
# return np.mean(predicted) if predicted else 0
|
| 66 |
-
|
| 67 |
-
# def get_grade(self, marks):
|
| 68 |
-
# if marks >= 85:
|
| 69 |
-
# return "A"
|
| 70 |
-
# elif marks >= 70:
|
| 71 |
-
# return "B"
|
| 72 |
-
# elif marks >= 55:
|
| 73 |
-
# return "C"
|
| 74 |
-
# elif marks >= 40:
|
| 75 |
-
# return "D"
|
| 76 |
-
# return "F"
|
| 77 |
-
|
| 78 |
-
# def best_subject(self):
|
| 79 |
-
# return max(self.subjects, key=lambda x: x.marks).name
|
| 80 |
-
|
| 81 |
-
# def weak_subject(self):
|
| 82 |
-
# return min(self.subjects, key=lambda x: x.marks).name
|
| 83 |
-
|
| 84 |
-
# def suggest_improvement(self):
|
| 85 |
-
# return f"Focus more on {self.weak_subject()} and increase study time by 2 hours."
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
# # -------------------------------
|
| 89 |
-
# # SESSION STATE FIX (IMPORTANT)
|
| 90 |
-
# # -------------------------------
|
| 91 |
-
|
| 92 |
-
# if "student" not in st.session_state:
|
| 93 |
-
# st.session_state.student = None
|
| 94 |
-
|
| 95 |
-
# if "student_name" not in st.session_state:
|
| 96 |
-
# st.session_state.student_name = ""
|
| 97 |
-
|
| 98 |
-
# # -------------------------------
|
| 99 |
-
# # INPUT UI
|
| 100 |
-
# # -------------------------------
|
| 101 |
-
|
| 102 |
-
# st.subheader("๐ค Student Information")
|
| 103 |
-
|
| 104 |
-
# name = st.text_input("Enter Student Name", value=st.session_state.student_name)
|
| 105 |
-
|
| 106 |
-
# if name:
|
| 107 |
-
# st.session_state.student_name = name
|
| 108 |
-
|
| 109 |
-
# # FIX: only create once
|
| 110 |
-
# if st.session_state.student is None:
|
| 111 |
-
# st.session_state.student = Student(name)
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
# st.subheader("๐ Add Subject")
|
| 115 |
-
|
| 116 |
-
# col1, col2, col3 = st.columns(3)
|
| 117 |
-
|
| 118 |
-
# with col1:
|
| 119 |
-
# subject_name = st.text_input("Subject")
|
| 120 |
-
|
| 121 |
-
# with col2:
|
| 122 |
-
# hours = st.number_input("Study Hours", min_value=0.0, step=0.5)
|
| 123 |
-
|
| 124 |
-
# with col3:
|
| 125 |
-
# marks = st.number_input("Marks", min_value=0, max_value=100)
|
| 126 |
-
|
| 127 |
-
# # -------------------------------
|
| 128 |
-
# # ADD SUBJECT
|
| 129 |
-
# # -------------------------------
|
| 130 |
-
|
| 131 |
-
# if st.button("โ Add Subject"):
|
| 132 |
-
# if not subject_name:
|
| 133 |
-
# st.error("Please enter subject name")
|
| 134 |
-
# elif st.session_state.student is None:
|
| 135 |
-
# st.error("Please enter student name first")
|
| 136 |
-
# else:
|
| 137 |
-
# sub = Subject(subject_name, hours, marks)
|
| 138 |
-
# st.session_state.student.add_subject(sub)
|
| 139 |
-
# st.success(f"{subject_name} added successfully!")
|
| 140 |
-
|
| 141 |
-
# # -------------------------------
|
| 142 |
-
# # ANALYSIS
|
| 143 |
-
# # -------------------------------
|
| 144 |
-
|
| 145 |
-
# st.markdown("---")
|
| 146 |
-
|
| 147 |
-
# if st.button("๐ Analyze Performance"):
|
| 148 |
-
|
| 149 |
-
# student = st.session_state.student
|
| 150 |
-
|
| 151 |
-
# if student is None or len(student.subjects) == 0:
|
| 152 |
-
# st.error("Please add subjects first!")
|
| 153 |
-
# else:
|
| 154 |
-
# df = student.get_dataframe()
|
| 155 |
-
|
| 156 |
-
# st.subheader("๐ Performance Table")
|
| 157 |
-
# st.dataframe(df, use_container_width=True)
|
| 158 |
-
|
| 159 |
-
# avg = student.calculate_average()
|
| 160 |
-
# max_m, min_m = student.get_max_min()
|
| 161 |
-
# grade = student.get_grade(avg)
|
| 162 |
-
# predicted = student.predict_performance()
|
| 163 |
-
# predicted_grade = student.get_grade(predicted)
|
| 164 |
-
|
| 165 |
-
# # ---------------- METRICS ----------------
|
| 166 |
-
# col1, col2, col3 = st.columns(3)
|
| 167 |
-
|
| 168 |
-
# col1.metric("Average Marks", f"{avg:.2f}")
|
| 169 |
-
# col2.metric("Highest Marks", max_m)
|
| 170 |
-
# col3.metric("Lowest Marks", min_m)
|
| 171 |
-
|
| 172 |
-
# # ---------------- PROGRESS BAR ----------------
|
| 173 |
-
# st.subheader("๐ Performance Progress")
|
| 174 |
-
# st.progress(int(avg))
|
| 175 |
-
|
| 176 |
-
# st.write(f"๐ฏ Current Grade: **{grade}**")
|
| 177 |
-
|
| 178 |
-
# # ---------------- PREDICTION ----------------
|
| 179 |
-
# st.subheader("๐ฎ Smart Prediction")
|
| 180 |
-
|
| 181 |
-
# st.success(f"Expected Marks (if improved): {predicted:.2f}")
|
| 182 |
-
# st.success(f"Predicted Grade: {predicted_grade}")
|
| 183 |
-
|
| 184 |
-
# # ---------------- INSIGHTS ----------------
|
| 185 |
-
# st.subheader("๐ Insights")
|
| 186 |
-
|
| 187 |
-
# st.write(f"๐ Best Subject: **{student.best_subject()}**")
|
| 188 |
-
# st.write(f"โ Weak Subject: **{student.weak_subject()}**")
|
| 189 |
-
|
| 190 |
-
# st.info(student.suggest_improvement())
|
| 191 |
-
|
| 192 |
-
# # ---------------- CHART ----------------
|
| 193 |
-
# st.subheader("๐ Study vs Performance Trend")
|
| 194 |
-
# st.line_chart(df.set_index("Subject"))
|
| 195 |
-
# Smart Study Planner - FINAL VERSION
|
| 196 |
-
# Smart Study Planner - FINAL STABLE VERSION
|
| 197 |
-
|
| 198 |
-
import streamlit as st
|
| 199 |
import numpy as np
|
| 200 |
import pandas as pd
|
| 201 |
-
|
| 202 |
# -------------------------------
|
| 203 |
# PAGE CONFIG
|
| 204 |
# -------------------------------
|
| 205 |
st.set_page_config(page_title="Smart Study Planner", page_icon="๐", layout="centered")
|
| 206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
st.title("๐ Smart Study Planner with Smart Prediction")
|
| 208 |
st.markdown("Analyze your study habits and improve performance ๐")
|
| 209 |
|
|
|
|
| 1 |
+
mport streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
import pandas as pd
|
|
|
|
| 4 |
# -------------------------------
|
| 5 |
# PAGE CONFIG
|
| 6 |
# -------------------------------
|
| 7 |
st.set_page_config(page_title="Smart Study Planner", page_icon="๐", layout="centered")
|
| 8 |
|
| 9 |
+
# -------------------------------
|
| 10 |
+
# CUSTOM CSS (UI DESIGN)
|
| 11 |
+
# -------------------------------
|
| 12 |
+
st.markdown("""
|
| 13 |
+
<style>
|
| 14 |
+
/* Background */
|
| 15 |
+
.stApp {
|
| 16 |
+
background: linear-gradient(to right, #e0f7fa, #e1bee7);
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/* Headings */
|
| 20 |
+
h1, h2, h3 {
|
| 21 |
+
color: #4b0082;
|
| 22 |
+
text-align: center;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/* Buttons */
|
| 26 |
+
.stButton>button {
|
| 27 |
+
background-color: #6c63ff;
|
| 28 |
+
color: white;
|
| 29 |
+
border-radius: 10px;
|
| 30 |
+
height: 3em;
|
| 31 |
+
width: 100%;
|
| 32 |
+
font-size: 16px;
|
| 33 |
+
font-weight: bold;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/* Dataframe */
|
| 37 |
+
.css-1d391kg {
|
| 38 |
+
border-radius: 10px;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/* Input boxes */
|
| 42 |
+
input {
|
| 43 |
+
border-radius: 8px !important;
|
| 44 |
+
}
|
| 45 |
+
</style>
|
| 46 |
+
""", unsafe_allow_html=True)
|
| 47 |
st.title("๐ Smart Study Planner with Smart Prediction")
|
| 48 |
st.markdown("Analyze your study habits and improve performance ๐")
|
| 49 |
|