Spaces:
Sleeping
Sleeping
Commit
·
e085bc3
1
Parent(s):
0955bb2
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,29 @@
|
|
|
|
1 |
import streamlit as st
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
import streamlit as st
|
3 |
+
from models.fraud_detection_model import load_fraud_detection_model, predict_fraud
|
4 |
+
from utils.preprocessing import preprocess_data_for_streamlit, feature_engineering
|
5 |
|
6 |
+
# Load model
|
7 |
+
model_path = 'models/fraud_detection_model.h5'
|
8 |
+
fraud_model = load_fraud_detection_model(model_path)
|
9 |
+
|
10 |
+
# Load data
|
11 |
+
data_path = 'data/dataset.csv'
|
12 |
+
df, X_scaled = preprocess_data_for_streamlit(data_path)
|
13 |
+
|
14 |
+
# Streamlit App
|
15 |
+
st.title('Fraud Detection Web App')
|
16 |
+
|
17 |
+
# Sidebar with user input
|
18 |
+
selected_index = st.sidebar.selectbox('Select an index:', df.index)
|
19 |
+
selected_data = X_scaled[selected_index].reshape(1, -1)
|
20 |
+
|
21 |
+
# Display selected data
|
22 |
+
st.write('Selected Data:')
|
23 |
+
st.write(df.iloc[selected_index])
|
24 |
+
|
25 |
+
# Predict fraud
|
26 |
+
if st.button('Predict Fraud'):
|
27 |
+
prediction = predict_fraud(fraud_model, selected_data)
|
28 |
+
result = "Fraud" if prediction[0][0] == 1 else "Non-Fraud"
|
29 |
+
st.write(f'Prediction: {result}')
|