image_output_1.png
from contextlib import contextmanager

import matplotlib.pyplot as plt

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import plotly.graph_objs as go

import plotly.offline as py

import seaborn as sns

import warnings

df_cred = pd.read_csv('/kaggle/input/creditcardfraud/creditcard.csv')

df_cred.shape

from scipy.stats import randint as sp_randint
from scipy.stats import uniform as sp_uniform
import warnings
import plotly.offline as py
py.init_notebook_mode(connected=True)
import plotly.graph_objs as go
import plotly.tools as tls
import plotly.figure_factory as ff
warnings.filterwarnings('ignore')
from contextlib import contextmanager
@contextmanager
def timer(title):
    t0 = time.time()
    yield

plt.style.use('ggplot') # Using ggplot2 style visuals 

f, ax = plt.subplots(figsize=(11, 15))

ax.set_facecolor('#fafafa')
ax.set(xlim=(-5, 5))
plt.ylabel('Variables')
plt.title("Overview Data Set")
ax = sns.boxplot(data = df_cred.drop(columns=['Amount', 'Class', 'Time']), 
  orient = 'h', 
  palette = 'Set2')

fraud = df_cred[df_cred['Class'] != 0]
normal = df_cred[df_cred['Class'] == 0]
trace = go.Pie(labels=['Normal', 'Fraud'], values=df_cred['Class'].value_counts(), textfont=dict(size=15), opacity=0.8, marker=dict(colors=['lightskyblue', 'gold'], line=dict(color='#000000', width=1.5)))
layout = dict(title='Distribution of target variable')
fig = dict(data=[trace], layout=layout)
py.iplot(fig)