text_html_output_1.png
from sklearn import preprocessing

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 seaborn as sns

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

df_cred.shape

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')

min_max_scaler = preprocessing.MinMaxScaler()
df_cred = df_cred.drop('Time', axis=1)
df_cred_scaled = min_max_scaler.fit_transform(df_cred.iloc[:, :-1])
df_cred_normalized = pd.DataFrame(df_cred_scaled)

df_cred_normalized_train = df_cred_normalized[df_cred_normalized['Class'] == 0]
df_cred_normalized_test = df_cred_normalized[df_cred_normalized['Class'] == 1]

df_cred_normalized_test_part_1 = df_cred_normalized_train.sample(frac=0.05)
df_cred_normalized_train = df_cred_normalized_train.drop(df_cred_normalized_test_part_1.index)
df_cred_normalized_test_part_2 = df_cred_normalized_train.sample(frac=0.05)
df_cred_normalized_train = df_cred_normalized_train.drop(df_cred_normalized_test_part_2.index)

df_cred_normalized_test_class_1 = df_cred_normalized_test.sample(frac=0.5)
df_cred_normalized_validation_class_1 = df_cred_normalized_test.drop(df_cred_normalized_test_class_1.index)

df_cred_normalized_test_class_1.shape

df_cred_normalized_test_set = df_cred_normalized_test_part_1.append(df_cred_normalized_test_class_1)
df_cred_normalized_validation_set = df_cred_normalized_test_part_2.append(df_cred_normalized_validation_class_1)

print('train set dimensions :', df_cred_normalized_train.shape)
print('test set dimensions :', df_cred_normalized_test_set.shape)
print('validate set dimensions :', df_cred_normalized_validation_set.shape)