Posts

Showing posts with the label Linear regression

線性迴歸 - 統計和預測的最基礎

Image
線性回歸 (Linear Regression) 應用於不同的方面以達到不同的目的。 描述自變量Independent Variables($ x_i $)和因變量Dependent Variables($ y $)之間的關係的方法,或者通過輸入($ x_i $)預測目標變量($ y $)。 還有助於我們了解在更改一個或多個獨立變量時對因變量變化的影響。 公式: $$y = w_0+w_1x_1+w_2x_2+ ... +w_nx_n$$ 也可以表示為: $$h_w(x)=\sum_{i=1}^{m}{w_ix_i}=w^Tx$$ Cost Function定義為$h_w(x^{(j)})$和$y^{(j)}$之間的差的平方和。 統計學上,被稱為平方誤差(Sum of Square Error, SSE)。 為了使直線符合$n$數據點,Cost Function / SSE需要最小化以實現優化目標,這過程又稱OLS Estimation(Ordinary least squares Estimation)。 直觀地想,預測值(Predicted value)和實際目標(Actual value)值之間的差異越小,預測模型給出的結果越接近實際值,也暗示這個模型的愈準確,誤差值亦愈小,$R^2$表示線性回歸模型解釋數據的能力。愈高的$R^2$意味著模型愈有能力解釋現有的數據。 它還量度總變異, $SST$和回歸平方誤差的和, $SSR$的比例。 $R^2=\frac{SSR}{SST}$, where $0\leq R^2\leq 1$ 但是,線性回歸面對著非線性關係的變數,不如其他模型那樣精確,如神經網絡,始終它假設輸入和輸出的線性關係。 線性回歸的另一個問題是它對Outlier(主要是Influence Point) 的敏感性,會影響預測結果的準確性。 在我們訓練模型之前,可以在某些圖表中或者統計結果中被識別,把Outlier踢出來解決這個問題。 In previous chapter , I have introduced the overall process of data mining. Some of you might not understand well. It should be fine since the s...

Linear Regression - Simple model for statistics and prediction

Image
No doubt that Linear Regression are competent to be applied to different aspects and purposes. It can be an approach to describe the relationship between the independent variables ($x_i$) and dependable variable ($y$), or predict the target variables ($y$ ) with the inputs ($x_i$). It also helps us to understand how much effect on change of dependent variable, when changing one or more independent variables. Formula: $$y = w_0+w_1x_1+w_2x_2+ ... +w_nx_n$$ It is also presented as: $$h_w(x)=\sum_{i=1}^{m}{w_ix_i}=w^Tx$$ Cost Function is defined as sum of square of difference between $h_w(x^{(j)})$ and $y^{(j)}$. In statistics, it is called sum of square error, SSE. In order to fit the straight line to $n$ data points, cost function / SSE needs to be minimized to achieve the optimization goal.  $$J(w)=\sum_{j=1}^{m}{h_w(x^{(j)})-y^{(j)})^2}$$ Think it intuitively, the less difference between predicted and actual target values, the predictive model is giving the result which...