Spaces:
Sleeping
Sleeping
Update app.py
Browse files3 unmodified lines456789314 unmodified lines32432532632732832933027 unmodified lines3583593603613623633 unmodified lines3673683693703 unmodified linesimport osimport pandas as pdimport openpyxl# Load the preprocessorpreprocessor_path = 'modelExports/preprocessor.pkl'314 unmodified linesst.header('Download Predictions')download_option = st.radio("Choose how to download your predictions:",("All Models in Separate Files", "Churn and Non-Churn in Separate Files"))if download_option == "All Models in Separate Files":27 unmodified linesfile_name=f'{model_name.lower().replace(" ", "_")}_non_churn_predictions.csv',mime='text/csv',)else:st.info('Awaiting CSV or Excel file to be uploaded.')3 unmodified linesst.sidebar.write(f"Models selected for prediction: {len(selected_models)}")st.sidebar.write("### Model Accuracies")for model, accuracy in model_accuracies.items():st.sidebar.write(f"{model}: {accuracy}%")3 unmodified lines4567891011314 unmodified lines32632732832933033133227 unmodified lines3603613623633643653663673683693703713723733743753763773783793803 unmodified lines3843853863873 unmodified linesimport osimport pandas as pdimport openpyxlimport zipfileimport io# Load the preprocessorpreprocessor_path = 'modelExports/preprocessor.pkl'314 unmodified linesst.header('Download Predictions')download_option = st.radio("Choose how to download your predictions:",("All Models in Separate Files", "Churn and Non-Churn in Separate Files", "Download All at Once"))if download_option == "All Models in Separate Files":27 unmodified linesfile_name=f'{model_name.lower().replace(" ", "_")}_non_churn_predictions.csv',mime='text/csv',)elif download_option == "Download All at Once":# Create a zip file containing all outputszip_buffer = io.BytesIO()with zipfile.ZipFile(zip_buffer, "w") as zip_file:for model_name, output_df in model_outputs.items():csv_data = output_df.to_csv(index=False).encode('utf-8')zip_file.writestr(f'{model_name.lower().replace(" ", "_")}_predictions.csv', csv_data)zip_buffer.seek(0)st.download_button(label="Download All Predictions as ZIP",data=zip_buffer,file_name='all_model_predictions.zip',mime='application/zip')else:st.info('Awaiting CSV or Excel file to be uploaded.')3 unmodified linesst.sidebar.write(f"Models selected for prediction: {len(selected_models)}")st.sidebar.write("### Model Accuracies")for model, accuracy in model_accuracies.items():st.sidebar.write(f"{model}: {accuracy}%")
app.py+19-2