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

Les réseaux de neurones convolutifs CNN
Les réseaux de neurones convolutifs CNNLes réseaux de neurones convolutifs CNN
Les réseaux de neurones convolutifs CNNSALMARACHIDI1
 
Deep Learning as a Cat/Dog Detector
Deep Learning as a Cat/Dog DetectorDeep Learning as a Cat/Dog Detector
Deep Learning as a Cat/Dog DetectorRoelof Pieters
 
AnoGAN을 이용한 철강 소재 결함 검출 AI
AnoGAN을 이용한 철강 소재 결함 검출 AIAnoGAN을 이용한 철강 소재 결함 검출 AI
AnoGAN을 이용한 철강 소재 결함 검출 AIHYEJINLIM10
 
論文紹介:InternVideo: General Video Foundation Models via Generative and Discrimi...
論文紹介:InternVideo: General Video Foundation Models via Generative and Discrimi...論文紹介:InternVideo: General Video Foundation Models via Generative and Discrimi...
論文紹介:InternVideo: General Video Foundation Models via Generative and Discrimi...Toru Tamaki
 
[MIRU2018] Global Average Poolingの特性を用いたAttention Branch Network
[MIRU2018] Global Average Poolingの特性を用いたAttention Branch Network[MIRU2018] Global Average Poolingの特性を用いたAttention Branch Network
[MIRU2018] Global Average Poolingの特性を用いたAttention Branch NetworkHiroshi Fukui
 
Introduction au traitement d'images
Introduction au traitement d'imagesIntroduction au traitement d'images
Introduction au traitement d'imagesAbdelouahed Abdou
 
MixMatch: A Holistic Approach to Semi- Supervised Learning
MixMatch: A Holistic Approach to Semi- Supervised LearningMixMatch: A Holistic Approach to Semi- Supervised Learning
MixMatch: A Holistic Approach to Semi- Supervised Learningharmonylab
 
NIPS2013読み会 DeViSE: A Deep Visual-Semantic Embedding Model
NIPS2013読み会 DeViSE: A Deep Visual-Semantic Embedding ModelNIPS2013読み会 DeViSE: A Deep Visual-Semantic Embedding Model
NIPS2013読み会 DeViSE: A Deep Visual-Semantic Embedding ModelSeiya Tokui
 
Using Deep Learning to Find Similar Dresses
Using Deep Learning to Find Similar DressesUsing Deep Learning to Find Similar Dresses
Using Deep Learning to Find Similar DressesHJ van Veen
 
Emerging Properties in Self-Supervised Vision Transformers
Emerging Properties in Self-Supervised Vision TransformersEmerging Properties in Self-Supervised Vision Transformers
Emerging Properties in Self-Supervised Vision TransformersSungchul Kim
 
文献紹介:CutDepth: Edge-aware Data Augmentation in Depth Estimation
文献紹介:CutDepth: Edge-aware Data Augmentation in Depth Estimation文献紹介:CutDepth: Edge-aware Data Augmentation in Depth Estimation
文献紹介:CutDepth: Edge-aware Data Augmentation in Depth EstimationToru Tamaki
 
You only look once: Unified, real-time object detection (UPC Reading Group)
You only look once: Unified, real-time object detection (UPC Reading Group)You only look once: Unified, real-time object detection (UPC Reading Group)
You only look once: Unified, real-time object detection (UPC Reading Group)Universitat Politècnica de Catalunya
 
제 15회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [YouPlace 팀] : 카프카와 스파크를 활용한 유튜브 영상 속 제주 명소 검색
제 15회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [YouPlace 팀] : 카프카와 스파크를 활용한 유튜브 영상 속 제주 명소 검색 제 15회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [YouPlace 팀] : 카프카와 스파크를 활용한 유튜브 영상 속 제주 명소 검색
제 15회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [YouPlace 팀] : 카프카와 스파크를 활용한 유튜브 영상 속 제주 명소 검색 BOAZ Bigdata
 
Convolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep LearningConvolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep LearningMohamed Loey
 
20191215 rate distortion theory and VAEs
20191215 rate distortion theory and VAEs20191215 rate distortion theory and VAEs
20191215 rate distortion theory and VAEsX 37
 
Object classification using CNN & VGG16 Model (Keras and Tensorflow)
Object classification using CNN & VGG16 Model (Keras and Tensorflow) Object classification using CNN & VGG16 Model (Keras and Tensorflow)
Object classification using CNN & VGG16 Model (Keras and Tensorflow) Lalit Jain
 
Deep generative model.pdf
Deep generative model.pdfDeep generative model.pdf
Deep generative model.pdfHyungjoo Cho
 
Convolutional neural network
Convolutional neural network Convolutional neural network
Convolutional neural network Yan Xu
 

What's hot (20)

Les réseaux de neurones convolutifs CNN
Les réseaux de neurones convolutifs CNNLes réseaux de neurones convolutifs CNN
Les réseaux de neurones convolutifs CNN
 
