text_plain_output_1.png
from sklearn.feature_selection import chi2, SelectKBest

from sklearn.preprocessing import LabelEncoder

from sklearn.preprocessing import MinMaxScaler

import matplotlib.pyplot as plt

import numpy as np

import numpy as np # linear algebra

import pandas as pd

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

import seaborn as sns

dataset = pd.read_csv('../input/financial-dataset-for-fraud-detection-in-a-comapny/Fraud.csv')

dataset.shape

dataset.nunique().sort_values(ascending=True)

target = 'isFraud'
features = [feature for feature in dataset.columns if feature not in [target]]

dataset.isna().sum()

pd.set_option('display.float_format', '{:.2f}'.format)

from sklearn.preprocessing import LabelEncoder
encoder = {}
for i in dataset.select_dtypes('object').columns:
    encoder[i] = LabelEncoder()
    dataset[i] = encoder[i].fit_transform(dataset[i])

x = dataset.drop(columns=['isFraud'])
y = dataset['isFraud']

y.value_counts()

y.value_counts()

from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
x = scaler.fit_transform(x)

best_feat = SelectKBest(chi2, k=8)
kbest = best_feat.fit_transform(x, y)
np.array(dataset.drop(columns=['isFraud']).columns)[best_feat.get_support()]