소품집

[KT AIVLE] 에이블스쿨 미니프로젝트 3차 회고 + Kaggle 13등!! 본문

AI/KT 에이블스쿨

[KT AIVLE] 에이블스쿨 미니프로젝트 3차 회고 + Kaggle 13등!!

sodayeong 2022. 9. 28. 01:34

안녕하세요!

오늘은 KT 에이블스쿨 3차 미니프로젝트 회고를 해보려고 합니다. 

 

이번 3차 미니프로젝트에서 가장 기억에 남았던 세션이었던 Kaggle competition에서

악성 코드 탐지 모델 개발을 주제로 진행됐는데요, 저는 이번 대회에서 13등을 했습니다!!

 

 

 

점심 먹기전엔 4등이었는데... 금세 밀려나는 게 재밌더라고요  

 

오랜만에 전공지식 다 꺼내기 + 구글링 + 도메인 빠르게 확보.. 해서

10등에서 제발 내려가지 마라!! 했지만.. 어림도 없지 앞으로 치고 나오는 에이블러분들..ㅎㅎ...

 

한없이 겸손해지는 이번 대회였습니다. 

앞으로도 경진대회 많이 했으면 좋겠어요!!ㅋㅋㅋ

 

 

 

 

* 더 자세한 코드는 제 Github에 올려두었습니다. 

https://github.com/sodayeong/AIVLE-School-3rd-Miniproject-Competition

 

GitHub - sodayeong/AIVLE-School-3rd-Miniproject-Competition: KT 에이블스쿨 kaggle review

KT 에이블스쿨 kaggle review. Contribute to sodayeong/AIVLE-School-3rd-Miniproject-Competition development by creating an account on GitHub.

github.com

 

 

# 라이브러리 로드
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import scipy.stats as spst
import statsmodels.api as sm
import lightgbm as lgb

%config InlineBackend.figure_format = 'retina' # plot 해상도 업

# 데이터 불러오기
train_row = pd.read_csv('train_dataset.csv')
test_row = pd.read_csv('test_dataset_v01.csv')

print(train_row.shape) # (3664, 25)
print(test_row.shape) # (2441, 24)

# 복사본 생성
train = train_row.copy()
test = test_row.copy()

## 데이터 전처리 
train.drop(columns='Unnamed: 0',axis=1, inplace=True)
test.drop(columns='Unnamed: 0', axis=1, inplace=True)

# target (정상, 불량) > (0,1) 로 변환
train.replace({'Result_v1':'malicious'}, 0, inplace=True)
train.replace({'Result_v1':'benign'}, 1, inplace=True)

## 결측치 파악 
train.info()
train.isna().sum()

test.info()
test.isna().sum()

train["html_num_tags('form')"].describe() # 통계치 파악
train.nunique() # 고유값 개수 파악 

test.nunique()

[train] 각 feature에 한 개씩 결측치가 있음.
- url_path_len 1개
- url_domain_len 1개

[test] 많은 feature에 다중으로 결측치 분포
- 최빈값으로 대체할까

 

[train / test] Url_chinese_presen와 html_num_tags('applet')은 원소의 개수가 한 개임. 
- 즉, 영향이 없는 변수임
- 이들을 제거해줄지 말지를 판별해야함 > 난 삭제할래

## 단변량 분석
- 정상과 불량에 대한 히스토그램 비교 (length 와 number)
- 모든 분포 그래프에서 최빈값의 차이가 많이 남.


train.columns

# Index(['url_len', 'url_num_hyphens_dom', 'url_path_len', 'url_domain_len',
       'url_hostname_len', 'url_num_dots', 'url_num_underscores',
       'url_query_len', 'url_num_query_para', 'url_ip_present', 'url_entropy',
       'url_chinese_present', 'url_port', 'html_num_tags('iframe')',
       'html_num_tags('script')', 'html_num_tags('embed')',
       'html_num_tags('object')', 'html_num_tags('div')',
       'html_num_tags('head')', 'html_num_tags('body')',
       'html_num_tags('form')', 'html_num_tags('a')',
       'html_num_tags('applet')', 'Result_v1'],
      dtype='object')
      
plt.figure(figsize=(10,7))
plt.subplot(2,2,1)
sns.kdeplot(data=train, x='url_len', hue='Result_v1')

plt.subplot(2,2,2)
sns.kdeplot(data=train, x='url_num_hyphens_dom', hue='Result_v1')

plt.subplot(2,2,3)
sns.kdeplot(data=train, x='url_path_len', hue='Result_v1')

plt.subplot(2,2,4)
sns.kdeplot(data=train, x='url_domain_len', hue='Result_v1')
plt.show()
      
plt.figure(figsize=(10,7))
plt.subplot(2,2,1)
sns.kdeplot(data=train, x='url_hostname_len', hue='Result_v1')

plt.subplot(2,2,2)
sns.kdeplot(data=train, x='url_num_dots', hue='Result_v1')

plt.subplot(2,2,3)
sns.kdeplot(data=train, x='url_num_underscores', hue='Result_v1')

plt.subplot(2,2,4)
sns.kdeplot(data=train, x='url_query_len', hue='Result_v1')
plt.show()

plt.figure(figsize=(10,7))
plt.subplot(2,2,1)
sns.kdeplot(data=train, x='url_num_query_para', hue='Result_v1')

plt.subplot(2,2,2)
sns.kdeplot(data=train, x='url_ip_present', hue='Result_v1')

plt.subplot(2,2,3)
sns.kdeplot(data=train, x='url_entropy', hue='Result_v1')

 


 

더 자세한 코드는 Github 에 올려두었습니다. 

 

* 매니저님께 이번 미프에서 한 캐글을 코드 리뷰 형식으로 리뷰해도 되는지 여쭤봤는데, 가능하다고 하셔서

올려봅니다. (❁´◡`❁)

728x90
Comments