# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/JSJeong-me/KOSA-Big-Data_Vision/blob/main/Model/0924-card.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + id="VRN4vP-JPE_M"
import pandas as pd


# + id="YcgSyuwqPPqq"
df = pd.read_csv('credit_cards_dataset.csv')

# + colab={"base_uri": "https://localhost:8080/"} id="fH17xKFcPl75" outputId="3e1689f9-90c6-4993-a7c0-dda658098c09"
df.columns

# + colab={"base_uri": "https://localhost:8080/"} id="Ab9GObgZQHMB" outputId="5d2ebc46-c73f-4e12-e5e0-9480b87e19d5"
type(df)

# + id="K_n1WUISP-0i"
array = df.values

# + colab={"base_uri": "https://localhost:8080/"} id="M5n9eQmAQDjh" outputId="dcc6baa3-a25b-4122-a291-5afd5cc6ba79"
type(array)

# + colab={"base_uri": "https://localhost:8080/"} id="PovMSrtPQUSq" outputId="7ec5adbd-7606-43e9-898c-aee22bdb17a6"
array.shape

# + id="M1Bc8JSPRdDc"
X = array[:,0:24]

# + colab={"base_uri": "https://localhost:8080/"} id="Dx0jGyaJReQy" outputId="e820ab78-f192-45cf-fadf-323823ec5d2b"
X.shape

# + id="5_1ZzWp3Rlra"
Y = array[:,24] # array[:,24]

# + colab={"base_uri": "https://localhost:8080/"} id="_CRO0hW5R0Fq" outputId="fb08437f-6597-4e3c-94e1-bc3ec0984f30"
Y[:3]

# + id="N73luhluSD9q"
from sklearn.linear_model import LogisticRegression

# + id="gOuqnOqiSPt5"
from sklearn.feature_selection import RFE

# + id="CapZwGaGPhrR"
# feature extraction
model = LogisticRegression()
rfe = RFE(model, 10)
fit = rfe.fit(X, Y)

# + colab={"base_uri": "https://localhost:8080/"} id="u3fLpQsMSva3" outputId="96df9e1e-93bd-4097-f0f3-5a8d4c28e3ec"
print("Num Features: {}".format(fit.n_features_))
print("Selected Features:{}".format(fit.support_))
print("Feature Ranking: {}".format(fit.ranking_))

# + colab={"base_uri": "https://localhost:8080/", "height": 848} id="TBaXP_ruVMNW" outputId="2b6c7d9f-f9df-446b-c2ee-8a8e915dd3bf"
df.corr()

# + id="dnj4riQxVdLS"
import matplotlib.pyplot as plt

# + id="4c9CX4n5Vo9K"
import seaborn as sns

# + colab={"base_uri": "https://localhost:8080/", "height": 843} id="8ULWsl2NVSQO" outputId="abdcba9b-8210-41ad-fbaa-faa5d791773e"
plt.subplots(figsize=(26,20))
corr = df.corr()
sns.heatmap(corr,annot=True)
plt.show()

StarcoderdataJupyterScriptsDedupFiltered