Update main.py
Browse files
main.py
CHANGED
|
@@ -1,8 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from app_config import AppConfig
|
| 3 |
-
from data_processor import DataProcessor
|
| 4 |
-
from visualization import Visualization
|
| 5 |
-
from ai_analysis import AIAnalysis
|
| 6 |
from sidebar import Sidebar # Import the Sidebar class
|
| 7 |
|
| 8 |
def main():
|
|
@@ -11,7 +101,7 @@ def main():
|
|
| 11 |
|
| 12 |
# Initialize the sidebar
|
| 13 |
sidebar = Sidebar()
|
| 14 |
-
sidebar.display()
|
| 15 |
|
| 16 |
# Initialize the data processor
|
| 17 |
data_processor = DataProcessor()
|
|
@@ -67,6 +157,18 @@ def main():
|
|
| 67 |
student_metrics_fig = visualization.plot_student_metrics(student_metrics_df, attendance_avg_stats, engagement_avg_stats)
|
| 68 |
visualization.download_chart(student_metrics_fig, "student_metrics_chart.png")
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
# Prepare input for the language model
|
| 71 |
llm_input = ai_analysis.prepare_llm_input(student_metrics_df)
|
| 72 |
|
|
@@ -81,7 +183,7 @@ def main():
|
|
| 81 |
ai_analysis.download_llm_output(recommendations, "llm_output.txt")
|
| 82 |
|
| 83 |
except Exception as e:
|
| 84 |
-
st.error(f"Error
|
| 85 |
|
| 86 |
if __name__ == '__main__':
|
| 87 |
main()
|
|
|
|
| 1 |
+
# import streamlit as st
|
| 2 |
+
# from app_config import AppConfig # Import the configerations class
|
| 3 |
+
# from data_processor import DataProcessor # Import the data analysis class
|
| 4 |
+
# from visualization import Visualization # Import the data viz class
|
| 5 |
+
# from ai_analysis import AIAnalysis # Import the ai analysis class
|
| 6 |
+
# from sidebar import Sidebar # Import the Sidebar class
|
| 7 |
+
|
| 8 |
+
# def main():
|
| 9 |
+
# # Initialize the app configuration
|
| 10 |
+
# app_config = AppConfig()
|
| 11 |
+
|
| 12 |
+
# # Initialize the sidebar
|
| 13 |
+
# sidebar = Sidebar()
|
| 14 |
+
# sidebar.display()
|
| 15 |
+
|
| 16 |
+
# # Initialize the data processor
|
| 17 |
+
# data_processor = DataProcessor()
|
| 18 |
+
|
| 19 |
+
# # Initialize the visualization handler
|
| 20 |
+
# visualization = Visualization()
|
| 21 |
+
|
| 22 |
+
# # Initialize the AI analysis handler
|
| 23 |
+
# ai_analysis = AIAnalysis(data_processor.client)
|
| 24 |
+
|
| 25 |
+
# st.title("Intervention Program Analysis")
|
| 26 |
+
|
| 27 |
+
# # File uploader
|
| 28 |
+
# uploaded_file = st.file_uploader("Upload your Excel file", type=["xlsx"])
|
| 29 |
+
|
| 30 |
+
# if uploaded_file is not None:
|
| 31 |
+
# try:
|
| 32 |
+
# # Read the Excel file into a DataFrame
|
| 33 |
+
# df = data_processor.read_excel(uploaded_file)
|
| 34 |
+
|
| 35 |
+
# # Format the session data
|
| 36 |
+
# df = data_processor.format_session_data(df)
|
| 37 |
+
|
| 38 |
+
# # Replace student names with initials
|
| 39 |
+
# df = data_processor.replace_student_names_with_initials(df)
|
| 40 |
+
|
| 41 |
+
# st.subheader("Uploaded Data")
|
| 42 |
+
# st.write(df)
|
| 43 |
+
|
| 44 |
+
# # Ensure expected column is available
|
| 45 |
+
# if DataProcessor.INTERVENTION_COLUMN not in df.columns:
|
| 46 |
+
# st.error(f"Expected column '{DataProcessor.INTERVENTION_COLUMN}' not found.")
|
| 47 |
+
# return
|
| 48 |
+
|
| 49 |
+
# # Compute Intervention Session Statistics
|
| 50 |
+
# intervention_stats = data_processor.compute_intervention_statistics(df)
|
| 51 |
+
# st.subheader("Intervention Session Statistics")
|
| 52 |
+
# st.write(intervention_stats)
|
| 53 |
+
|
| 54 |
+
# # Plot and download intervention statistics
|
| 55 |
+
# intervention_fig = visualization.plot_intervention_statistics(intervention_stats)
|
| 56 |
+
# visualization.download_chart(intervention_fig, "intervention_statistics_chart.png")
|
| 57 |
+
|
| 58 |
+
# # Compute Student Metrics
|
| 59 |
+
# student_metrics_df = data_processor.compute_student_metrics(df)
|
| 60 |
+
# st.subheader("Student Metrics")
|
| 61 |
+
# st.write(student_metrics_df)
|
| 62 |
+
|
| 63 |
+
# # Compute Student Metric Averages
|
| 64 |
+
# attendance_avg_stats, engagement_avg_stats = data_processor.compute_average_metrics(student_metrics_df)
|
| 65 |
+
|
| 66 |
+
# # Plot and download student metrics
|
| 67 |
+
# student_metrics_fig = visualization.plot_student_metrics(student_metrics_df, attendance_avg_stats, engagement_avg_stats)
|
| 68 |
+
# visualization.download_chart(student_metrics_fig, "student_metrics_chart.png")
|
| 69 |
+
|
| 70 |
+
# # Prepare input for the language model
|
| 71 |
+
# llm_input = ai_analysis.prepare_llm_input(student_metrics_df)
|
| 72 |
+
|
| 73 |
+
# # Generate Notes and Recommendations using Hugging Face LLM
|
| 74 |
+
# with st.spinner("Generating AI analysis..."):
|
| 75 |
+
# recommendations = ai_analysis.prompt_response_from_hf_llm(llm_input)
|
| 76 |
+
|
| 77 |
+
# st.subheader("AI Analysis")
|
| 78 |
+
# st.markdown(recommendations)
|
| 79 |
+
|
| 80 |
+
# # Download AI output
|
| 81 |
+
# ai_analysis.download_llm_output(recommendations, "llm_output.txt")
|
| 82 |
+
|
| 83 |
+
# except Exception as e:
|
| 84 |
+
# st.error(f"Error reading the file: {str(e)}")
|
| 85 |
+
|
| 86 |
+
# if __name__ == '__main__':
|
| 87 |
+
# main()
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
|
| 91 |
import streamlit as st
|
| 92 |
+
from app_config import AppConfig # Import the configurations class
|
| 93 |
+
from data_processor import DataProcessor # Import the data analysis class
|
| 94 |
+
from visualization import Visualization # Import the data viz class
|
| 95 |
+
from ai_analysis import AIAnalysis # Import the ai analysis class
|
| 96 |
from sidebar import Sidebar # Import the Sidebar class
|
| 97 |
|
| 98 |
def main():
|
|
|
|
| 101 |
|
| 102 |
# Initialize the sidebar
|
| 103 |
sidebar = Sidebar()
|
| 104 |
+
sidebar.display()
|
| 105 |
|
| 106 |
# Initialize the data processor
|
| 107 |
data_processor = DataProcessor()
|
|
|
|
| 157 |
student_metrics_fig = visualization.plot_student_metrics(student_metrics_df, attendance_avg_stats, engagement_avg_stats)
|
| 158 |
visualization.download_chart(student_metrics_fig, "student_metrics_chart.png")
|
| 159 |
|
| 160 |
+
# Evaluate each student and build decision tree diagrams
|
| 161 |
+
student_metrics_df['Evaluation'] = student_metrics_df.apply(
|
| 162 |
+
lambda row: data_processor.evaluate_student(row), axis=1
|
| 163 |
+
)
|
| 164 |
+
st.subheader("Student Evaluations")
|
| 165 |
+
st.write(student_metrics_df[['Student', 'Evaluation']])
|
| 166 |
+
|
| 167 |
+
# Build and display decision tree diagrams for each student
|
| 168 |
+
for index, row in student_metrics_df.iterrows():
|
| 169 |
+
tree_diagram = data_processor.build_tree_diagram(row)
|
| 170 |
+
st.graphviz_chart(tree_diagram.source)
|
| 171 |
+
|
| 172 |
# Prepare input for the language model
|
| 173 |
llm_input = ai_analysis.prepare_llm_input(student_metrics_df)
|
| 174 |
|
|
|
|
| 183 |
ai_analysis.download_llm_output(recommendations, "llm_output.txt")
|
| 184 |
|
| 185 |
except Exception as e:
|
| 186 |
+
st.error(f"Error processing the file: {str(e)}")
|
| 187 |
|
| 188 |
if __name__ == '__main__':
|
| 189 |
main()
|