【问题标题】:About the input format of vowpal_wabbit关于 vowpal_wabbit 的输入格式
【发布时间】:2017-03-09 13:25:08
【问题描述】:

我在这方面是新手。 我想用一系列数据进行训练并进行预测。试了好久,能告诉我是怎么回事吗?

我的火车数据如下所示(我在此处选择前几行):

-1 '13731#276 |f gender:0 age_range:2 action0:1 action1:0 action2:1 action3:0
-1 '70175#4214 |f gender:0 age_range:4 action0:0 action1:0 action2:1 action3:0
-1 '89370#2598 |f gender:1 age_range:2 action0:8 action1:0 action2:1 action3:0
1 '89371#1250 |f gender:0 age_range:2 action0:0 action1:0 action2:1 action3:0
-1 '89372#2792 |f gender:1 age_range:5 action0:0 action1:0 action2:1 action3:0
1 '89372#962 |f gender:1 age_range:5 action0:0 action1:0 action2:1 action3:0
-1 '89373#4472 |f gender:0 age_range:7 action0:5 action1:0 action2:1 action3:0

这样的测试数据:

1 '177796#1807 |f gender:0 age_range:5 action0:5 action1:0 action2:1 action3:0
1 '155638#2445 |f gender:0 age_range:7 action0:3 action1:0 action2:1 action3:0
1 '155639#658 |f gender:1 age_range:2 action0:5 action1:0 action2:1 action3:0
1 '127479#2480 |f gender:0 age_range:7 action0:0 action1:0 action2:1 action3:0
1 '127478#1245 |f gender:0 age_range:4 action0:1 action1:0 action2:1 action3:0
1 '127473#4995 |f gender:1 age_range:4 action0:13 action1:0 action2:1 action3:0
1 '127472#45 |f gender:0 age_range:7 action0:4 action1:0 action2:1 action3:0

是的,它们看起来没有什么不同。我不知道这是否正确。我在github上看到很多人都是这样写的。

我的 vw 命令如下:

vw -d train.vw --loss_function=logistic -f model.vw
vw -d test.vw -t -i model.vw --loss_function=logistic -r shop.preds.txt

嗯,结果是

-2.816693 177796#1807
-2.817430 155638#2445
-2.981194 155639#658
-2.821442 127479#2480
-2.823012 127478#1245
-2.968556 127473#4995
-2.816092 127472#45
-2.820939 127471#4010
-2.975476 127470#593
-2.820105 155634#4103
-2.799539 155635#2980
-3.139279 127475#1469

我不知道为什么,数字变得小于-2,实际上我的理想结果是这样的:

202178#1665,0.67
156148#4730,0.50
132360#2459,0.24
132360#144,0.99
180387#1534,0.48
187963#1360,0.19
158187#2534,0.54
188206#4890,0.70

至少我希望数字是正确的,但它都是 1。 你能告诉我如何解决这个问题吗?谢谢!

【问题讨论】:

    标签: machine-learning classification vowpalwabbit


    【解决方案1】:

    如果你想预测概率,那么你应该使用 vw -d test.vw -t -i model.vw --loss_function=logistic -r shop.preds.txt 而不是 vw -d test.vw -t -i model.vw --loss_function=logistic --link=logistic -p shop.preds.txt

    如果您想获得最可能的标签(-1 或 +1),请使用 vw -d test.vw -t -i model.vw --loss_function=logistic --binary -p shop.preds.txt

    https://github.com/JohnLangford/vowpal_wabbit/wiki/Predicting-probabilities

    【讨论】:

    • 并将 vw 原始预测格式转换为您可以使用的首选 CSV 格式:perl -lane 'print $F[1], ",", $F[0]' shop.preds.txt
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-14
    • 2014-07-26
    相关资源
    最近更新 更多