Deep Learning as a Cat/Dog Detector
Deep Learning as a Cat/Dog DetectorDeep Learning as a Cat/Dog Detector
Deep Learning as a Cat/Dog Detector
 
AnoGAN을 이용한 철강 소재 결함 검출 AI
AnoGAN을 이용한 철강 소재 결함 검출 AIAnoGAN을 이용한 철강 소재 결함 검출 AI
AnoGAN을 이용한 철강 소재 결함 검출 AI
 
論文紹介:InternVideo: General Video Foundation Models via Generative and Discrimi...
論文紹介:InternVideo: General Video Foundation Models via Generative and Discrimi...論文紹介:InternVideo: General Video Foundation Models via Generative and Discrimi...
論文紹介:InternVideo: General Video Foundation Models via Generative and Discrimi...
 
[MIRU2018] Global Average Poolingの特性を用いたAttention Branch Network
[MIRU2018] Global Average Poolingの特性を用いたAttention Branch Network[MIRU2018] Global Average Poolingの特性を用いたAttention Branch Network
[MIRU2018] Global Average Poolingの特性を用いたAttention Branch Network
 
Introduction au traitement d'images
Introduction au traitement d'imagesIntroduction au traitement d'images
Introduction au traitement d'images
 
MixMatch: A Holistic Approach to Semi- Supervised Learning
MixMatch: A Holistic Approach to Semi- Supervised LearningMixMatch: A Holistic Approach to Semi- Supervised Learning
MixMatch: A Holistic Approach to Semi- Supervised Learning
 
NIPS2013読み会 DeViSE: A Deep Visual-Semantic Embedding Model
NIPS2013読み会 DeViSE: A Deep Visual-Semantic Embedding ModelNIPS2013読み会 DeViSE: A Deep Visual-Semantic Embedding Model
NIPS2013読み会 DeViSE: A Deep Visual-Semantic Embedding Model
 
Using Deep Learning to Find Similar Dresses
Using Deep Learning to Find Similar DressesUsing Deep Learning to Find Similar Dresses
Using Deep Learning to Find Similar Dresses
 
Emerging Properties in Self-Supervised Vision Transformers
Emerging Properties in Self-Supervised Vision TransformersEmerging Properties in Self-Supervised Vision Transformers
Emerging Properties in Self-Supervised Vision Transformers
 
文献紹介:CutDepth: Edge-aware Data Augmentation in Depth Estimation
文献紹介:CutDepth: Edge-aware Data Augmentation in Depth Estimation文献紹介:CutDepth: Edge-aware Data Augmentation in Depth Estimation
文献紹介:CutDepth: Edge-aware Data Augmentation in Depth Estimation
 
You only look once: Unified, real-time object detection (UPC Reading Group)
You only look once: Unified, real-time object detection (UPC Reading Group)You only look once: Unified, real-time object detection (UPC Reading Group)
You only look once: Unified, real-time object detection (UPC Reading Group)
 
제 15회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [YouPlace 팀] : 카프카와 스파크를 활용한 유튜브 영상 속 제주 명소 검색
제 15회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [YouPlace 팀] : 카프카와 스파크를 활용한 유튜브 영상 속 제주 명소 검색 제 15회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [YouPlace 팀] : 카프카와 스파크를 활용한 유튜브 영상 속 제주 명소 검색
제 15회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [YouPlace 팀] : 카프카와 스파크를 활용한 유튜브 영상 속 제주 명소 검색
 
Convolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep LearningConvolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep Learning
 
20191215 rate distortion theory and VAEs
20191215 rate distortion theory and VAEs20191215 rate distortion theory and VAEs
20191215 rate distortion theory and VAEs
 
Object classification using CNN & VGG16 Model (Keras and Tensorflow)
Object classification using CNN & VGG16 Model (Keras and Tensorflow) Object classification using CNN & VGG16 Model (Keras and Tensorflow)
Object classification using CNN & VGG16 Model (Keras and Tensorflow)
 
実装レベルで学ぶVQVAE
実装レベルで学ぶVQVAE実装レベルで学ぶVQVAE
実装レベルで学ぶVQVAE
 
Linear algebra
Linear algebraLinear algebra
Linear algebra
 
Deep generative model.pdf
Deep generative model.pdfDeep generative model.pdf
Deep generative model.pdf
 
Convolutional neural network
Convolutional neural network Convolutional neural network
Convolutional neural network
 

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
 
머신러닝(딥러닝 요약)
머신러닝(딥러닝 요약)머신러닝(딥러닝 요약)
머신러닝(딥러닝 요약)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
 
Learning by association
Learning by associationLearning by association
Learning by association홍배 김
 

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] 금융권의 머신러닝 활용사례
 
머신러닝(딥러닝 요약)
머신러닝(딥러닝 요약)머신러닝(딥러닝 요약)
머신러닝(딥러닝 요약)
 
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조
 
Learning by association
Learning by associationLearning by association
Learning by association
 

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