SlideShare a Scribd company logo
1 of 60
Download to read offline
신용카드 이상거래 검출
-autoencoder-
DaeHyun,YoungJun
index
• FDS (Fraud Detection System)
• data EDA & visualization
• data cleaning
• data modeling - autoencoder
• result
공인인증서가 없는 세상
FDS(Fraud Detection System)
“ 이상 금융 거래 방지 시스템“
간편결제와 같은 금융환경의 변화에 맞춰 핀 테크의 중심으로
요약하자면
Rule Based System (낮은 정확도) -> DeepLearning 을 적용(높은 정확도)
이상 거래의 사전탐지율을 높이자!
간단한 신경망으로
이상거래를 찾아낼 수 있을까?
Input Output
autoencoder
이미지 잡음 제거, 차원축소, 이상치 감지에 효과적인 비지도학습 모델
encoder 를 통해 입력 데이터의 특징을 추출
decoder 를 통해 추출된 특징을
입력 데이터와 유사하게 복원
기본적인 학습 방법
(출력값 – 입력값) 이 0 에 가까워지도록
Input Output
minimize(output – input)
학습을 진행할수록 출력과 입력이 같아진다
(출력-입력 = 0 에 가까워진다)
학습 후 이상거래 데이터를 넣었을 때 학습한
데이터와 다르므로 출력이 커진다
임의의 임계값을 설정해 (출력-입력) > (임계값) 이
되면 이상거래라고 판단한다
어쨌든 Tensor로 구현해보자
step by step
data EDA
Use Kaggle Data
https://www.kaggle.com/mlg-ulb/creditcardfraud
• creditcard.csv
• 2013년 9월 중 이틀간 유럽 카드사의 실제 데이터
• 총 284,807 건의 트랜잭션 로그( 492건의 비정상 데이터)
• 데이터 분포의 불균형 (비정상 데이터 0.172%)
• 전체 31개 컬럼
• time, v1~v28(features), class(abnormal =1 else 0), amount 로 구성
• v1~v28 컬럼은 보안의 문제로 컬럼명이 모두 삭제됨
pandas 패키지를 이용해 csv 파일을 읽는다
null 값이 있는지 확인
데이터의 불균형 확인
시간에 따른 트랜잭션 양
금액별 트랜잭션 양
시간대별 트랜잭션 금액 사이에서도 별다른 특징점을 찾을 수 없다
각 컬럼별 값 분포 히스토그램 (blue : normal – orange: fraud)
값차이가 있는 feature 와 없는 feature 가 보인다
data EDA
data cleaning
데이터 정규화
데이터를 일정한 값 사이로 분포시켜 네트워크의 학습을 돕는다
Feature scaling
X’ = X- min(X) / max(X) – min(X)
모든 값을 0과1 사이의 값으로
df_norm = (df - df.min() ) / (df.max() - df.min() )
데이터 분할
train 데이터로는 학습을 test 데이터로 나눠 모델의 범용성을 평가
원본데이터 정규화
정상거래
데이터
이상거래
데이터
학습 데이터
(80%)
테스트 데이터
(20%)
테스트 데이터
셔플한 학습
데이터
셔플한 테스트
데이터
Matrix 형태로 변형
data EDA
data cleaning
data modeling
high level API 로 쉽게
모델링하자!
encoder
압축
.
.
.
28
.
.
.
20
.
.
.
14
.
.
10
X
(V1~V28)
encoder
X = tf.placeholder(tf.float32, [None,28])
입력 데이터 V1~V28 특징 컬럼
dense1=tf.layers.dense(inputs=X, units=20, activation=tf.nn.sigmoid)
dense2=tf.layers.dense(inputs=dense1, units=14, activation=tf.nn.sigmoid)
encoder = tf.layers.dense(inputs=dense2, units=10, activation=tf.nn.sigmoid)
decoder
복원
.
.
.
28
.
.
.
20
.
.
.
14
.
.
10
encoder
decoder
(V1’~V28`)
dense4 = tf.layers.dense(inputs=encoder, units=14, activation=tf.nn.sigmoid)
dense5 = tf.layers.dense(inputs=dense4, units=20, activation=tf.nn.sigmoid)
decoder = tf.layers.dense(inputs=dense5, units=28, activation=tf.nn.sigmoid)
optimize
tf.subtract(decoder,X)
cost = tf.reduce_sum(tf.square(tf.subtract(decoder,X)))
optimizer = tf.train.AdamOptimizer().minimize(cost)
빼기 출력 입력
training
epoch = 5
batch size = 500
learning rate = 0.001(default)
critical point(임계값) = 0.07
Data(cost)
임계값
임계값이 넘는 데이터를 이상거래로 판단한다
data EDA
data cleaning
data modeling
result!
test
492 개의 이상거래 데이터 중 447 개의 이상거래 검출(임계값 0.07)
다양한 임계값으로 테스트
임계값이 커질수록 검출을 못한다
개선점
• 비지도 학습에서의 평가지표, 시각화
• 불균형적 데이터의 처리 방법
• 파라미터 튜닝, 반복적 테스트
• 적절한 임계점을 찾을 수 있는 알고리즘 연구
Done!
아쉬워
이상거래로 검출된 데이터를 db 에 저장해보기
import SQLITE3
SQLite는 별도의 DB 서버가 필요없이 DB 파일에 기초하여
데이타베이스 처리를 구현한 Embedded SQL DB 엔진
이상거래라 판단되는 데이터를 하나씩 리스트에
담아준다
리스트를 DataFrame화 해준다
DataFrame을 만든 db 파일에 한번에 넣어준다
SQLITE3 를 사용해 db 파일을 만든다
maybefraud = pd.DataFrame(a_list)
con = sqlite3.connect("company.db")
maybefraud.to_sql('maybefraud’, con)
DB browser 로 확인
이상 거래로 의심되는 V1~V28 특징값이 잘 들어갔다
코드는 이곳에서
https://github.com/itwill009/deeplearning
자신감을 얻고 가세요
감사합니다!

More Related Content

What's hot

Conditional Random Fields
Conditional Random FieldsConditional Random Fields
Conditional Random Fieldslswing
 
Feature Engineering
Feature EngineeringFeature Engineering
Feature EngineeringSri Ambati
 
정수론적 알고리즘 - Sogang ICPC Team, 2020 Winter
정수론적 알고리즘 - Sogang ICPC Team, 2020 Winter정수론적 알고리즘 - Sogang ICPC Team, 2020 Winter
정수론적 알고리즘 - Sogang ICPC Team, 2020 WinterSuhyun Park
 
InternImage: Exploring Large-Scale Vision Foundation Models with Deformable C...
InternImage: Exploring Large-Scale Vision Foundation Models with Deformable C...InternImage: Exploring Large-Scale Vision Foundation Models with Deformable C...
InternImage: Exploring Large-Scale Vision Foundation Models with Deformable C...taeseon ryu
 
[기초개념] Graph Convolutional Network (GCN)
[기초개념] Graph Convolutional Network (GCN)[기초개념] Graph Convolutional Network (GCN)
[기초개념] Graph Convolutional Network (GCN)Donghyeon Kim
 
Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Graham Wihlidal
 
Meanshift Tracking Presentation
Meanshift Tracking PresentationMeanshift Tracking Presentation
Meanshift Tracking Presentationsandtouch
 
[MLOps KR 행사] MLOps 춘추 전국 시대 정리(210605)
[MLOps KR 행사] MLOps 춘추 전국 시대 정리(210605)[MLOps KR 행사] MLOps 춘추 전국 시대 정리(210605)
[MLOps KR 행사] MLOps 춘추 전국 시대 정리(210605)Seongyun Byeon
 
Introduction of Deep Reinforcement Learning
Introduction of Deep Reinforcement LearningIntroduction of Deep Reinforcement Learning
Introduction of Deep Reinforcement LearningNAVER Engineering
 
[261] 실시간 추천엔진 머신한대에 구겨넣기
[261] 실시간 추천엔진 머신한대에 구겨넣기[261] 실시간 추천엔진 머신한대에 구겨넣기
[261] 실시간 추천엔진 머신한대에 구겨넣기NAVER D2
 
우아하게 준비하는 테스트와 리팩토링 - PyCon Korea 2018
우아하게 준비하는 테스트와 리팩토링 - PyCon Korea 2018우아하게 준비하는 테스트와 리팩토링 - PyCon Korea 2018
우아하게 준비하는 테스트와 리팩토링 - PyCon Korea 2018Kenneth Ceyer
 
The Magic of Auto Differentiation
The Magic of Auto DifferentiationThe Magic of Auto Differentiation
The Magic of Auto DifferentiationSanyam Kapoor
 
기계학습 / 딥러닝이란 무엇인가
기계학습 / 딥러닝이란 무엇인가기계학습 / 딥러닝이란 무엇인가
기계학습 / 딥러닝이란 무엇인가Yongha Kim
 
알아두면 쓸데있는 신비한 딥러닝 이야기
알아두면 쓸데있는 신비한 딥러닝 이야기알아두면 쓸데있는 신비한 딥러닝 이야기
알아두면 쓸데있는 신비한 딥러닝 이야기Kwangsik Lee
 
Michal Erel's SIFT presentation
Michal Erel's SIFT presentationMichal Erel's SIFT presentation
Michal Erel's SIFT presentationwolf
 

What's hot (20)

Conditional Random Fields
Conditional Random FieldsConditional Random Fields
Conditional Random Fields
 
Deep learning
Deep learningDeep learning
Deep learning
 
Feature Engineering
Feature EngineeringFeature Engineering
Feature Engineering
 
1 Supervised learning
1 Supervised learning1 Supervised learning
1 Supervised learning
 
정수론적 알고리즘 - Sogang ICPC Team, 2020 Winter
정수론적 알고리즘 - Sogang ICPC Team, 2020 Winter정수론적 알고리즘 - Sogang ICPC Team, 2020 Winter
정수론적 알고리즘 - Sogang ICPC Team, 2020 Winter
 
Rendering Battlefield 4 with Mantle
Rendering Battlefield 4 with MantleRendering Battlefield 4 with Mantle
Rendering Battlefield 4 with Mantle
 
InternImage: Exploring Large-Scale Vision Foundation Models with Deformable C...
InternImage: Exploring Large-Scale Vision Foundation Models with Deformable C...InternImage: Exploring Large-Scale Vision Foundation Models with Deformable C...
InternImage: Exploring Large-Scale Vision Foundation Models with Deformable C...
 
[기초개념] Graph Convolutional Network (GCN)
[기초개념] Graph Convolutional Network (GCN)[기초개념] Graph Convolutional Network (GCN)
[기초개념] Graph Convolutional Network (GCN)
 
Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016
 
Meanshift Tracking Presentation
Meanshift Tracking PresentationMeanshift Tracking Presentation
Meanshift Tracking Presentation
 
[MLOps KR 행사] MLOps 춘추 전국 시대 정리(210605)
[MLOps KR 행사] MLOps 춘추 전국 시대 정리(210605)[MLOps KR 행사] MLOps 춘추 전국 시대 정리(210605)
[MLOps KR 행사] MLOps 춘추 전국 시대 정리(210605)
 
Introduction of Deep Reinforcement Learning
Introduction of Deep Reinforcement LearningIntroduction of Deep Reinforcement Learning
Introduction of Deep Reinforcement Learning
 
[261] 실시간 추천엔진 머신한대에 구겨넣기
[261] 실시간 추천엔진 머신한대에 구겨넣기[261] 실시간 추천엔진 머신한대에 구겨넣기
[261] 실시간 추천엔진 머신한대에 구겨넣기
 
Data Preprocessing
Data PreprocessingData Preprocessing
Data Preprocessing
 
우아하게 준비하는 테스트와 리팩토링 - PyCon Korea 2018
우아하게 준비하는 테스트와 리팩토링 - PyCon Korea 2018우아하게 준비하는 테스트와 리팩토링 - PyCon Korea 2018
우아하게 준비하는 테스트와 리팩토링 - PyCon Korea 2018
 
The Magic of Auto Differentiation
The Magic of Auto DifferentiationThe Magic of Auto Differentiation
The Magic of Auto Differentiation
 
기계학습 / 딥러닝이란 무엇인가
기계학습 / 딥러닝이란 무엇인가기계학습 / 딥러닝이란 무엇인가
기계학습 / 딥러닝이란 무엇인가
 
알아두면 쓸데있는 신비한 딥러닝 이야기
알아두면 쓸데있는 신비한 딥러닝 이야기알아두면 쓸데있는 신비한 딥러닝 이야기
알아두면 쓸데있는 신비한 딥러닝 이야기
 
Autonomous Tello Drone ASU
Autonomous Tello Drone ASUAutonomous Tello Drone ASU
Autonomous Tello Drone ASU
 
Michal Erel's SIFT presentation
Michal Erel's SIFT presentationMichal Erel's SIFT presentation
Michal Erel's SIFT presentation
 

Similar to 딥러닝으로 구현한 이상거래탐지시스템

Tensorflow for Deep Learning(SK Planet)
Tensorflow for Deep Learning(SK Planet)Tensorflow for Deep Learning(SK Planet)
Tensorflow for Deep Learning(SK Planet)Tae Young Lee
 
딥러닝을 위한 Tensor flow(skt academy)
딥러닝을 위한 Tensor flow(skt academy)딥러닝을 위한 Tensor flow(skt academy)
딥러닝을 위한 Tensor flow(skt academy)Tae Young Lee
 
what is deep learning?
what is deep learning? what is deep learning?
what is deep learning? PartPrime
 
머신러닝 프로젝트 - LSTM을 이용한 주가(KODEX200) 예측
머신러닝 프로젝트 - LSTM을 이용한 주가(KODEX200) 예측머신러닝 프로젝트 - LSTM을 이용한 주가(KODEX200) 예측
머신러닝 프로젝트 - LSTM을 이용한 주가(KODEX200) 예측PARK SUNGMIN
 
HR Analytics - 퇴직가능성예측모델
HR Analytics - 퇴직가능성예측모델HR Analytics - 퇴직가능성예측모델
HR Analytics - 퇴직가능성예측모델Seong-Bok Lee
 
Adversarial Attack in Neural Machine Translation
Adversarial Attack in Neural Machine TranslationAdversarial Attack in Neural Machine Translation
Adversarial Attack in Neural Machine TranslationHyunKyu Jeon
 
[코세나, kosena] 금융권의 머신러닝 활용사례
[코세나, kosena] 금융권의 머신러닝 활용사례[코세나, kosena] 금융권의 머신러닝 활용사례
[코세나, kosena] 금융권의 머신러닝 활용사례kosena
 
Anomaly detection practive_using_deep_learning
Anomaly detection practive_using_deep_learningAnomaly detection practive_using_deep_learning
Anomaly detection practive_using_deep_learning도형 임
 
머신러닝(딥러닝 요약)
머신러닝(딥러닝 요약)머신러닝(딥러닝 요약)
머신러닝(딥러닝 요약)Byung-han Lee
 
R을 이용한 데이터 분석
R을 이용한 데이터 분석R을 이용한 데이터 분석
R을 이용한 데이터 분석simon park
 
Graph attention network - deep learning paper review
Graph attention network -  deep learning paper reviewGraph attention network -  deep learning paper review
Graph attention network - deep learning paper reviewtaeseon ryu
 
링크드인의 Big Data Recommendation Products - 어제의 데이터를 통해 내일을 예측한다
링크드인의 Big Data Recommendation Products - 어제의 데이터를 통해 내일을 예측한다링크드인의 Big Data Recommendation Products - 어제의 데이터를 통해 내일을 예측한다
링크드인의 Big Data Recommendation Products - 어제의 데이터를 통해 내일을 예측한다Evion Kim
 
기계학습 Overview
기계학습  Overview기계학습  Overview
기계학습 Overviewjaeho kang
 
Python machine learning Ch.4
Python machine learning Ch.4Python machine learning Ch.4
Python machine learning Ch.4PartPrime
 
인공지능 맛보기
인공지능 맛보기인공지능 맛보기
인공지능 맛보기Park JoongSoo
 
Workshop 210417 dhlee
Workshop 210417 dhleeWorkshop 210417 dhlee
Workshop 210417 dhleeDongheon Lee
 
Spark & Zeppelin을 활용한 머신러닝 실전 적용기
Spark & Zeppelin을 활용한 머신러닝 실전 적용기Spark & Zeppelin을 활용한 머신러닝 실전 적용기
Spark & Zeppelin을 활용한 머신러닝 실전 적용기Taejun Kim
 

Similar to 딥러닝으로 구현한 이상거래탐지시스템 (20)

Tensorflow for Deep Learning(SK Planet)
Tensorflow for Deep Learning(SK Planet)Tensorflow for Deep Learning(SK Planet)
Tensorflow for Deep Learning(SK Planet)
 
딥러닝을 위한 Tensor flow(skt academy)
딥러닝을 위한 Tensor flow(skt academy)딥러닝을 위한 Tensor flow(skt academy)
딥러닝을 위한 Tensor flow(skt academy)
 
what is deep learning?
what is deep learning? what is deep learning?
what is deep learning?
 
머신러닝 프로젝트 - LSTM을 이용한 주가(KODEX200) 예측
머신러닝 프로젝트 - LSTM을 이용한 주가(KODEX200) 예측머신러닝 프로젝트 - LSTM을 이용한 주가(KODEX200) 예측
머신러닝 프로젝트 - LSTM을 이용한 주가(KODEX200) 예측
 
HR Analytics - 퇴직가능성예측모델
HR Analytics - 퇴직가능성예측모델HR Analytics - 퇴직가능성예측모델
HR Analytics - 퇴직가능성예측모델
 
Ml
MlMl
Ml
 
Adversarial Attack in Neural Machine Translation
Adversarial Attack in Neural Machine TranslationAdversarial Attack in Neural Machine Translation
Adversarial Attack in Neural Machine Translation
 
[코세나, kosena] 금융권의 머신러닝 활용사례
[코세나, kosena] 금융권의 머신러닝 활용사례[코세나, kosena] 금융권의 머신러닝 활용사례
[코세나, kosena] 금융권의 머신러닝 활용사례
 
Anomaly detection practive_using_deep_learning
Anomaly detection practive_using_deep_learningAnomaly detection practive_using_deep_learning
Anomaly detection practive_using_deep_learning
 
머신러닝(딥러닝 요약)
머신러닝(딥러닝 요약)머신러닝(딥러닝 요약)
머신러닝(딥러닝 요약)
 
R을 이용한 데이터 분석
R을 이용한 데이터 분석R을 이용한 데이터 분석
R을 이용한 데이터 분석
 
Graph attention network - deep learning paper review
Graph attention network -  deep learning paper reviewGraph attention network -  deep learning paper review
Graph attention network - deep learning paper review
 
링크드인의 Big Data Recommendation Products - 어제의 데이터를 통해 내일을 예측한다
링크드인의 Big Data Recommendation Products - 어제의 데이터를 통해 내일을 예측한다링크드인의 Big Data Recommendation Products - 어제의 데이터를 통해 내일을 예측한다
링크드인의 Big Data Recommendation Products - 어제의 데이터를 통해 내일을 예측한다
 
기계학습 Overview
기계학습  Overview기계학습  Overview
기계학습 Overview
 
Naive ML Overview
Naive ML OverviewNaive ML Overview
Naive ML Overview
 
Python machine learning Ch.4
Python machine learning Ch.4Python machine learning Ch.4
Python machine learning Ch.4
 
인공지능 맛보기
인공지능 맛보기인공지능 맛보기
인공지능 맛보기
 
Workshop 210417 dhlee
Workshop 210417 dhleeWorkshop 210417 dhlee
Workshop 210417 dhlee
 
Spark & Zeppelin을 활용한 머신러닝 실전 적용기
Spark & Zeppelin을 활용한 머신러닝 실전 적용기Spark & Zeppelin을 활용한 머신러닝 실전 적용기
Spark & Zeppelin을 활용한 머신러닝 실전 적용기
 
분석6기 4조
분석6기 4조분석6기 4조
분석6기 4조
 

딥러닝으로 구현한 이상거래탐지시스템