Hemavathineelirothu commited on
Commit
24b741e
·
verified ·
1 Parent(s): dddf0e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -1,8 +1,8 @@
 
1
  import streamlit as st
2
  import pandas as pd
3
  import joblib
4
 
5
- # Load the XGBoost model
6
  @st.cache_resource
7
  def load_model():
8
  return joblib.load("fraud_xgb_model.pkl")
@@ -10,16 +10,15 @@ def load_model():
10
  model = load_model()
11
 
12
  st.title("💳 Fraud Detection App")
13
- st.write("Upload a CSV file to check for fraudulent transactions.")
14
 
15
- uploaded_file = st.file_uploader("Upload CSV", type="csv")
16
 
17
- if uploaded_file is not None:
18
- data = pd.read_csv(uploaded_file)
19
- st.write(" Uploaded Data Preview:", data.head())
20
 
21
- if st.button("🔍 Predict Fraud"):
22
- predictions = model.predict(data)
23
- data["Fraud Prediction"] = predictions
24
- st.write("🔔 Prediction Results:", data)
25
- st.download_button("⬇️ Download Results", data.to_csv(index=False), file_name="fraud_predictions.csv")
 
1
+ # app.py
2
  import streamlit as st
3
  import pandas as pd
4
  import joblib
5
 
 
6
  @st.cache_resource
7
  def load_model():
8
  return joblib.load("fraud_xgb_model.pkl")
 
10
  model = load_model()
11
 
12
  st.title("💳 Fraud Detection App")
 
13
 
14
+ uploaded_file = st.file_uploader("Upload a CSV file for prediction", type=["csv"])
15
 
16
+ if uploaded_file:
17
+ input_data = pd.read_csv(uploaded_file)
18
+ st.write("📄 Uploaded Data", input_data.head())
19
 
20
+ if st.button("Predict Fraud"):
21
+ predictions = model.predict(input_data)
22
+ input_data["Prediction"] = predictions
23
+ st.write("🧾 Results", input_data.head())
24
+ st.download_button("Download Results", input_data.to_csv(index=False), file_name="predictions.csv")