標籤:style class blog http com width
網易公開課,第10,11課
notes,http://cs229.stanford.edu/notes/cs229-notes5.pdf
Model Selection
首先需要解決的問題是,模型選擇問題,如何來平衡bais和variance來自動選擇模型?比如對於多項式分類,如何決定階數k,對於locally weighted regression如何決定視窗大小,對於SVM如何決定參數C
For instance, we might be using a polynomial regression model , and wish to decide if k should be
0, 1, . . . , or 10. Alternatively, suppose we want to automatically choose the bandwidth parameter τ for locally weighted regression, or the parameter C for our ?1-regularized SVM.
Cross validation
最典型的就是交叉驗證,有3種方法,
hold-out cross validation (also called simple cross validation)
用70%的資料作為訓練集,用30%資料作為測試集,找出訓練誤差最小的h(7:3是比較典型的比例)
這個方法的問題是,我們浪費了30%的資料,即使你在選定model後,拿整個資料集再做一遍訓練,也無法改變你只用了70%來選擇最優模型的事實
尤其對於一些領域,資料集的收集的代價是很高的,就不太合適
k-fold cross validation,通常k=10
把資料集隨機分為k份,用k-1份來訓練,用剩下的那份來測試,這樣的過程可以進行k次(不同的組合)
最終選取平均測試誤差最小的h
這個的問題,顯然是計算量比較大
leave-one-out cross validation
k-fold的特例,k=m,即k等於樣本數,一份就是一個樣本
適用於樣本非常少的情況
Feature Selection
One special and important case of model selection is called feature selection.
對於比如文本分類問題,垃圾郵件分類,會有很大量的features,但其實只有其中一小部分和分類問題相關,比如很多stop word,a,the,都和分類相關,而buy,shop等比較相關的只是一小部分,所以我們需要減少feature數來降低複雜度
Given n features, there are possible feature subsets, thus feature selection can be posed as a model selection problem over possible models.
顯然計算和比較那麼多的模型是不現實的,所以我們用heuristic search procedure,啟發學習法的方式,去找到一個good feature subset,
forward search OR backward search
屬於貪心演算法,forward是一個個加,backward是一個個減,然後每次加減都通過cross validation做次局部最優的選擇,即加個誤差最小的,或減個誤差最大的
這種需要通過訓練測試的方式來選擇的,稱為wrapper model feature selection,因為它就像wrapper,需要反覆調用學習演算法來評估feature。
wrapper模型效果還是不錯的,問題就是計算量比較大,需要調用這個數量級的次數的訓練演算法
Filter feature selection
效果沒有wrapper那麼好,但是比較cheaper,思路就是計算每個feature的score S(i) that measures how informative each feature xi is about the class labels y,最終我們只需要pick分數最高的那k個features就可以了,最常用的score就是mutual information
In practice, it is more common (particularly for discrete-valued features xi) to choose S(i) to be the mutual information MI(xi, y) between xi and y:
為了更直觀的理解mutual information,這個式子還可以表示成,Kullback-Leibler (KL) divergence:
這個KL表示p(xi, y) and p(xi)p(y)的差異程度,
如果x和y是沒有關係的,即獨立的,那麼 ,即KL-divergence為0
特徵選取常用演算法綜述,這篇綜述很好,看這個就ok了