2016-07-08 107 views
0

我正在嘗試一個反對所有邏輯迴歸分類編輯文章的主題類別根據他們的文本使用vowpal wabbit。當我嘗試使用用於培訓的相同數據對新文章進行預測時,結果很差,但由於過度擬合,我期望得到不切實際的好結果。在這種情況下,我實際上想要過度擬合,因爲我想驗證我是否正確使用了vowpal wabbit。一對一邏輯迴歸分類器與Vowpal Wabbit

我的模型被訓練上的例子看起來像這樣的,其中每個功能是從文章一個字,每一個標籤是一個類別的標識符,如體育或娛樂: 1 | the baseball player ... stadium 4 | musicians played all ... crowd ... 2 | fish are an ... squid

我的訓練命令如下: vw --oaa=19 --loss_function=logistic --save_resume -d /tmp/train.vw -f /tmp/model.vw

我的測試命令如下: vw -t --probabilities --loss_function=logistic --link=logistic -d /tmp/test.vw -i /tmp/model.vw -p /tmp/predict.vw --raw_predictions=/tmp/predictions_raw.vw

我使用--probabilities--link=logistic b因爲我希望我的結果可以被解釋爲屬於該類的那篇文章的概率。

我對於我的數據集的大小(81個示例和52000個特徵)有一個明顯的問題,但是我預計這會導致嚴重的過度擬合,因此對與訓練數據相同的數據集做出的任何預測都會相當好。 我在做我的vowpal wabbit命令有問題嗎?我對數據科學的理解是關閉的嗎?

這裏是從訓練命令的輸出:

Num weight bits = 18 
learning rate = 0.5 
initial_t = 0 
power_t = 0.5 
using no cache 
Reading datafile = /tmp/train.vw 
num sources = 1 
average since   example  example current current current 
loss  last   counter   weight label predict features 
1.000000 1.000000   1   1.0  15  1  451 
1.000000 1.000000   2   2.0  8  15  296 
1.000000 1.000000   4   4.0  8  7  333 
0.875000 0.750000   8   8.0  15  15  429 
0.500000 0.125000   16   16.0  8  7  305 
0.531250 0.562500   32   32.0  12  8  117 
0.500000 0.468750   64   64.0  3  15  117 

finished run 
number of examples per pass = 81 
passes used = 1 
weighted example sum = 81.000000 
weighted label sum = 0.000000 
average loss = 0.518519 
total feature number = 52703 

而對於測試命令:

only testing 
predictions = /tmp/predict.vw 
raw predictions = /tmp/predictions_raw.vw 
Num weight bits = 18 
learning rate = 0.5 
initial_t = 0 
power_t = 0.5 
using no cache 
Reading datafile = /tmp/test.vw 
num sources = 1 
average since   example  example current current current 
loss  last   counter   weight label predict features 
1.000000 -0.015873   1   1.0 4294967295 3(7%)  117 
1.000000 1.000000   2   2.0 4294967295 3(7%)  88 
1.000000 1.000000   4   4.0 4294967295 3(7%)  188 
1.000000 1.000000   8   8.0 4294967295 9(7%)  1175 
1.000000 1.000000   16   16.0 4294967295 5(7%)  883 
1.000000 1.000000   32   32.0 4294967295 7(7%)  229 
1.000000 1.000000   64   64.0 4294967295 15(7%)  304 

finished run 
number of examples per pass = 40 
passes used = 2 
weighted example sum = 81.000000 
weighted label sum = 0.000000 
average loss = 1.000000 
average multiclass log loss = 999.000000 
total feature number = 52703 
+0

使用'--probabilities',您不需要'--link = logistic'和'--raw_predictions'。你的訓練數據是否被洗牌(或按照自然順序排列)? –

+0

@MartinPopel我明白了,謝謝。我無法找到有關'--probabilities'和'--link = logistic'的信息。是的,在訓練之前,我已經注意到我的例子。 (感謝實際上你的另一個SO回答) – vaerek

+0

你沒有試過它 - 「link = logisitic'? '--probabilities'在內部計算邏輯鏈接函數。還可以嘗試省略'--save_resume':只有在需要更多步驟訓練模型時(如果在上一個訓練步驟中使用它,可能會影響報告的測試損失),才需要使用它。 –

回答

0

我相信我的主要問題只是我需要運行更多的傳球。我不太瞭解vw如何實現在線學習,這與批量學習有何不同,但經過多次通過後,平均損失降至13%。隨着--holdout_off啓用,此損失進一步下降到%1。非常感謝@arielf和@MartinPopel

Running training command with 2421 examples: vw --oaa=19 --loss_function=logistic --save_resume -c --passes 10 -d /tmp/train.vw -f /tmp/model.vw 
final_regressor = /tmp/model.vw 
Num weight bits = 18 
learning rate = 0.5 
initial_t = 0 
power_t = 0.5 
decay_learning_rate = 1 
using cache_file = /tmp/train.vw.cache 
ignoring text input in favor of cache input 
num sources = 1 
average since   example  example current current current 
loss  last   counter   weight label predict features 
1.000000 1.000000   1   1.0  11  1  234 
1.000000 1.000000   2   2.0  6  11  651 
1.000000 1.000000   4   4.0  2  12  1157 
1.000000 1.000000   8   8.0  4  2  74 
1.000000 1.000000   16   16.0  12  15  171 
0.906250 0.812500   32   32.0  9  6  6 
0.750000 0.593750   64   64.0  15  19  348 
0.625000 0.500000   128   128.0  12  12  110 
0.566406 0.507812   256   256.0  12  5  176 
0.472656 0.378906   512   512.0  5  5  168 
0.362305 0.251953   1024   1024.0  16  8  274 
0.293457 0.224609   2048   2048.0  3  4  118 
0.224670 0.224670   4096   4096.0  8  8  850 h 
0.191419 0.158242   8192   8192.0  6  6  249 h 
0.164926 0.138462  16384  16384.0  3  4  154 h 

finished run 
number of examples per pass = 2179 
passes used = 10 
weighted example sum = 21790.000000 
weighted label sum = 0.000000 
average loss = 0.132231 h 
total feature number = 12925010