본문 바로가기

ML14

Credit Card Fraud Detection / IPYNB In [ ]: ''' precision recall f1-score support 1)Original 0.0 1.00 1.00 1.00 85295 1.0 0.85 0.84 0.84 148 2)with divide 0.0 1.00 1.00 1.00 85295 corr items 1.0 0.89* 0.86 0.88* 148 3)with 0.0 1.00 1.00 1.00 85295 corr inputs 1.0 0.82 0.89* 0.86 148 ------------------------Over Sampling----------------------- with 1). 0.0 1.00 1.00 1.00 85295 SMOTE 1.0 0.67 0.91 0.77 148 with 1). 0.0 1.. 2021. 10. 7.
Basic RNN/LSTM cell implementation RNN $ h_t = tanh(W_hh_{t-1}+W_xx_t+b) $ $ y_t = W_yh_t $ class RNNCell(layers.Layer): def __init__(self, units, **kwargs): self.units = units self.state_size = units super(RNNCell, self).__init__(**kwargs) def build(self, input_shape): self.w_xh = self.add_weight(shape=(input_shape[-1], self.units), initializer='uniform', name='W_xh') self.w_hh = self.add_weight(shape=(self.units, self.units), i.. 2021. 9. 10.
seq2seq + attention 이란? seq2seq 시계열(sequence) 데이터를 다른 시계열 데이터로 바꿔줄 수 있다. (Sequence to sequence) 예를 들면, 한국어를 영어나 일본어로 번역하는 작업, 음성인식 등 seq2seq 모델은 Encoder-Decoder 모델이라고도 불린다. 구조 인코더는 input으로 들어간 데이터를 output으로 압축해서 표현해주고 이를 Context Vector라고 부른다. 디코더는 Context Vector를 새로운 시계열 데이터로 바꿔준다. (결과) 인코더와 디코더는 내부적으로 RNN 구조, 성능을 위해 Vanilla RNN보다는 LSTM이나 GRU로 구성됨 동작 인코더의 output, 즉 context vector는 RNN의 마지막 hidden state 부분에 해당한다. -> Hid.. 2021. 8. 17.
RNN, LSTM ? RNN (Recurrent Neural Network) 이름에서 알 수 있듯이 순환적 구조를 가지고 있다. 따라서 이전의 정보를 완전히 잃지 않고 이어나갈 수 있다. 연속적인 데이터나 시계열 데이터에 주로 사용된다. $ h_{t} = tanh(W_{h}h_{t-1} + W_{x}x_{t} + b) $ $ y_{t} = W_{y}h_{t} $ tanh 함수의 문제로 gradient vanishing 문제 발생할 수 있음 ( 멀리 떨어진 정보 소실될 수 있음 ) LSTM (Long Short Term Memory Network) RNN의 한 종류. LSTM의 핵심 아이디어는 "cell state"이다. 위 그림에서 가장 윗쪽의 수평선에 해당한다. cell state와 연산을 하기 위한 삭제 게이트, 입력 게.. 2021. 8. 16.