import streamlit as st import pandas as pd import joblib from sklearn.linear_model import LogisticRegression from sklearn.ensemble import RandomForestClassifier from sklearn.tree import DecisionTreeClassifier import time import numpy as np import streamlit as st # Using Markdown with custom styles to center the title and add style st.markdown("""
🎓 STUDENT DROPOUT PREDICTION APP 🎓
""", unsafe_allow_html=True) # Display a banner image st.image("banner.webp", use_column_width=True) # Main page description st.markdown(""" This app predicts the likelihood of a student dropping out 🚪. Enter the student's details on the left sidebar to see the prediction result. The prediction helps in identifying students at risk early, allowing for timely intervention to improve retention rates. """) import joblib # Load the models decision_tree = joblib.load('decision_tree_model.joblib') logistic_regression = joblib.load('logistic_regression_model.joblib') random_forest = joblib.load('random_forest_model.joblib') # Define a dictionary of models with their names, actual models, and types models = { 'Decision Tree': {'model': decision_tree, 'type': 'Decision Tree'}, 'Logistic Regression': {'model': logistic_regression, 'type': 'Logistic Regression'}, 'Random Forest': {'model': random_forest, 'type': 'Random Forest'} } with st.sidebar: # Streamlit UI to select a model # Add some design to the header st.write("

Select Model

", unsafe_allow_html=True) st.header('') # Ensure that this is defined before you try to use `model_name` model_name = st.selectbox('Choose a model', list(models.keys())) # Retrieve the selected model and its type from the dictionary after it's been defined model = models[model_name]['model'] model_type = models[model_name]['type'] # Additional Streamlit code to display selected model and type or other UI elements st.write(f"You have selected: {model_name}") # Load trained model @st.cache_resource #def load_model(): # return LogisticRegression() # Load your trained model here def preprocess_input(input_data, original_feature_names): # Create a DataFrame from the input data input_df = pd.DataFrame(input_data, index=[0]) # Ensure the DataFrame has the correct column structure input_df = input_df.reindex(columns=original_feature_names, fill_value=0) return input_df original_feature_names = ['Marital_Status', 'Application_Mode', 'Application_Order', 'Course', 'Attendance', 'Previous_Qualification', 'Nationality', 'Mother_Qualification', 'Father_Qualification', 'Mother_Occupation', 'Father_Occupation', 'Displaced', 'Special_Needs', 'Debtor', 'Fees_UpToDate', 'Gender', 'Scholarship_Holder', 'Age', 'International', '1st_Sem_Credits', '1st_Sem_Enrolled', '1st_Sem_Evaluations', '1st_Sem_Approved', '1st_Sem_Grade', '1st_Sem_No_Evaluations', '2nd_Sem_Credits', '2nd_Sem_Enrolled', '2nd_Sem_Evaluations', '2nd_Sem_Approved', '2nd_Sem_Grade', '2nd_Sem_No_Evaluations', 'Unemployment_Rate', 'Inflation_Rate', 'GDP'] def map_and_select(label, mapping_or_value, min_value=None, max_value=None, step=None): if isinstance(mapping_or_value, dict): # Invert the mapping dictionary inverted_mapping = {v: k for k, v in mapping_or_value.items()} # Display the selectbox selected_option = st.sidebar.selectbox(label, options=list(inverted_mapping.keys())) # Retrieve numerical value based on the selected option selected_value = inverted_mapping[selected_option] st.sidebar.write(f"{label} Value:", selected_value) return selected_value else: # Determine the type of input and display accordingly if isinstance(mapping_or_value, float): # Handle as a slider for float values selected_value = st.sidebar.slider(label, min_value=min_value, max_value=max_value, value=mapping_or_value, step=step) elif isinstance(mapping_or_value, int): # Handle as a number input for int values selected_value = st.sidebar.number_input(label, min_value=min_value, max_value=max_value, value=mapping_or_value, step=step) else: # Display as a text input for non-numeric values selected_value = st.sidebar.text_input(label, value=str(mapping_or_value)) st.sidebar.write(f"{label}:", selected_value) return selected_value def predict_dropout(input_data, model, model_type): # Initialize variable to ensure it has a value in all code paths dropout_prediction = None # Check the model type to decide on the prediction method if model_type == "Logistic Regression" or model_type == "Decision Tree" or model_type == "Random Forest": # Use model.predict for predictions dropout_prediction = model.predict(input_data) else: raise ValueError("Unsupported model type.") return dropout_prediction def map_dropout_prediction(prediction): if prediction == 1: return "Dropout", "🎓", "The model predicts that the student is likely to dropout." else: return "Not Dropout", "👩‍🎓", "The model predicts that the student is not likely to dropout." marital_mapping = { 1: 'Single', 2: 'Married', 3: 'Widower', 4: 'Divorced', 5: 'Facto union', 6: 'Legally separated' } # Add some design to the header st.sidebar.write("

