728x90 반응형 전체 글268 Likelihood function, Sufficient Statistics, Minimum Sufficient Statistics (가능도함수, 충분통계량, 최소충분통계량) Likelihood Functionlikelihood inference는 관찰한 데이터 $s$와 Statistical Model(통계모델) $\{P_{\theta}: \theta \in \Omega \}$ 을 이용한 추정법이다. 일반적으로 pmf, pdf의 경우 각각 $P_{\theta},\ f_{\theta}$로 표기하지만 포스팅에서는 맥락에 맞추어 $f_{\theta}$로 통일한다. likelihood function은 다음과 같이 정의한다.\[ L(\theta | s) = f_{\theta}(s) \] $f_{\theta_1}(s) > f_{\theta_2}(s)$라면, 데이터 $s$는 $\theta = \theta_1$일 때 더 관측될 가능성(믿음)이 높다고 한다. $S = \{ 1, 2, \do.. 2023. 5. 16. [Ensemble] AdaBoost in Python (scikit-learn) Setup필요한 라이브러리를 import하자.# To support both python 2 and python 3from __future__ import division, print_function, unicode_literals# Common importsimport numpy as npimport os# to make this notebook's output stable across runsnp.random.seed(42)# To plot pretty figures%matplotlib inlineimport matplotlib as mplimport matplotlib.pyplot as pltmpl.rc('axes', labelsize=14)mpl.rc('xtick', labelsize=12)mpl.. 2023. 5. 16. [Ensemble] AdaBoost AdaBoostadaptive boosting 이다.Algorithm in OverviewGiven: $d$개의 class-labeled tuple이 input으로 주어진다. $(\mathbf{X}_1, y_1), \dots, (\mathbf{X}_d, y_d)$ 맨 처음, 모든 tuple은 uniformly weighed 된다. 즉 $j$번째 tuple의 weight는 $\frac{1}{d}$이다. $T$ round동안 $T$개의 classifier를 생성한다. 그리고 $i$번째 round에서,$\mathcal{D}$로부터 복원추출(sampling with replacement)하여 training set $D_i$를 얻는다.각 tuple은 각 weight에 기반하여 selected 확률을 지닌다.$D.. 2023. 5. 16. [Data Science] Mediator, Moderator Mediator (intermediate variable, mediating variable, 매개변수)두 변수 (주로 독립변수와 종속변수)의 관계(이유, 매커니즘 등)를 설명한다.그러나 매개변수 자체가 인과관계(causality)를 의미하지 않는다. (모델링이 가능하다는 것이다) 예시로 운동($X$)이 정신건강($Y$)에 미치는 영향에 대한 가설($X \to Y$)을 고려해보자.그러나 실제로는 자존감이라는 매개변수($Me$)가 운동에 영향을 받고, 자존감이 정신건강에 영향을 주는 모형으로 설명할 수 있다. Mediation Effiect어떤 변수 $M$이 mediator의 효과가 있는지 알아보기 위해서 3개의 regression이 필요하다.$Y = b_0 + b_1X + e$$M = b_0 + b_2X.. 2023. 5. 15. Dummy coding, Effect Coding 범주형 변수(categorical variables)를 regression model의 input으로 사용할 때 2가지 방법을 고려할 수 있다.예시로 4개의 범주(초등, 중등, 고등, 초등교육 미만)를 사용한다. $G = \{ G_1,\ G_2,\ G_3,\ G_4 \}$$G_1$: Primary$G_2$: Secondary$G_3$: Post-secondary$G_4$: Less than primaryDummy coding4개의 범주에 대하여 해당 범주면 1, 아니면 0으로 할당하는 방법을 생각할 수 있다.이때 마지막 범주의 경우 모두 0으로 표현하면 $k$개의 범주에 대하여 길이가 $(k-1)$개의 더미만 필요하다. Note: One-hot encoding은 $k$개의 범주를 $k$개의 더미 변수로 .. 2023. 5. 15. [Data Science] Logistic Regression Class Probability Estimation많은 task중에서 어떤 instance가 주어졌을 때 어떤 class에 해당할지 예측하고 싶다.예를 들어 fraud detection은 baking이나 commerce에서 중요한 이슈이다.다행히도, linear model을 이용하여 binary class일 확률을 예측할 수 있다. \[ f(\mathbf{x}) = w_0 + w_1 x_1 + \cdots + w_n x_n \]그러나 우리가 예측할 class일 확률은 $[0, 1]$인데, $f(\mathbf{x})$의 범위는 $(-\infty, \infty)$이다. 이를 해결하기 위해 log-odds를 도입한다.odd는 likelihood of an event로, 일어날 확률와 일어나지 않는 확률의 비이.. 2023. 5. 14. 이전 1 ··· 21 22 23 24 25 26 27 ··· 45 다음 728x90 반응형