-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_app.py
More file actions
123 lines (123 loc) · 6.93 KB
/
streamlit_app.py
File metadata and controls
123 lines (123 loc) · 6.93 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import streamlit as st
from cryptography.fernet import Fernet
import pickle
import pandas as pd
import os
def load_credentials():
with open("key.key", "rb") as key_file:
key = key_file.read()
cipher_suite = Fernet(key)
with open('credentials_encrypted.pkl', 'rb') as f:
encrypted_credentials = pickle.load(f)
return cipher_suite, encrypted_credentials
def login():
st.sidebar.title("Login")
cipher_suite, credentials = load_credentials()
username = st.sidebar.text_input("Username")
password = st.sidebar.text_input("Password", type='password')
if username and password:
if username in credentials:
decrypted_password = cipher_suite.decrypt(credentials[username].encode()).decode()
if password == decrypted_password:
st.session_state.logged_in = True
st.sidebar.success("Login successful!")
return True
else:
st.sidebar.error("Incorrect password")
else:
st.sidebar.error("Username not found")
return False
BASE_DIR = os.path.dirname(__file__)
DATA_DIR = os.path.join(BASE_DIR, 'Dataset')
def _read_csv(name: str):
return pd.read_csv(os.path.join(DATA_DIR, name))
def main():
st.set_page_config(page_title="LMS Dashboard", layout="wide")
if 'logged_in' not in st.session_state or not st.session_state.logged_in:
if not login():
return
st.title("LMS Dashboard")
assessments_df = _read_csv('assessments.csv')
courses_df = _read_csv('courses.csv')
student_assessment_df = _read_csv('studentAssessment.csv')
student_info_df = _read_csv('studentInfo.csv')
student_registration_df = _read_csv('studentRegistration.csv')
student_vle_df = _read_csv('studentVle.csv')
vle_df = _read_csv('vle.csv')
st.sidebar.title("Navigation")
menu_option = st.sidebar.radio("Go to", ["Student Info", "Assessments", "Courses", "VLE Interactions", "Model Analysis"])
if menu_option == "Student Info":
st.header("Student Information")
student_id = st.selectbox("Select a Student ID to view details:", student_info_df['id_student'].unique())
student_info = student_info_df[student_info_df['id_student'] == student_id]
student_registration = student_registration_df[student_registration_df['id_student'] == student_id]
if not student_info.empty:
st.subheader("Student Profile")
col1, col2 = st.columns([1, 3])
with col1:
st.image("https://i.imgur.com/NPnaIRmb.jpg", caption="Sample Profile Photo", width=150)
with col2:
st.write("### Personal Details")
st.write(f"**Student ID:** {student_info['id_student'].values[0]}")
st.write(f"**Gender:** {student_info['gender'].values[0]}")
st.write(f"**Region:** {student_info['region'].values[0]}")
st.write(f"**Age Band:** {student_info['age_band'].values[0]}")
st.write(f"**IMD Band (Socio-Economic Status):** {student_info['imd_band'].values[0]}")
st.write(f"**Highest Education:** {student_info['highest_education'].values[0]}")
st.write(f"**Disability:** {'Yes' if student_info['disability'].values[0] == 'Y' else 'No'}")
st.subheader("Registration Details")
st.dataframe(student_registration)
else:
st.warning("No data available for the selected student ID.")
elif menu_option == "Assessments":
st.header("Assessments Overview")
st.dataframe(assessments_df.head())
module = st.selectbox("Select a module:", assessments_df['code_module'].unique())
presentation = st.selectbox("Select a presentation:", assessments_df[assessments_df['code_module'] == module]['code_presentation'].unique())
filtered_assessments = assessments_df[(assessments_df['code_module'] == module) & (assessments_df['code_presentation'] == presentation)]
st.subheader(f"Assessments for {module} ({presentation})")
st.dataframe(filtered_assessments)
elif menu_option == "Courses":
st.header("Course Information")
st.dataframe(courses_df)
selected_course = st.selectbox("Choose a course module:", courses_df['code_module'].unique())
course_data = courses_df[courses_df['code_module'] == selected_course]
if not course_data.empty:
st.subheader(f"Course Details: {selected_course}")
st.dataframe(course_data)
elif menu_option == "VLE Interactions":
st.header("VLE (Virtual Learning Environment) Interactions")
vle_student_id = st.selectbox("Select Student ID for VLE data:", student_vle_df['id_student'].unique())
if vle_student_id:
student_vle_data = student_vle_df[student_vle_df['id_student'] == vle_student_id]
if not student_vle_data.empty:
st.subheader(f"VLE Data for Student ID: {vle_student_id}")
st.dataframe(student_vle_data)
vle_clicks_summary = student_vle_data.groupby('code_module')['sum_click'].sum().reset_index()
st.subheader("Total Clicks per Module")
st.bar_chart(vle_clicks_summary.set_index('code_module')['sum_click'])
student_vle_data = student_vle_data.merge(vle_df[['id_site', 'code_module', 'activity_type']], on=['id_site', 'code_module'])
resource_clicks = student_vle_data.groupby('activity_type')['sum_click'].sum().sort_values(ascending=False)
st.subheader("Resource Type Engagement (Click Totals)")
st.bar_chart(resource_clicks)
else:
st.warning("No VLE data found for that student ID.")
st.subheader("Overall VLE Usage")
overall_vle_summary = student_vle_df.groupby('id_site')['sum_click'].sum().reset_index()
top_vle_resources = overall_vle_summary.sort_values(by='sum_click', ascending=False).head(10)
st.subheader("Top VLE Resources by Clicks (Overall)")
st.bar_chart(top_vle_resources.set_index('id_site')['sum_click'])
elif menu_option == "Model Analysis":
st.header("Model Analysis")
st.subheader("Confusion Matrix Analysis")
st.image(os.path.join(BASE_DIR, 'confusion_matrix_analysis.png'), caption="Confusion Matrix Analysis")
st.subheader("Prediction Distribution")
st.image(os.path.join(BASE_DIR, 'prediction_distribution.png'), caption="Prediction Distribution")
st.subheader("Feature Importance")
st.image(os.path.join(BASE_DIR, 'feature_importance.png'), caption="Feature Importance")
st.subheader("Confusion Matrix - Random Forest")
st.image(os.path.join(BASE_DIR, 'confusion_matrix_Random Forest.png'), caption="Confusion Matrix - Random Forest Model")
st.subheader("Confusion Matrix - XGBoost")
st.image(os.path.join(BASE_DIR, 'confusion_matrix_XGBoost.png'), caption="Confusion Matrix - XGBoost Model")
if __name__ == "__main__":
main()