sourize
commited on
Commit
Β·
1a31bc2
1
Parent(s):
9c92fdf
Initial Commit
Browse files- app.py +25 -91
- pages/analytics_dashboard.py +1 -0
- pages/fraud_detection.py +1 -0
- pages/home.py +1 -0
- pages/model_insights.py +1 -0
- requirements.txt +3 -1
app.py
CHANGED
|
@@ -1,13 +1,8 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from utils.model_utils import load_models, create_demo_model
|
| 3 |
-
from pages.home import home_page
|
| 4 |
-
from pages.fraud_detection import fraud_detection_page
|
| 5 |
-
from pages.model_insights import model_insights_page
|
| 6 |
-
from pages.analytics_dashboard import analytics_dashboard_page
|
| 7 |
|
| 8 |
# Page config
|
| 9 |
st.set_page_config(
|
| 10 |
-
page_title="π E-Commerce Fraud Detection",
|
| 11 |
page_icon="π‘οΈ",
|
| 12 |
layout="wide",
|
| 13 |
initial_sidebar_state="expanded"
|
|
@@ -23,93 +18,32 @@ st.markdown("""
|
|
| 23 |
margin-bottom: 2rem;
|
| 24 |
text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
|
| 25 |
}
|
| 26 |
-
.metric-card {
|
| 27 |
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 28 |
-
padding: 1.5rem;
|
| 29 |
-
border-radius: 15px;
|
| 30 |
-
color: white;
|
| 31 |
-
text-align: center;
|
| 32 |
-
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
|
| 33 |
-
}
|
| 34 |
-
.fraud-alert {
|
| 35 |
-
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
|
| 36 |
-
padding: 1.5rem;
|
| 37 |
-
border-radius: 15px;
|
| 38 |
-
color: white;
|
| 39 |
-
text-align: center;
|
| 40 |
-
box-shadow: 0 4px 15px rgba(255,107,107,0.3);
|
| 41 |
-
}
|
| 42 |
-
.safe-alert {
|
| 43 |
-
background: linear-gradient(135deg, #51cf66 0%, #40c057 100%);
|
| 44 |
-
padding: 1.5rem;
|
| 45 |
-
border-radius: 15px;
|
| 46 |
-
color: white;
|
| 47 |
-
text-align: center;
|
| 48 |
-
box-shadow: 0 4px 15px rgba(81,207,102,0.3);
|
| 49 |
-
}
|
| 50 |
-
.feature-impact {
|
| 51 |
-
background-color: #23272f;
|
| 52 |
-
color: #f8f9fa;
|
| 53 |
-
padding: 1rem;
|
| 54 |
-
border-radius: 10px;
|
| 55 |
-
margin: 0.5rem 0;
|
| 56 |
-
border-left: 4px solid #007bff;
|
| 57 |
-
}
|
| 58 |
-
.stButton > button {
|
| 59 |
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 60 |
-
color: white;
|
| 61 |
-
border: none;
|
| 62 |
-
padding: 0.5rem 2rem;
|
| 63 |
-
border-radius: 25px;
|
| 64 |
-
font-weight: bold;
|
| 65 |
-
transition: all 0.3s ease;
|
| 66 |
-
}
|
| 67 |
-
.stButton > button:hover {
|
| 68 |
-
transform: translateY(-2px);
|
| 69 |
-
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
|
| 70 |
-
}
|
| 71 |
</style>
|
| 72 |
""", unsafe_allow_html=True)
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
<div class="main-header">
|
| 89 |
-
π‘οΈ E-Commerce Fraud Detection System
|
| 90 |
-
</div>
|
| 91 |
-
''', unsafe_allow_html=True)
|
| 92 |
-
with st.spinner("π Loading AI models..."):
|
| 93 |
-
model, label_encoder, models_loaded = load_models()
|
| 94 |
-
if not models_loaded:
|
| 95 |
-
st.warning("π§ Using demo mode - real models not found")
|
| 96 |
-
model, label_encoder = create_demo_model()
|
| 97 |
-
st.sidebar.title("π― Navigation")
|
| 98 |
-
st.sidebar.markdown("---")
|
| 99 |
-
page = st.sidebar.selectbox(
|
| 100 |
-
"Choose a section:",
|
| 101 |
-
["π Home", "π Fraud Detection", "π Model Insights", "π Analytics Dashboard"],
|
| 102 |
-
index=1
|
| 103 |
-
)
|
| 104 |
-
if page == "π Home":
|
| 105 |
-
home_page()
|
| 106 |
-
elif page == "π Fraud Detection":
|
| 107 |
-
fraud_detection_page(model, label_encoder)
|
| 108 |
-
elif page == "π Model Insights":
|
| 109 |
-
model_insights_page(model)
|
| 110 |
-
elif page == "π Analytics Dashboard":
|
| 111 |
-
analytics_dashboard_page()
|
| 112 |
-
show_footer()
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
# Page config
|
| 4 |
st.set_page_config(
|
| 5 |
+
page_title="π FraudLens: An E-Commerce Fraud Detection",
|
| 6 |
page_icon="π‘οΈ",
|
| 7 |
layout="wide",
|
| 8 |
initial_sidebar_state="expanded"
|
|
|
|
| 18 |
margin-bottom: 2rem;
|
| 19 |
text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
|
| 20 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
</style>
|
| 22 |
""", unsafe_allow_html=True)
|
| 23 |
|
| 24 |
+
st.markdown('''
|
| 25 |
+
<div class="main-header">
|
| 26 |
+
π‘οΈ E-Commerce Fraud Detection System
|
| 27 |
+
</div>
|
| 28 |
+
''', unsafe_allow_html=True)
|
| 29 |
+
|
| 30 |
+
st.markdown("""
|
| 31 |
+
## π― Welcome to FraudLens
|
| 32 |
+
|
| 33 |
+
This is the landing page for the E-Commerce Fraud Detection System. Use the navigation menu on the left to explore:
|
| 34 |
+
- π Fraud Detection
|
| 35 |
+
- π Model Insights
|
| 36 |
+
- π Analytics Dashboard
|
| 37 |
|
| 38 |
+
Protecting businesses and customers from fraudulent transactions with Explainable AI.
|
| 39 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
st.markdown("---")
|
| 42 |
+
st.markdown("""
|
| 43 |
+
<div style='text-align: center; padding: 30px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 44 |
+
border-radius: 15px; color: white; margin-top: 2rem;'>
|
| 45 |
+
<h3>π‘οΈ E-Commerce Fraud Detection System</h3>
|
| 46 |
+
<p>Powered by <strong>Explainable AI</strong> β’ Built by <strong>FraudNinjas</strong> for Security</p>
|
| 47 |
+
<p><em>Protecting businesses and customers from fraudulent transactions</em></p>
|
| 48 |
+
</div>
|
| 49 |
+
""", unsafe_allow_html=True)
|
pages/analytics_dashboard.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
import pandas as pd
|
| 4 |
import plotly.express as px
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
st.set_page_config(page_title="π Analytics Dashboard")
|
| 3 |
import numpy as np
|
| 4 |
import pandas as pd
|
| 5 |
import plotly.express as px
|
pages/fraud_detection.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
from utils.preprocessing import get_location_options, preprocess_inputs
|
| 4 |
from utils.visualization import create_risk_gauge, explain_prediction_simple
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
st.set_page_config(page_title="π Fraud Detection")
|
| 3 |
import pandas as pd
|
| 4 |
from utils.preprocessing import get_location_options, preprocess_inputs
|
| 5 |
from utils.visualization import create_risk_gauge, explain_prediction_simple
|
pages/home.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
def home_page():
|
| 4 |
col1, col2 = st.columns([2, 1])
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
st.set_page_config(page_title="π Home")
|
| 3 |
|
| 4 |
def home_page():
|
| 5 |
col1, col2 = st.columns([2, 1])
|
pages/model_insights.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
import pandas as pd
|
| 4 |
import plotly.express as px
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
st.set_page_config(page_title="π Model Insights")
|
| 3 |
import numpy as np
|
| 4 |
import pandas as pd
|
| 5 |
import plotly.express as px
|
requirements.txt
CHANGED
|
@@ -6,4 +6,6 @@ lightgbm
|
|
| 6 |
matplotlib
|
| 7 |
seaborn
|
| 8 |
plotly
|
| 9 |
-
joblib
|
|
|
|
|
|
|
|
|
| 6 |
matplotlib
|
| 7 |
seaborn
|
| 8 |
plotly
|
| 9 |
+
joblib
|
| 10 |
+
shap
|
| 11 |
+
dice-ml
|