Enter Student Details

", unsafe_allow_html=True) # Use the map_and_select function to handle mapping and selection for Marital Status marital_status = map_and_select('Marital Status', marital_mapping) application_mode_mapping = { 1: '1st phase—general contingent', 2: 'Ordinance No. 612/93', 3: '1st phase—special contingent (Azores Island)', 4: 'Holders of other higher courses', 5: 'Ordinance No. 854-B/99', 6: 'International student (bachelor)', 7: '1st phase—special contingent (Madeira Island)', 8: '2nd phase—general contingent', 9: '3rd phase—general contingent', 10: 'Ordinance No. 533-A/99, item b2) (Different Plan)', 11: 'Ordinance No. 533-A/99, item b3 (Other Institution)', 12: 'Over 23 years old', 13: 'Transfer', 14: 'Change in course', 15: 'Technological specialization diploma holders', 16: 'Change in institution/course', 17: 'Short cycle diploma holders', 18: 'Change in institution/course (International)' } application_mode = map_and_select('Application Mode', application_mode_mapping) #application_mode = st.sidebar.selectbox('Application Mode', options=range(1, 10)) # Assuming modes 1 through 9 #st.sidebar.write("application Mode:", application_mode) application_order_mapping = { 1: 'First', 2: 'Second', 3: 'Third', 4: 'Fourth', 5: 'Fifth', 6: 'Sixth', 9: 'Ninth', 0: 'Zero' } application_order = map_and_select('Application Order', application_order_mapping) #application_order = st.sidebar.number_input('Application Order', min_value=0, max_value=10, value=1) #st.sidebar.write("application Order:", application_order) courses_mapping = { 1: 'Biofuel Production Technologies', 2: 'Animation and Multimedia Design', 3: 'Social Service (evening attendance)', 4: 'Agronomy', 5: 'Communication Design', 6: 'Veterinary Nursing', 7: 'Informatics Engineering', 8: 'Equiniculture', 9: 'Management', 10: 'Social Service', 11: 'Tourism', 12: 'Nursing', 13: 'Oral Hygiene', 14: 'Advertising and Marketing Management', 15: 'Journalism and Communication', 16: 'Basic Education', 17: 'Management (evening attendance)' } # Use the map_and_select function to handle mapping and selection for Courses course = map_and_select('Course', courses_mapping) #course = st.sidebar.selectbox('Course', options=range(1, 100)) # Update range based on actual course codes #st.sidebar.write("course:", course) attendance_mapping = { 1: 'Daytime', 2: 'Evening' } # Use the map_and_select function to handle mapping and selection for Daytime/Evening Attendance daytime_evening_attendance = map_and_select('Daytime/Evening Attendance', attendance_mapping) #daytime_evening_attendance = st.sidebar.radio('Daytime/Evening Attendance', options=[1, 2], format_func=lambda x: 'Daytime' if x == 1 else 'Evening') #st.sidebar.write("Daytime Evening Attendance:", daytime_evening_attendance) previous_qualification_mapping = { 1: 'Secondary education', 2: 'Higher education—bachelor’s degree', 3: 'Higher education—degree', 4: 'Higher education—master’s degree', 5: 'Higher education—doctorate', 6: 'Frequency of higher education', 7: '12th year of schooling—not completed', 8: '11th year of schooling—not completed', 9: 'Other—11th year of schooling', 10: '10th year of schooling', 11: '10th year of schooling—not completed', 12: 'Basic education 3rd cycle (9th/10th/11th year) or equivalent', 13: 'Basic education 2nd cycle (6th/7th/8th year) or equivalent', 14: 'Technological specialization course', 15: 'Higher education—degree (1st cycle)', 16: 'Professional higher technical course', 17: 'Higher education—master’s degree (2nd cycle)' } # Use the map_and_select function to handle mapping and selection for Previous Qualification previous_qualification = map_and_select('Previous Qualification', previous_qualification_mapping) ## Output the selected value using st.write #st.sidebar.write("Previous Qualification:", selected_previous_qualification_label) #previous_qualification = st.sidebar.selectbox('Previous Qualification', options=range(1, 20)) # Update range based on actual qualifications #st.sidebar.write("Previous Qualification:", previous_qualification) nationality_mapping = { 1: 'Portuguese', 2: 'German', 3: 'Spanish', 4: 'Italian', 5: 'Dutch', 6: 'English', 7: 'Lithuanian', 8: 'Angolan', 9: 'Cape Verdean', 10: 'Guinean', 11: 'Mozambican', 12: 'Santomean', 13: 'Turkish', 14: 'Brazilian', 15: 'Romanian', 16: 'Moldova (Republic of)', 17: 'Mexican', 18: 'Ukrainian', 19: 'Russian', 20: 'Cuban', 21: 'Colombian' } nationality = map_and_select('Nationality', nationality_mapping) #nationality = st.sidebar.selectbox('Nationality', options=range(1, 200)) # Update range based on actual nationality codes #st.sidebar.write("nationality:", nationality) qualification_mapping = { 1: 'Secondary Education', 2: 'Higher Education - Undergraduate', 3: 'Higher Education - Undergraduate', 4: 'Higher Education - Graduate', 5: 'Higher Education - Graduate', 6: 'Higher Education - Undergraduate', 7: 'Primary Education', 8: 'Primary Education', 9: 'Primary Education', 10: 'Secondary Education', 11: 'Secondary Education', 12: 'Secondary Education', 13: 'Secondary Education', 14: 'Secondary Education', 15: 'Secondary Education', 16: 'Vocational/Technical', 17: 'Secondary Education', 18: 'Primary Education', 19: 'Secondary Education', 20: 'Primary Education', 21: 'Primary Education', 22: 'Secondary Education', 23: 'Secondary Education', 24: 'Unknown', 25: 'Primary Education', 26: 'Primary Education', 27: 'Primary Education', 28: 'Primary Education', 29: 'Vocational/Technical', 30: 'Higher Education - Undergraduate', 31: 'Higher Education - Undergraduate', 32: 'Higher Education - Undergraduate', 33: 'Higher Education - Graduate', 34: 'Higher Education - Graduate' } mother_qualification = map_and_select('Mother\'s Qualification', qualification_mapping) #mother_qualification = st.sidebar.selectbox('Mother\'s Qualification', options=range(1, 20)) #st.sidebar.write("Mother Qualification:", mother_qualification) father_qualification = map_and_select('Father\'s Qualification', qualification_mapping) #father_qualification = st.sidebar.selectbox('Father\'s Qualification', options=range(1, 20)) #st.sidebar.write("Father Qualification:", father_qualification) occupation_mapping = { 1: 'Student', 2: 'Representatives of the Legislative Power and Executive Bodies, Directors, Directors and Executive Managers', 3: 'Specialists in Intellectual and Scientific Activities', 4: 'Intermediate Level Technicians and Professions', 5: 'Administrative staff', 6: 'Personal Services, Security and Safety Workers, and Sellers', 7: 'Farmers and Skilled Workers in Agriculture, Fisheries, and Forestry', 8: 'Skilled Workers in Industry, Construction, and Craftsmen', 9: 'Installation and Machine Operators and Assembly Workers', 10: 'Unskilled Workers', 11: 'Armed Forces Professions', 12: 'Other Situation', 13: '(blank)', 14: 'Armed Forces Officers', 15: 'Armed Forces Sergeants', 16: 'Other Armed Forces personnel', 17: 'Directors of administrative and commercial services', 18: 'Hotel, catering, trade, and other services directors', 19: 'Specialists in the physical sciences, mathematics, engineering, and related techniques', 20: 'Health professionals', 21: 'Teachers', 22: 'Specialists in finance, accounting, administrative organization, and public and commercial relations', 23: 'Intermediate level science and engineering technicians and professions', 24: 'Technicians and professionals of intermediate level of health', 25: 'Intermediate level technicians from legal, social, sports, cultural, and similar services', 26: 'Information and communication technology technicians', 27: 'Office workers, secretaries in general, and data processing operators', 28: 'Data, accounting, statistical, financial services, and registry-related operators', 29: 'Other administrative support staff', 30: 'Personal service workers', 31: 'Sellers', 32: 'Personal care workers and the like', 33: 'Protection and security services personnel', 34: 'Market-oriented farmers and skilled agricultural and animal production workers', 35: 'Farmers, livestock keepers, fishermen, hunters and gatherers, and subsistence', 36: 'Skilled construction workers and the like, except electricians', 37: 'Skilled workers in metallurgy, metalworking, and similar', 38: 'Skilled workers in electricity and electronics', 39: 'Workers in food processing, woodworking, and clothing and other industries and crafts', 40: 'Fixed plant and machine operators', 41: 'Assembly workers', 42: 'Vehicle drivers and mobile equipment operators', 43: 'Unskilled workers in agriculture, animal production, and fisheries and forestry', 44: 'Unskilled workers in extractive industry, construction, manufacturing, and transport', 45: 'Meal preparation assistants', 46: 'Street vendors (except food) and street service providers' } mother_occupation = map_and_select('Mother\'s Occupation', occupation_mapping) #mother_occupation = st.sidebar.selectbox('Mother\'s Occupation', options=range(1, 50)) # Update range based on actual occupations #st.sidebar.write("Mother Occupation:", mother_occupation) father_occupation = map_and_select('Father\'s Occupation', occupation_mapping) #father_occupation = st.sidebar.selectbox('Father\'s Occupation', options=range(1, 50)) #st.sidebar.write("Father Occupation:", father_occupation) displaced_mapping = { 1: 'Yes', 0: 'No' } displaced = map_and_select('Displaced', displaced_mapping) #displaced = st.sidebar.radio('Displaced', options=[0, 1], format_func=lambda x: 'No' if x == 0 else 'Yes') #st.sidebar.write("Displaced:", displaced) educational_special_needs_mapping = { 1: 'Yes', 0: 'No' } debtor_mapping = { 1: 'Yes', 0: 'No' } educational_special_needs = map_and_select('Educational Special Needs', educational_special_needs_mapping) #st.sidebar.write("Educational Special Needs:", educational_special_needs_mapping[educational_special_needs]) debtor = map_and_select('Debtor', debtor_mapping) #st.sidebar.write("Debtor:", debtor_mapping[debtor]) #educational_special_needs = st.sidebar.radio('Educational Special Needs', options=[0, 1], format_func=lambda x: 'No' if x == 0 else 'Yes') #st.sidebar.write("Educational Special Needs:", educational_special_needs) #debtor = st.sidebar.radio('Debtor', options=[0, 1], format_func=lambda x: 'No' if x == 0 else 'Yes') #st.sidebar.write("Debtor:", debtor) # Example usage for single input tuition_fees_up_to_date = map_and_select('Tuition Fees Up to Date', 5000, min_value=0, max_value=10000) #tuition_fees_up_to_date = st.sidebar.number_input('Tuition Fees Up to Date', min_value=0, max_value=10000, value=5000) #st.sidebar.write("tuition_fees_up_to_date:", tuition_fees_up_to_date) # Gender replacement gender_mapping = { 1: 'male', 0: 'female' } gender = map_and_select('Gender', gender_mapping) #gender = st.sidebar.radio('Gender', options=[1, 2], format_func=lambda x: 'Male' if x == 1 else 'Female') #st.sidebar.write("gender:", gender) scholarship_mapping = { 1: 'Yes', 0: 'No' } scholarship_holder = map_and_select('Scholarship Holder', scholarship_mapping) #st.sidebar.write("Scholarship holder:", scholarship_mapping[scholarship_holder]) #scholarship_holder = st.sidebar.radio('Scholarship Holder', options=[0, 1], format_func=lambda x: 'No' if x == 0 else 'Yes') #st.sidebar.write("Scholarship holder:", scholarship_holder) # Example usage for single input age_at_enrollment = map_and_select('Age at Enrollment', 16, min_value=6, max_value=18) #age_at_enrollment = st.sidebar.number_input('Age at Enrollment', min_value=16, max_value=60, value=18) #st.sidebar.write("Age at Enrollment:", age_at_enrollment) international_mapping = { 1: 'Yes', 0: 'No' } international = map_and_select('International', international_mapping) #st.sidebar.write("International:", international_mapping[international]) #international = st.sidebar.radio('International', options=[0, 1], format_func=lambda x: 'No' if x == 0 else 'Yes') #st.sidebar.write("International:", international) unemployment_rate = map_and_select('Unemployment Rate', 10.8, min_value=0.0, max_value=100.0 ) #st.sidebar.write("unemployment_rate:", unemployment_rate) #unemployment_rate = st.sidebar.slider('Unemployment Rate', min_value=0.0, max_value=100.0, value=10.8) #st.sidebar.write("Unemployment Rate:", unemployment_rate) inflation_rate = map_and_select('Inflation Rate', 1.4, min_value=-10.0, max_value=30.0) #st.sidebar.write("inflation_rate:", inflation_rate) # Use map_and_select for the inflation_rate #inflation_rate = map_and_select(1, 'Inflation Rate', 1.4) #st.sidebar.write("Inflation Rate:", inflation_rate) #inflation_rate = st.sidebar.slider('Inflation Rate', min_value=-10.0, max_value=30.0, value=1.4) #st.sidebar.write("Inflation Rate:", inflation_rate) #gdp = st.sidebar.number_input('GDP', min_value=0.0, max_value=100.0, value=1.74) #st.sidebar.write("GDP:", gdp) # Use map_and_select for the inflation_rate gdp = map_and_select('GDP', 1.74, min_value=0.0, max_value=100.0) #st.sidebar.write("Inflation Rate:", gdp) #st.header('Curricular Units 1st Semester') #credited_1st_sem = st.sidebar.number_input('Credited Units 1st Semester', min_value=0, step=1) #st.sidebar.write("Credited Units 1st Semester:", credited_1st_sem) #enrolled_1st_sem = st.sidebar.number_input('Enrolled Units 1st Semester', min_value=0, step=1) #st.sidebar.write("Enrolled Units 1st Semester:", enrolled_1st_sem) #evaluations_1st_sem = st.sidebar.number_input('Evaluations 1st Semester', min_value=0, step=1) #st.sidebar.write("Evaluations 1st Semester:", evaluations_1st_sem) #approved_1st_sem = st.sidebar.number_input('Approved Units 1st Semester', min_value=0, step=1) #st.sidebar.write("Approved Units 1st Semester:", approved_1st_sem) #grade_1st_sem = st.sidebar.number_input('Grade 1st Semester', min_value=0.0, max_value=10.0, step=0.1) #st.sidebar.write("Grade 1st Semester:", grade_1st_sem) #without_evaluations_1st_sem = st.sidebar.number_input('Units without Evaluations 1st Semester', min_value=0, step=1) #st.sidebar.write("GDP:", without_evaluations_1st_sem) # Use map_and_select for the various inputs credited_1st_sem = map_and_select('Credited Units 1st Semester', 0, min_value=0, step=1) #st.sidebar.write("Credited Units 1st Semester:", credited_1st_sem) enrolled_1st_sem = map_and_select('Enrolled Units 1st Semester', 0, min_value=0, step=1) #st.sidebar.write("Enrolled Units 1st Semester:", enrolled_1st_sem) evaluations_1st_sem = map_and_select('Evaluations 1st Semester', 0, min_value=0, step=1) #st.sidebar.write("Evaluations 1st Semester:", evaluations_1st_sem) approved_1st_sem = map_and_select('Approved Units 1st Semester', 0, min_value=0, step=1) #st.sidebar.write("Approved Units 1st Semester:", approved_1st_sem) grade_1st_sem = map_and_select('Grade 1st Semester', 0.0, min_value=0.0, max_value=10.0, step=0.1) #st.sidebar.write("Grade 1st Semester:", grade_1st_sem) without_evaluations_1st_sem = map_and_select('Units without Evaluations 1st Semester', 0, min_value=0, step=1) #st.sidebar.write("Units without Evaluations 1st Semester:", without_evaluations_1st_sem) #st.sidebar.header('Curricular Units 2nd Semester') #credited_2nd_sem = st.sidebar.number_input('Credited Units 2nd Semester', min_value=0, step=1) #st.sidebar.write("Credited Units 2nd Semester:", credited_2nd_sem) #enrolled_2nd_sem = st.sidebar.number_input('Enrolled Units 2nd Semester', min_value=0, step=1) #st.sidebar.write("Enrolled Units 2nd Semester:", enrolled_2nd_sem) #evaluations_2nd_sem = st.sidebar.number_input('Evaluations 2nd Semester', min_value=0, step=1) #st.sidebar.write("Evaluations 2nd Semester:", evaluations_2nd_sem) #approved_2nd_sem = st.sidebar.number_input('Approved Units 2nd Semester', min_value=0, step=1) #st.sidebar.write("Approved Units 2nd Semester:", approved_2nd_sem) #grade_2nd_sem = st.sidebar.number_input('Grade 2nd Semester', min_value=0.0, max_value=10.0, step=0.1) #st.sidebar.write("Grade 2nd Semester:", grade_2nd_sem) #without_evaluations_2nd_sem = st.sidebar.number_input('Units without Evaluations 2nd Semester', min_value=0, step=1) #st.sidebar.write("Units without Evaluations 2nd Semester:", without_evaluations_2nd_sem) # Use map_and_select for the various inputs for the 2nd semester credited_2nd_sem = map_and_select('Credited Units 2nd Semester', 0, min_value=0, step=1) #st.sidebar.write("Credited Units 2nd Semester:", credited_2nd_sem) enrolled_2nd_sem = map_and_select('Enrolled Units 2nd Semester', 0, min_value=0, step=1) #st.sidebar.write("Enrolled Units 2nd Semester:", enrolled_2nd_sem) evaluations_2nd_sem = map_and_select('Evaluations 2nd Semester', 0, min_value=0, step=1) #st.sidebar.write("Evaluations 2nd Semester:", evaluations_2nd_sem) approved_2nd_sem = map_and_select('Approved Units 2nd Semester', 0, min_value=0, step=1) #st.sidebar.write("Approved Units 2nd Semester:", approved_2nd_sem) grade_2nd_sem = map_and_select('Grade 2nd Semester', 0.0, min_value=0.0, max_value=10.0, step=0.1) #st.sidebar.write("Grade 2nd Semester:", grade_2nd_sem) without_evaluations_2nd_sem = map_and_select('Units without Evaluations 2nd Semester', 0, min_value=0, step=1) #st.sidebar.write("Units without Evaluations 2nd Semester:", without_evaluations_2nd_sem) input_data = { 'Marital_Status': marital_status, 'Application_Mode' : application_mode, 'Application_Order': application_order, 'Course': course, 'Attendance': daytime_evening_attendance, 'Previous_Qualification': previous_qualification, 'Nationality': nationality, 'Mother_Qualification': mother_qualification, 'Father_Qualification': father_qualification, 'Mother_Occupation': mother_occupation, 'Father_Occupation': father_occupation, 'Displaced': displaced, 'Special_Needs': educational_special_needs, 'Debtor': debtor, 'Fees_UpToDate':tuition_fees_up_to_date, 'Gender': gender, 'Scholarship_Holder': scholarship_holder, 'Age': age_at_enrollment, 'International': international, '1st_Sem_Credits': credited_1st_sem, '1st_Sem_Enrolled': enrolled_1st_sem, '1st_Sem_Evaluations': evaluations_1st_sem, '1st_Sem_Approved': approved_1st_sem, '1st_Sem_Grade': grade_1st_sem, '1st_Sem_No_Evaluations': without_evaluations_1st_sem, '2nd_Sem_Credits': credited_2nd_sem, '2nd_Sem_Enrolled': enrolled_2nd_sem, '2nd_Sem_Evaluations': evaluations_2nd_sem, '2nd_Sem_Approved': approved_2nd_sem, '2nd_Sem_Grade': grade_2nd_sem, '2nd_Sem_No_Evaluations': without_evaluations_2nd_sem, 'Unemployment_Rate': unemployment_rate, 'Inflation_Rate': inflation_rate, 'GDP':gdp } if st.sidebar.button('Predict Dropout'): try: with st.spinner("Predicting..."): # Simulate a long-running prediction process progress_bar = st.progress(0) for i in range(5): # Simulate progress time.sleep(0.1) # Sleep for a short period to simulate work progress_bar.progress((i + 1) * 20) # Convert input dictionary to a 2D array input_array = np.array(list(input_data.values())).reshape(1, -1) # Perform prediction dropout_label = predict_dropout(input_array, model, model_type) dropout_label, emoji, explanation = map_dropout_prediction(dropout_label) # Display the prediction result st.success("Prediction complete!") st.write(f"Prediction: {dropout_label} {emoji}") st.write(explanation) # Display images if dropout_label == "Dropout": st.image("dropout_image.webp", caption="Image representing a dropout student", use_column_width=True) else: st.image("not_dropout_image.webp", caption="Image representing a non-dropout student", use_column_width=True) except Exception as e: st.error(f"An error occurred: {str(e)}")