Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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
|
| 18 |
-
|
| 19 |
-
st.write("
|
| 20 |
|
| 21 |
-
if st.button("
|
| 22 |
-
predictions = model.predict(
|
| 23 |
-
|
| 24 |
-
st.write("
|
| 25 |
-
st.download_button("
|
|
|
|
| 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")
|