๊ธฐ์ด ํ๋ก์ ํธ : ์ํ ๊ณ ๊ฐ๋ฐ์ดํฐ๋ฅผ ์ด์ฉํ ์๋น์ค ๋ถ์
ํ๋ก์ ํธ ๊ฐ์
- ๋ถ์ ๋ชฉ์ : ์ํ ๊ณ ๊ฐ๋ฐ์ดํฐ๋ฅผ ์ด์ฉํด ์๋น์ค์ ํํฉ์ ๋ถ์ํ๊ณ ๊ณ ๊ฐ์ ๋ถ๋ฅํ๊ธฐ.
- ๋ฐ์ดํฐ ์์ง : Kaggle
๋ฐ์ดํฐ ์๊ฐ
Bank User Dataset
This dataset contains user behaviors contributing to their credit score
www.kaggle.com
โ ์ ์ฒด ์ปฌ๋ผ ์ : 50,000๊ฐ (๊ฐ์ ๊ณ ๊ฐ์ 9,10,11,12์์น ๋ฐ์ดํฐ๊ฐ ๋ค์ด์์ด ์ค์ total_user์ ์๋ 12,500๋ช )
๐ก ์ด๋ ค์ ๋ ์
- int, float ํ์ ์ ๋ฐ์ดํฐ์ฌ์ผ ํ ๊ฒ๋ค์ด ์ธ๋๋ฐ๊ฐ ๋ถ๋(์ด์๊ฐ) ๊ฒฝ์ฐ๊ฐ ๋ง์ ์ด๋ฅผ ์ ์ ํ ์์๋ด๊ธฐ ์ด๋ ค์.
- ๋ฐ์ดํฐ description์ด ์๋ค ๋ณด๋ ๋ฐ์ดํฐ ์์ฒด๋ฅผ ์ดํดํ๋๋ฐ ์ด๋ ค์
- ๋ฐ์ดํฐ๊ฐ ๊ธฐ๋ฐํ๊ณ ์๋ ๋ฏธ๊ตญ์ ์ํ ๊ณ์ข ๊ฐ์ค ์ฒด๊ณ์ ์ฐ๋ฆฌ๋๋ผ์ ์ฒด๊ณ๊ฐ ๋ฌ๋ผ ์ด๋ฅผ ์ดํดํ๋๋ฐ ์ด๋ ค์ ์
์ ์ฒ๋ฆฌ
1. ํ์ํ ์ปฌ๋ผ๋ง ๊ณจ๋ผ์ ํ์ฉ
# ํ์ํ ์ปฌ๋ผ๋ง ์ ํ (์ด 27๊ฐ ์ค 22๊ฐ ์ฌ์ฉ)
bank = bank.drop(['Name','SSN','Monthly_Inhand_Salary','Changed_Credit_Limit',
'Num_Credit_Inquiries'], axis = 1)
# ์ฌ์ฉํ ์ปฌ๋ผ
bank.columns
## Index(['ID', 'Customer_ID', 'Month', 'Age', 'Occupation', 'Annual_Income',
## 'Num_Bank_Accounts', 'Num_Credit_Card', 'Interest_Rate', 'Num_of_Loan',
## 'Type_of_Loan', 'Delay_from_due_date', 'Num_of_Delayed_Payment',
## 'Credit_Mix', 'Outstanding_Debt', 'Credit_Utilization_Ratio',
## 'Credit_History_Age', 'Payment_of_Min_Amount', 'Total_EMI_per_month',
## 'Amount_invested_monthly', 'Payment_Behaviour', 'Monthly_Balance'],dtype='object')
→ ์ ์ฒด 27๊ฐ์ ์ปฌ๋ผ ์ค 22๊ฐ์ ์ปฌ๋ผ๋ง ์ ํ.
2. del_underbar_int/ del_underbar_float ํจ์ ๋ง๋ค๊ธฐ
์ธ๋๋ฐ๊ฐ ํฌํจ๋ int, float ํ์ ์ด์ด์ผ ํ๋ ๋ฐ์ดํฐ๋ค์ ์๋ ๋ฐ์ดํฐ ํ์ ์ผ๋ก ๋ฐ๊ฟ์ผํ๋๋ฐ, for๋ฌธ์ ์ด์ฉํ ์์ ์ ๋ฐ๋ณตํ๋๊ฒ์ด ๋ฒ๊ฑฐ๋กญ๋ค๊ณ ๋๊ปด์ ธ์ ํจ์๋ฅผ ์ ์ํ๋ค.
def del_underbar_int(data, col):
for i, x in enumerate(data[col]):
if pd.notnull(x) and '_' in x:
data.at[i, col] = x.strip('_')
data[col] = data[col].fillna(0).astype('int64')
def del_underbar_float(data, col):
for i, x in enumerate(data[col]):
if pd.notnull(x) and '_' in x:
data.at[i, col] = x.strip('_')
data[col] = data[col].fillna(0).astype('float')
๋ค์ ๊ณผ์
โ ์ด๋ป๊ฒ Null ๊ฐ์ ์ฑ์๋ฃ์์ง ๊ณ ๋ฏผ!
โ ์๊ฐํ ํด๋ณด๊ธฐ (Null๊ฐ์ ์ฑ์๋ฃ์ง ๋ชปํ๋ค๋ฉด ๊ทธ๊ฒ์ ์ ์ธํ๊ณ ์๋ผ๋!)