|  | import streamlit as st | 
					
						
						|  | from app_config import AppConfig | 
					
						
						|  | from data_processor import DataProcessor | 
					
						
						|  | from visualization import Visualization | 
					
						
						|  | from ai_analysis import AIAnalysis | 
					
						
						|  | from sidebar import Sidebar | 
					
						
						|  |  | 
					
						
						|  | def main(): | 
					
						
						|  |  | 
					
						
						|  | app_config = AppConfig() | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | sidebar = Sidebar() | 
					
						
						|  | sidebar.display() | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | data_processor = DataProcessor() | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | visualization = Visualization() | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | ai_analysis = AIAnalysis(data_processor.client) | 
					
						
						|  |  | 
					
						
						|  | st.title("Intervention Program Analysis") | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | uploaded_file = st.file_uploader("Upload your Excel file", type=["xlsx"]) | 
					
						
						|  |  | 
					
						
						|  | if uploaded_file is not None: | 
					
						
						|  | try: | 
					
						
						|  |  | 
					
						
						|  | df = data_processor.read_excel(uploaded_file) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | df = data_processor.format_session_data(df) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | df = data_processor.replace_student_names_with_initials(df) | 
					
						
						|  |  | 
					
						
						|  | st.subheader("Uploaded Data") | 
					
						
						|  | st.write(df) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | if DataProcessor.INTERVENTION_COLUMN not in df.columns: | 
					
						
						|  | st.error(f"Expected column '{DataProcessor.INTERVENTION_COLUMN}' not found.") | 
					
						
						|  | return | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | intervention_stats = data_processor.compute_intervention_statistics(df) | 
					
						
						|  | st.subheader("Intervention Session Statistics") | 
					
						
						|  | st.write(intervention_stats) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | col1, col2 = st.columns([3, 1]) | 
					
						
						|  |  | 
					
						
						|  | with col1: | 
					
						
						|  | intervention_fig = visualization.plot_intervention_statistics(intervention_stats) | 
					
						
						|  |  | 
					
						
						|  | with col2: | 
					
						
						|  | intervention_frequency = intervention_stats['Intervention Frequency (%)'].values[0] | 
					
						
						|  |  | 
					
						
						|  | st.markdown("<h3 style='color: #358E66;'>Intervention Frequency</h3>", unsafe_allow_html=True) | 
					
						
						|  |  | 
					
						
						|  | st.markdown(f"<h1 style='color: #358E66;'>{intervention_frequency}%</h1>", unsafe_allow_html=True) | 
					
						
						|  |  | 
					
						
						|  | visualization.download_chart(intervention_fig, "intervention_statistics_chart.png") | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | student_metrics_df = data_processor.compute_student_metrics(df) | 
					
						
						|  | st.subheader("Student Metrics") | 
					
						
						|  | st.write(student_metrics_df) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | attendance_avg_stats, engagement_avg_stats = data_processor.compute_average_metrics(student_metrics_df) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | student_metrics_fig = visualization.plot_student_metrics(student_metrics_df, attendance_avg_stats, engagement_avg_stats) | 
					
						
						|  | visualization.download_chart(student_metrics_fig, "student_metrics_chart.png") | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | student_metrics_df['Evaluation'] = student_metrics_df.apply( | 
					
						
						|  | lambda row: data_processor.evaluate_student(row), axis=1 | 
					
						
						|  | ) | 
					
						
						|  | st.subheader("Student Evaluations") | 
					
						
						|  | st.write(student_metrics_df[['Student', 'Evaluation']]) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | for index, row in student_metrics_df.iterrows(): | 
					
						
						|  | tree_diagram = visualization.build_tree_diagram(row) | 
					
						
						|  | st.graphviz_chart(tree_diagram.source) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | llm_input = ai_analysis.prepare_llm_input(student_metrics_df) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | with st.spinner("Generating AI analysis..."): | 
					
						
						|  | recommendations = ai_analysis.prompt_response_from_hf_llm(llm_input) | 
					
						
						|  |  | 
					
						
						|  | st.subheader("AI Analysis") | 
					
						
						|  | st.markdown(recommendations) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | ai_analysis.download_llm_output(recommendations, "llm_output.txt") | 
					
						
						|  |  | 
					
						
						|  | except Exception as e: | 
					
						
						|  | st.error(f"Error processing the file: {str(e)}") | 
					
						
						|  |  | 
					
						
						|  | if __name__ == '__main__': | 
					
						
						|  | main() |