<jupyter_start><jupyter_text>Credit Card Fraud Analysis and Detection--- Problem Identification Problem statementHow can credit card companies detect up to 90% of fraudulent transactions? ContextCredit card companies get a small percentage of fraudulent charges but those transactions result in many hours of work and lost revenue. They would like to have a model to use to detect fraud before the charges are processed. Criteria for successDetect 90% of fraudulent transactions. Scope of solution spaceThis project only applies to credit card charges by XYZ Credit Union (i.e., the Kaggle dataset). Constraints within solution spaceDue to privacy, the dataset was put through Principle Component Analysis (PCA) and anonymized.  Stakeholders* Executives from XYZ Credit Union* Chief Technology Officer Key data sources- [Credit Card Fraud Detection Kaggle dataset](https://www.kaggle.com/mlg-ulb/creditcardfraud) --- Environment setup<jupyter_code>import os
import pandas as pd
import datetime
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

%matplotlib inline

sns.set('notebook')<jupyter_output><empty_output><jupyter_text>--- Data Wrangling  Data Collection<jupyter_code># Read CSV to Dataframe
df = pd.read_csv('../data/raw/creditcard.csv')
# Inspect the data
df.head()<jupyter_output><empty_output><jupyter_text>Data OrganizationProject based on the [cookiecutter data science project template](https://drivendata.github.io/cookiecutter-data-science/).  Data Definition<jupyter_code># Review the columns
df.columns
# Review the types
df.dtypes<jupyter_output><empty_output><jupyter_text>All data seems to be in the expected format. No cleaning work to be done here.<jupyter_code># Inspect the entire Dataframe
df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 284807 entries, 0 to 284806
Data columns (total 31 columns):
 #   Column  Non-Null Count   Dtype  
---  ------  --------------   -----  
 0   Time    284807 non-null  float64
 1   V1      284807 non-null  float64
 2   V2      284807 non-null  float64
 3   V3      284807 non-null  float64
 4   V4      284807 non-null  float64
 5   V5      284807 non-null  float64
 6   V6      284807 non-null  float64
 7   V7      284807 non-null  float64
 8   V8      284807 non-null  float64
 9   V9      284807 non-null  float64
 10  V10     284807 non-null  float64
 11  V11     284807 non-null  float64
 12  V12     284807 non-null  float64
 13  V13     284807 non-null  float64
 14  V14     284807 non-null  float64
 15  V15     284807 non-null  float64
 16  V16     284807 non-null  float64
 17  V17     284807 non-null  float64
 18  V18     284807 non-null  float64
 19  V19     284807 non-null  float64
 20  V20     284807 non-null  float64
 21  V21     28[...]<jupyter_text>No missing values. No cleanup work to be done.<jupyter_code># Inspect the percent of unique values per column
df.nunique() / 284807 * 100<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06910569105691057, 'fraction_numerical': 0.08976964769647697, 'mean_word_length': 3.543076923076923, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '260491', 'license': 'MIT', 'n_tokens_mistral': 1093, 'n_tokens_neox': 917, 'n_words': 341, 'path': 'notebooks/1.0-cjm-initial.ipynb', 'repo_name': 'chrisjm/Springboard-Capstone-Two', 'size': '2952'}