天天看點

【筆記】Week1:機器學習,監督學習,無監督學習,一進制線性回歸,線代複習 (Machine Learning)

吐槽:第一周隻有quiz沒有程式設計作業,于是記個筆記總結一下吧。。英文的話都是複制,我大概就是用自己話再說一遍,如有不對可以評論指出。。

正文:

1,Machine Learning(機器學習)

Two definitions of Machine Learning are offered. Arthur Samuel described it as: "the field of study that gives computers the ability to learn without being explicitly programmed." This is an older, informal definition.

Tom Mitchell provides a more modern definition: "A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E."

Example: playing checkers.

E = the experience of playing many games of checkers

T = the task of playing checkers.

P = the probability that the program will win the next game.

In general, any machine learning problem can be assigned to one of two broad classifications:

Supervised learning and Unsupervised learning.

兩個定義:不正式的說是計算機不通過顯式程式設計完成學習;正式的說是計算機通過經驗E完成任務T達到效果P。

兩個廣義的分類:監督學習和無監督學習。

2,Supervised Learning(監督學習)

In supervised learning, we are given a data set and already know what our correct output should look like, having the idea that there is a relationship between the input and the output.

Supervised learning problems are categorized into "regression" and "classification" problems. In a regression problem, we are trying to predict results within a continuous output, meaning that we are trying to map input variables to some continuous function. In a classification problem, we are instead trying to predict results in a discrete output. In other words, we are trying to map input variables into discrete categories.

Example 1:

Given data about the size of houses on the real estate market, try to predict their price. Price as a function of size is a continuous output, so this is a regression problem.

We could turn this example into a classification problem by instead making our output about whether the house "sells for more or less than the asking price." Here we are classifying the houses based on price into two discrete categories.

Example 2:

(a) Regression - Given a picture of a person, we have to predict their age on the basis of the given picture

(b) Classification - Given a patient with a tumor, we have to predict whether the tumor is malignant or benign.

定義:有個已知結果(正确答案)的資料集,我們要找輸入輸出之間的關系。

兩類問題:回歸問題(輸出是連續的,例如預測房價問題的價格是連續的),分類問題(輸出是離散的,例如檢測乳腺癌是良性還是惡性)。

3,Unsupervised Learning(無監督學習)

Unsupervised learning allows us to approach problems with little or no idea what our results should look like. We can derive structure from data where we don't necessarily know the effect of the variables.

We can derive this structure by clustering the data based on relationships among the variables in the data.

With unsupervised learning there is no feedback based on the prediction results.

Example:

Clustering: Take a collection of 1,000,000 different genes, and find a way to automatically group these genes into groups that are somehow similar or related by different variables, such as lifespan, location, roles, and so on.

Non-clustering: The "Cocktail Party Algorithm", allows you to find structure in a chaotic environment. (i.e. identifying individual voices and music from a mesh of sounds at a cocktail party).

定義:允許我們解決問題在不知道結果的情況下,我們可以從資料中推出模型,即使我們不知道變量的影響。

兩類問題/例子:聚類問題(例如社交網絡分析,市場分割等),非聚類問題(例如雞尾酒會問題,可以在雜亂的環境中尋找一個結構,這裡lecture上有展示最終效果,大概就是從酒會上分析出各種不一樣人說話的音頻)。

4,Linear regression with one variable(一進制線性回歸)

因為這邊帶公式了,就不複制了。。

記号:x^(i) 表示輸入變量或叫輸入特征,y^(i) 表示輸出變量,(x^(i), y^(i)) 一個訓練樣本(對一個訓練集來說有m個訓練樣本),m是訓練樣本個數,X是輸入變量的空間,Y是輸出變量的空間,h是假設函數。

代價函數:J(theta) = 1/2m*sum((h(x)-y)^2)(最小二乘法吧,中學學過的,theta是個列向量 [theta0; ....; theta1],sum是對i=1到m的h(x^(i))-y^(i)平方的求和)

說明:這個函數的用途就是用它去估計theta們的取值怎麼樣,J越小theta越好;而且這個J線上性回歸情況下一定是個凸函數,是以局部最小值一定是全局最小值,是以我們可以用梯度下降法去求解。

梯度下降法:theta := theta - alpha*對J求對theta_j的偏導(:= 是指派的意思;這要注意theta要同步變化,是以如果單個求要記得算完之後再指派,如果theta是列向量,就自動完成同步變化了;alpha是學習率)

說明:alpha如果太小,則梯度下降太慢;過大則不一定會收斂;直覺的了解就是在一個山上任意一點尋找最快下降的方向,然後走學習率大小的步長,最後會走到局部最小值點(但在這裡是凸函數,是以一定是全局最小值點);梯度下降法也叫batch梯度下降法,因為每一步都要用到所有的訓練樣本。

5,Linear Algebra review(線代複習)

講了矩陣,向量的定義,強調了1-indexed和0-indexed的差別(就是有時候是坐标從0開始有時候從1開始,matlab裡面是從1開始的),矩陣加法,數乘矩陣,矩陣向量乘法規則和性質,矩陣逆和轉置。

繼續閱讀