Download app.py from MahimaP/BankChurn: direct link, hf CLI and curl.
- Browser
- Download file 896 Bytes
-
https://huggingface.co/spaces/MahimaP/BankChurn/resolve/main/app.py
- Command line
-
hf download hf://spaces/MahimaP/BankChurn/app.py
-
curl -L -o app.py https://huggingface.co/spaces/MahimaP/BankChurn/resolve/main/app.py
896 Bytes
| import streamlit as st | |
| import pandas as pd | |
| import numpy as np | |
| from tensorflow.keras.models import load_model | |
| from sklearn.preprocessing import StandardScaler | |
| # Load the trained model | |
| model = load_model('best_dnn_model') | |
| # Load the scaler | |
| scaler = StandardScaler() | |
| # Define function to preprocess input data | |
| def preprocess_data(data): | |
| data = np.array(data).reshape(1, -1) | |
| data = scaler.transform(data) | |
| return data | |
| # Streamlit app | |
| st.title('Bank Churn: DNN Model Deployment') | |
| # Collect user input | |
| user_input = st.text_area("Enter your input data (comma-separated)") | |
| # Process the input and make prediction | |
| if st.button('Predict'): | |
| try: | |
| data = [float(i) for i in user_input.split(',')] | |
| data = preprocess_data(data) | |
| prediction = model.predict(data) | |
| st.write(f"Prediction: {prediction}") | |
| except Exception as e: | |
| st.write(f"Error: {e}") | |