본문 바로가기

데이터 과학

KL Divergence(Kullback Leibler Divergence) 설명 출처) https://www.countbayesie.com/blog/2017/5/9/kullback-leibler-divergence-explained Kullback-Leibler Divergence Explained — Count Bayesie Kullback–Leibler divergence is a very useful way to measure the difference between two probability distributions. In this post we'll go over a simple example to help you better grasp this interesting tool from information theory. www.countbayesie.com (번역) 해당 .. 더보기
Reservoir Sampling Q. 전체 모집단의 갯수(n)를 알지 못하는 상황에서 편향 없이 1개를 샘플링하면 각 샘플링의 확률은 1/n이 된다. 어떻하면 이를 코드로 구현할 수 있을까? https://www.youtube.com/watch?v=A1iwzSew5QY 위의 영상에 방법이 나와 있다. 모자 n개가 있고, i 번째 모자를 최종적으로 쓰고 있으려면 (i 번째 모자를 쓰고), (i+1번째 모자를 쓰지 않고), (i+2번째 모자를 쓰지 않고)... (n번째 모자를 쓰지 않으면 된다) 즉, (i번째 모자를 최종적으로 쓰고 있을 확률) = (i 번째를 선택할 확률) = (1 / i) * (1 - (1/(i+1))) * (1 - (1/(i+1))) ... *(1 - 1/(n)) 이 식을 정리하면 1 / n 이 된다. 따라서, 코드로.. 더보기
LSTM Autoencoder 설명 ※ 아래 글은 https://machinelearningmastery.com/lstm-autoencoders/ 해당 링크를 요약한 것입니다. Introduction Encoder-Decoder LSTM Models Early Application of LSTM Autoencoder Code Introduction - LSTM Autoencoder는 Encoder-Decoder LSTM 구조를 사용하는 Sequence 데이터를 위한 Autoencoder로 볼 수 있다(Learn compressed representation of sequence data, e.g. video, text, audio and time series sequence date) - 학습시에 Encoder 부분은 Sequence 데이.. 더보기
Scipy 함수 정리 Scipy 제공 확률 분포 목록 확률 분포 메소드 scipy.stats.norm.pdf(x, loc=0, scale=1) - pdf는 scipy.stats.norm의 여러 매소드 중 하나(정규 분포의 특성을 모아둔 듯 하다) - 정규 연속 확률 밀도함수 생성 - loc (= mean), scale (= std) - $ f(x) = {exp(-x^{2}/2) \over \sqrt{2\pi} } $ from scipy.stats import norm norm.pdf(x, loc, scale) # Same as norm.pdf(y) / scale # y = (x - loc) / scale (계속 정리...) ※ 이항분포 : 연속된 n번의 독립 시행에서 각 시행이 확률 p를 가질 때의 이산 확률 분포 https.. 더보기
RNN & LSTM 설명 및 구현(pytorch) ※ 본 포스팅은 아래 링크 문서 및 다수 파이토치 포럼 글을 참고하여 만든것 입니다. pytorch.org/tutorials/beginner/nlp/sequence_models_tutorial.html 참고) LSTM 설명 포스팅 참고) Time Series Forecasting using LSTM 1) LSTM in Pytorch 1-1) Pytorch 사용법 1-2) LSTM 사용시 궁금한 부분과 모은 답변 1-3) Multivariate time series (anomaly) data using LSTM 1) LSTM in Pytorch "Sequence models are central to NLP: they are models where there is some sort of dependence.. 더보기
Density Estimation (in Python) ※ scikit-learn.org/stable/modules/density.html 2.8. Density Estimation — scikit-learn 0.24.1 documentation 2.8. Density Estimation Density estimation walks the line between unsupervised learning, feature engineering, and data modeling. Some of the most popular and useful density estimation techniques are mixture models such as Gaussian Mixtures (GaussianMixture scikit-learn.org 아래 글은 본 링크 글을 번역한.. 더보기
모델 앙상블(ensemble) 하기 학습이 잘된 몇가지 모델이 있고, 각각의 모델의 성능을 결합하여 최선의 결과를 얻고 싶을 때 모델 앙상블을 이용한다. 예시) 잘 학습된 가중치를 포함한 모델 1~3이 있다고 하자. 모델을 통해 추론한 결과는 (5000, 26) 사이즈를 갖는다고 가정해 보자. 모델 3개를 통해 추론한 결과를 앙상블 하는 과정은 다음과 같이 정리할 수 있다. 코드로 나타내면 다음과 같다. for model in best_models: (...) for idx, sample in enumerate(test_data_loader): with torch.no_grad(): (...) probs = model_bone(images) preds = (probs > 0.5) batch_idx = batch_size * idx # im.. 더보기
결합 확률 분포, 주변 확률 분포 (Joint / Marginal Probability Distribution) Contents 결합 확률 분포(Joint Probability Distribution) 결합 확률 질량 함수(Joint PMF) 결합 확률 밀도 함수(Joint PDF) 주변 확률 분포(Marginal Probability Distribution) 주변 확률 질량 함수(Marginal PMF) 주변 확률 밀도 함수(Marginal PDF) 조건부 확률 분포(Marginal Probability Distribution) 조건부 확률 질량 함수(Conditional PMF) 조건부 확률 밀도 함수(Conditional PDF) ※ 주변 확률 분포는 두개의 변수로 이루어진 결합 확률 분포를 하나의 변수로 표현하기 위한 방법이다. ※ 주변 확률 분포는 결합 확률 분포와 대립되는 개념이 아니다! ▶ 결합 확률 .. 더보기