목록Machine Learning (23)
statduck

요약통계량은 적률(Moment)이라고 볼 수 있다. 이 적률은 함수의 모양을 결정짓는 녀석이다. 이 녀석으로 어떤 함수가 지나는 점을 기준으로 모양을 추정할 수 있다(데이터 포인트->분포추정) 평균, 분산, 최빈값 이런 요약 통계량(summary statistics)들이 예시이다. - 평균: 중심을 측정하는 척도. 선형 연산 성립 - 분산: 퍼진 정도를 측정하는 척도. - 최빈값(mode): 쌍봉분포에서는 유니크 하지 않을 수 있다 그렇지만 위 그림처럼 요약 통계량만 믿다가는 큰 코 다칠 수도 있다. 같은 요약통계량을 가지더라도 위와 같이 전혀 다른 데이터의 흐름 혹은 두 데이터의 관계를 설명하는 경우가 있기 때문이다. 1차원 데이터의 경우에는 아래처럼 박스플랏 대신 분포를 육안으로 설명해주는 바이올린플..

Ref: https://towardsdatascience.com/analyzing-seasonality-with-fourier-transforms-using-python-scipy-bb46945a23d3 Data: https://data.seoul.go.kr/dataList/OA-2218/S/1/datasetView.do 2020, 2021년도 데이터 이용 from scipy import fft from scipy import signal as sig import matplotlib.pyplot as plt import numpy as np import pandas as pd import math from pandas.plotting import register_matplotlib_converters r..
Python - BeautifulSoup, request 라이브러리 이용 BeautifulSoup? - HTML이나 XML 파일의 데이터를 당겨오는 라이브러리 requests?: http 호출 라이브러리 XML?: 내부적으로 트리구조를 가지는 마크업 언어 (html파일이 대표적) requests 사용법 import requests r = requests.get('https://api.github.com/user', auth=('user', 'pass')) r.status_code # 200 r.headers['content-type'] # 'application/json; charset=utf8' r.encoding # 'utf-8' r.text # doctest: +ELLIPSIS # u'{"type"..

ARIMA 모형 모형의 정상성 가정을 먼저 만족해야한다. AR(Auto Regressive)모형은 $$Z_t = \phi_1Z_{t-1}+ + \phi_2 Z_{t-2} + \phi_3 Z_{t-3} + \cdots + \phi_p Z_{t-p} + a_t $$ 이와 같이 나타나며, 이는 이전 시점의 데이터들을 t시점의 데이터에 회귀시킨 모형이다. * 단 회귀모형과는 달리 독립변수들간 독립성이 가정되지 않으며 독립변수 개수가 사전적으로 결정되는 것이 아니다. MA(Moving Average)모형은 $$ Z_t = a_t - \theta_1 a_{t-1} - \theta_2 a_{t-2} - \theta_3 a_{t-3} - \cdots - \theta_q a_{t-1} $$ 이는 $\{ a_t, a_{t..

Kernel method Kernel method is a method to estimate the function using kernel. It estimates the value of a function by investigating data around x values. Neareness is defined by the distance, so a weight is given by the distance. KNN as a kernel method KNN can be viewed as a kernel method because it calculates distances in choosing nearest k points. $$ \hat{f}(x)=Ave(y_i|x_i \subset N_k(x)) $$ ..

Smoothing Splines ✏️ Smoothing Spline Avoiding the knot selection problem completely by using a maximal set of knots. $$ RSS(f,\lambda)=\sum^N_{i=1}{y_i-f(x_i)}^2+\lambda\int {f''(t)}^2dt $$ Our goal is to find the form of function minimizing RSS. The constrains mean curvature as follows: $$ r = (x,y), ||r'||=\sqrt{x'(s)^2+y'(s)^2}=1 \\ T(s)=(x'(s),y'(s)) = unit \; tangent \; vector \\ \kappa(s)..

Basis Expansions & Regularization We can't assure our function is linear. To deal with non-linear problem, we can use transformed X instead of original X. Basis Expansions and Regularization $$ f(X)=\sum^M_{m=1}\beta_mh_m(X) $$ The basis function, f(X), is linear on h even though $h(X)$ is non linear Form $h_m(X)=X_m$ Basic linear model $h_m(X)=X_j^2 \; or \; h_m(X)=X_jX_k$ Polynomial model $h_m..

Calculation $$ \delta_k(x) =-\dfrac{1}{2}log|\hat{\Sigma}_k|-\dfrac{1}{2}(x-\mu_k)^T\hat{\Sigma}_k^{-1}(x-\mu_k)+log\pi_k $$ $\hat{\Sigma}_k=U_kD_kU_k^T$can make this calculation more faster. $$ ✔️ (x-\hat{\mu}k)^T\hat{\Sigma}^{-1}_k(x-\hat{\mu}_k)=[U_k^T(x-\hat{\mu}_k)]^TD_k^{-1}[U_k^T(x-\hat{\mu}_k)] \ ✔️ log|\hat{\Sigma}_k|=\Sigma_llogd{kl}$$ In normal dsitrubiton, the quadratic form means ma..