Ajay-user's picture
Rename app.py to Home.py
770bcff
from utils import FraudDetection
import streamlit as st
detect = FraudDetection()
@st.cache_resource
def get_us_states(region):
return detect.plot_geo_data_us_states(region)
st.title("Credit Card Transactions & Fraud Detection")
st.caption("Detecting fraud in digital channels is a challenge, due to the competing requirements of dealing with emerging attack vectors and delivering a smooth user experience. Security and risk management leaders must orchestrate multiple capabilities to create dynamic user journeys, while minimizing risk. Lets explore why most large businesses still require a dedicated fraud detection to secure there assets.")
st.caption("Payment fraud is already a billion dollar business, and it’s growing. When you look at the stats behind global online payment fraud, it’s no surprise that almost three quarters of businesses say it’s a major concern.")
st.caption("Lets study about Credit Card Transactions & Fraud Detection")
st.subheader("Dataset Information")
st.caption("Kaggle Credit Card Transactions & Fraud Detection Dataset . This is a simulated credit card transaction dataset containing legitimate and fraud transactions from the duration 1st Jan 2019 – 31st Dec 2020. It covers credit cards of 1000 customers doing transactions with a pool of 800 merchants. This was generated using Sparkov Data Generation | Github tool created by Brandon Harris. The files were combined and converted into a standard csv format. The dataset is highly unbalanced.")
st.write("[Kaggle Dataset link](https://www.kaggle.com/datasets/kartik2112/fraud-detection?select=fraudTrain.csv)")
st.subheader('Class Imbalance')
st.caption("A classification data set with skewed class proportions is called imbalanced. Classes that make up a large proportion of the data set are called majority classes. Those that make up a smaller proportion are minority classes.")
imbalance_stats = detect.plot_class_imbalance(field="CombinedData")
st.altair_chart(imbalance_stats, use_container_width=True)
st.subheader("Fraud Detection")
st.markdown(
"""
**Traditionally Businesses relied on rules alone to block fraudulent payments.**
There are many concerns
* Using a lots of rules tends to result in a high number of **False positives**
* The statistics of fraudulent behaviour can change over time.
* Using a rules-only approach means that your library must keep expanding as fraud evolves.
"""
)
st.caption("The modern day solution to the drawbacks of traditional rule-based fraud detection techniques is Artificial intelligence")
st.caption("Every online business wants to increase its transaction volume. With a rules only system, increasing amounts of payment and customer data puts more pressure on the rules library to expand. But with machine learning it’s the opposite – the more data the better.")
st.caption("Machine learning models are able to learn from patterns of normal behavior. They are very fast to adapt to changes in that normal behaviour and can quickly identify patterns of rapidly varying fraud transactions.")
st.subheader("Kaggle Credit Card Transactions & Fraud Detection Dataset")
us_states_fraudulent_transaction = detect.plot_us_states_fraudulent_transaction()
st.altair_chart(us_states_fraudulent_transaction, use_container_width=True)
us_region = st.selectbox(label="United States of America",
options=['All regions'] + detect.geo_states.region.unique().tolist())
with st.spinner("Preparing Map 🗺"):
geo_data_us_states = get_us_states(region=us_region)
st.pyplot(fig=geo_data_us_states, use_container_width=True)
selection = st.multiselect(
label='Choose a state to see the count of fraudulent transaction detected.',
options=detect.us_state_fraudulent_transaction['state'].unique(),
default=['MT', 'NY', 'CA', 'FL'], max_selections=5
)
st.pyplot(fig=detect.plot_selected_states(selection), use_container_width=True)
st.divider()
selected_state = st.selectbox(
"Select a state to see the number of fraudulent transaction at steet level ",
options=detect.us_state_fraudulent_transaction['state'].unique())
us_street_fraudulent_transaction = detect.plot_street_level_fraudulent_transaction(
selected_state)
st.altair_chart(us_street_fraudulent_transaction, use_container_width=True)