sourize commited on
Commit
1a31bc2
Β·
1 Parent(s): 9c92fdf

Initial Commit

Browse files
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
- def show_footer():
75
- """Enhanced footer"""
76
- st.markdown("---")
77
- st.markdown("""
78
- <div style='text-align: center; padding: 30px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
79
- border-radius: 15px; color: white; margin-top: 2rem;'>
80
- <h3>πŸ›‘οΈ E-Commerce Fraud Detection System</h3>
81
- <p>Powered by <strong>Explainable AI</strong> β€’ Built with ❀️ for Security</p>
82
- <p><em>Protecting businesses and customers from fraudulent transactions</em></p>
83
- </div>
84
- """, unsafe_allow_html=True)
 
 
85
 
86
- def main():
87
- st.markdown('''
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
- if __name__ == "__main__":
115
- main()
 
 
 
 
 
 
 
 
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