import streamlit as st import pandas as pd from app_config import AppConfig # Import the configurations class from data_processor import DataProcessor # Import the data analysis class from visualization import Visualization # Import the data viz class from ai_analysis import AIAnalysis # Import the ai analysis class from sidebar import Sidebar # Import the Sidebar class def main(): # Initialize the app configuration app_config = AppConfig() # Initialize the sidebar sidebar = Sidebar() sidebar.display() # Initialize the data processor data_processor = DataProcessor() # Initialize the visualization handler visualization = Visualization() # Initialize the AI analysis handler ai_analysis = AIAnalysis(data_processor.client) st.title("Literacy Implementation Record Data Analysis") # Add the descriptive text st.markdown(""" This tool summarizes implementation record data for student attendance, engagement, and intervention dosage to address hypothesis #1: Have Students Received Adequate Instruction? """) # Date selection option date_option = st.radio( "Select data range:", ("All Data", "Date Range") ) # Initialize start and end date variables start_date = None end_date = None if date_option == "Date Range": # Prompt user to enter start and end dates start_date = st.date_input("Start Date") end_date = st.date_input("End Date") # Ensure start date is before end date if start_date > end_date: st.error("Start date must be before end date.") return # File uploader uploaded_file = st.file_uploader("Upload your Excel file", type=["xlsx"]) if uploaded_file is not None: try: # Read the Excel file into a DataFrame df = data_processor.read_excel(uploaded_file) # Format the session data df = data_processor.format_session_data(df) # Replace student names with initials df = data_processor.replace_student_names_with_initials(df) # Filter data if date range is selected if date_option == "Date Range": # Convert start_date and end_date to datetime start_date = pd.to_datetime(start_date).date() end_date = pd.to_datetime(end_date).date() # Identify the date column date_column = next((col for col in df.columns if col in ["Date of Session", "Date"]), None) if date_column: # Filter the DataFrame based on the selected date range df = df[(df[date_column] >= start_date) & (df[date_column] <= end_date)] else: st.error("Date column not found in the data.") return st.subheader("Uploaded Data") st.write(df) # Ensure the intervention column is determined intervention_column = data_processor.get_intervention_column(df) if intervention_column not in df.columns: st.error(f"Expected column '{intervention_column}' not found.") return # Compute Intervention Session Statistics intervention_stats = data_processor.compute_intervention_statistics(df) st.subheader("Intervention Dosage") st.write(intervention_stats) # Plot and download intervention statistics: Two-column layout for the visualization and intervention frequency col1, col2 = st.columns([3, 1]) # Set the column width ratio with col1: intervention_fig = visualization.plot_intervention_statistics(intervention_stats) with col2: intervention_frequency = intervention_stats['Intervention Dosage (%)'].values[0] # Display the "Intervention Dosage (%)" text st.markdown("