用clip 选项就可。例子如下:
\includegraphics[width=3in,clip]{examplenew.eps}
以上
Thursday, 22 January 2015
Thursday, 4 December 2014
How to build a naive (very naive) system scored over 30,000 in RecSysChallenge 2015?
How to build a naive (very naive) system scored over 30,000 in RecSysChallenge 2015?
-The task
Given a sequence of click events performed by some user during a typical session in an e-commerce website, the goal is to predict whether the user is going to buy something or not, and if he is buying, what would be the items he is going to buy.
The detail of RecSysChallenge 2015 can be found at http://2015.recsyschallenge.com/index.html.
-A naive system (too simple and too naive!!)
It is very easy to build a system which achieves a score > 30,000 by using two simple rules.
--Rules
Rule#1: The items which are bought no less than MINF=10 times in the train data.
Rule#2: The items which are clicked no less than MINCLICKS=2 times *in each sesssion* in the test data.
--Steps:
Step#1: Obtain the list (buys.list) of items which are bought in the train data.
Step#2: Keep the items following Rule#1 and Rule#2 for each session.
--The code in perl
########################
#Usage
print stderr "Usage: perl a.pl buys.list MINF test_file MINCLICKS\n";
$MINF = $ARGV[1];
$MINCLICKS = $ARGV[3];
open FP, $ARGV[0] or die; #buys.list
while(){
($item, $freq) = split /\t/;
next if($item eq "" or $freq < $MINF);
$itemlist{$item} = $freq;
#print stderr "ITEM:$item\n";
}
close FP;
open FP, $ARGV[2] or die;#test file
while(){
($sid, $stime, $item, $sg) = split /\,/;
next if($sid eq "");
next if(!exists $itemlist{$item});
#print stderr "Tobuy:$sid\t$item\n";
$pred_buys{$sid}{$item}++;
}
close FP;
foreach $sid (sort{$a <=> $b} keys %pred_buys){
$pred = "";
foreach $item (keys %{$pred_buys{$sid}}){
$pred .= $item."," if($pred_buys{$sid}{$item} >=$MINCLICKS);
}
next if($pred eq "");
$pred =~ s/\,$//g;
print "$sid;$pred\n";
}
##The END
########################
Upload the results and get a score =33780.1.
OK. Time to have a rest. Let us party!!!
-The task
Given a sequence of click events performed by some user during a typical session in an e-commerce website, the goal is to predict whether the user is going to buy something or not, and if he is buying, what would be the items he is going to buy.
The detail of RecSysChallenge 2015 can be found at http://2015.recsyschallenge.com/index.html.
-A naive system (too simple and too naive!!)
It is very easy to build a system which achieves a score > 30,000 by using two simple rules.
--Rules
Rule#1: The items which are bought no less than MINF=10 times in the train data.
Rule#2: The items which are clicked no less than MINCLICKS=2 times *in each sesssion* in the test data.
--Steps:
Step#1: Obtain the list (buys.list) of items which are bought in the train data.
Step#2: Keep the items following Rule#1 and Rule#2 for each session.
--The code in perl
########################
#Usage
print stderr "Usage: perl a.pl buys.list MINF test_file MINCLICKS\n";
$MINF = $ARGV[1];
$MINCLICKS = $ARGV[3];
open FP, $ARGV[0] or die; #buys.list
while(
($item, $freq) = split /\t/;
next if($item eq "" or $freq < $MINF);
$itemlist{$item} = $freq;
#print stderr "ITEM:$item\n";
}
close FP;
open FP, $ARGV[2] or die;#test file
while(
($sid, $stime, $item, $sg) = split /\,/;
next if($sid eq "");
next if(!exists $itemlist{$item});
#print stderr "Tobuy:$sid\t$item\n";
$pred_buys{$sid}{$item}++;
}
close FP;
foreach $sid (sort{$a <=> $b} keys %pred_buys){
$pred = "";
foreach $item (keys %{$pred_buys{$sid}}){
$pred .= $item."," if($pred_buys{$sid}{$item} >=$MINCLICKS);
}
next if($pred eq "");
$pred =~ s/\,$//g;
print "$sid;$pred\n";
}
##The END
########################
Upload the results and get a score =33780.1.
OK. Time to have a rest. Let us party!!!
Monday, 21 November 2011
从ppt 转成 eps文件过程
作为一个免不了写paper的人,自然需要制作一些eps文件嵌入到latex文件。下面怎么使用ppt来做图最后生成eps。
1. 使用ppt 做一页slide。
2. 打印输出到pdf(current slide)
3. pdf再次打印成ps(print to file)。
3. 使用 ps -> eps选项
1. 使用ppt 做一页slide。
2. 打印输出到pdf(current slide)
3. pdf再次打印成ps(print to file)。
3. 使用 ps -> eps选项
Wednesday, 22 June 2011
How to make a EPS from PPT
1. PPT ---(CutePDF) -> PDF
2. PDF ---(ToPS) -> PS (choose auto-rotate and center)
3. PS -> EPS
How to set a new printer named ToPS (http://u.cs.biu.ac.il/~herzbea/makeP.htm)
To install the MS Publisher Imagesetter virtual printer, open the `Printers` settings folder, and click `Add Printer`. Select a local printer; since it is virtual, select the FILE: port. Specify `Generic` as manufacturer, and then you can choose the MS Publisher Imagesetter.
After you install the printer, you may want to fine-tune its properties. To do so, open again the Printers setting folder, and right click on the printer; select `Properties`. Under `Device Settings`, set very low values (e.g. 5) to the following two parameters:
Minimum font size to download as outline
Maximum font size to download as bitmap
Next, go to the `Advanced` tab, and from there, select `Printing Defaults…`. In the window that opens, select `Document options`, then `Postscript options`. Set the following two options:
PostScript Output Option: Optimize for Portability
TrueType Font Download Option: Outline
2. PDF ---(ToPS) -> PS (choose auto-rotate and center)
3. PS -> EPS
How to set a new printer named ToPS (http://u.cs.biu.ac.il/~herzbea/makeP.htm)
To install the MS Publisher Imagesetter virtual printer, open the `Printers` settings folder, and click `Add Printer`. Select a local printer; since it is virtual, select the FILE: port. Specify `Generic` as manufacturer, and then you can choose the MS Publisher Imagesetter.
After you install the printer, you may want to fine-tune its properties. To do so, open again the Printers setting folder, and right click on the printer; select `Properties`. Under `Device Settings`, set very low values (e.g. 5) to the following two parameters:
Minimum font size to download as outline
Maximum font size to download as bitmap
Next, go to the `Advanced` tab, and from there, select `Printing Defaults…`. In the window that opens, select `Document options`, then `Postscript options`. Set the following two options:
PostScript Output Option: Optimize for Portability
TrueType Font Download Option: Outline
Monday, 23 May 2011
Moses-训练Hierachical model
注意点:
--2011.5.24
1. input-type set as 0 for hiero/string-to-tree; 3 for tree-to-string
2. 应该使用:/moses-chart-cmd/src/moses_chart
--2011.5.23
在train-model.perl时使用 -hierachical -glue-grammar -max-phrase-length 5。记得把训练phrase-model的-reordering去掉。
--2011.5.24
1. input-type set as 0 for hiero/string-to-tree; 3 for tree-to-string
2. 应该使用:/moses-chart-cmd/src/moses_chart
--2011.5.23
在train-model.perl时使用 -hierachical -glue-grammar -max-phrase-length 5。记得把训练phrase-model的-reordering去掉。
Sunday, 23 January 2011
训练基于Moses的中英翻译
训练基于Moses的中英翻译
开始学习SMT,第一步就是想熟悉一下SMT的整个运行过程。于是乎就开始练习使用Moses。使用过程遇到一些问题,记下来免得以后忘记了。
基本上按照这里的指南一步一步的测试。该指南写的相当得好。很好!
http://www.statmt.org/moses_steps.html
但是还是会遇到几个问题。
测试环境:2.6.31-22-server #68-Ubuntu SMP Tue Oct 26 16:50:02 UTC 2010 x86_64 GNU/Linux
----------------
支持软件
----------------
++支持软件的版本尽量和指南一致。如果没有一致的,可以选择稍微早一点的版本。如果选择后面的版本,会有一些变数。我还没有去探索具体哪些版本好用。
比如:SRILM 1.5.7,在主页上没有这个版本。我开始选择最新版本,结果遇到一些问题。后来改成下载1.4.6就好用了
++moses-scripts编译中间会提示一些Boost lib缺少的问题,实际不影响(也许在某些地方有用,但是作为我这么菜鸟级的,无所谓)
++如果moses是直接下载的,有时候会出现dos格式 ^M问题,导致perl脚本执行不了的问题。
解决方案1. 把所有的perl文件 第一行结尾 加入空格。
解决方案2. 在所有调用位置 加入 perl a.pl
解决方案3. svn co https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk moses去下载(这也是指南推荐的,我开始土了,直接用web去下载)
---------------
训练过程
---------------
++语料必须是UTF8的
++Giza++在训练过程中,遇到一些core溢出的问题,经过google找回来的问题,我做了如下更改,好用!
*** file_spec.h 2009/07/10 21:38:39 1.1
--- file_spec.h 2009/07/13 11:37:21
! char time_stmp[17];
! sprintf(time_stmp, "%02d-%02d-%02d.%02d%02d%02d.", local->tm_year,
(local->tm_mon + 1), local->tm_mday, local->tm_hour,
local->tm_min, local->tm_sec);
--- 37,49 ----
! char time_stmp[19];
! sprintf(time_stmp, "%04d-%02d-%02d.%02d%02d%02d.", 1900 + local->tm_year,
(local->tm_mon + 1), local->tm_mday, local->tm_hour,
local->tm_min, local->tm_sec);
++MERT训练的时候,应该加入--mertdir 来指定路径,是不是旧版本没有这个问题?我不是很清楚。
++本文用了64位机器,脚本路径应该是i686-m64
大致就这样,其他要做的事情就等。。。直到模型训练成功。
-------------
初步试验结果
--------------
++设置
FBIS作为双语语料
GIGA_xin来训练语料模型(只使用头1M句)
GIGA_xin来训练Recaser(所有的)
没有MERT
++BLUE
19.79
哇,这么高!休息先
2011.1.24
开始学习SMT,第一步就是想熟悉一下SMT的整个运行过程。于是乎就开始练习使用Moses。使用过程遇到一些问题,记下来免得以后忘记了。
基本上按照这里的指南一步一步的测试。该指南写的相当得好。很好!
http://www.statmt.org/moses_steps.html
但是还是会遇到几个问题。
测试环境:2.6.31-22-server #68-Ubuntu SMP Tue Oct 26 16:50:02 UTC 2010 x86_64 GNU/Linux
----------------
支持软件
----------------
++支持软件的版本尽量和指南一致。如果没有一致的,可以选择稍微早一点的版本。如果选择后面的版本,会有一些变数。我还没有去探索具体哪些版本好用。
比如:SRILM 1.5.7,在主页上没有这个版本。我开始选择最新版本,结果遇到一些问题。后来改成下载1.4.6就好用了
++moses-scripts编译中间会提示一些Boost lib缺少的问题,实际不影响(也许在某些地方有用,但是作为我这么菜鸟级的,无所谓)
++如果moses是直接下载的,有时候会出现dos格式 ^M问题,导致perl脚本执行不了的问题。
解决方案1. 把所有的perl文件 第一行结尾 加入空格。
解决方案2. 在所有调用位置 加入 perl a.pl
解决方案3. svn co https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk moses去下载(这也是指南推荐的,我开始土了,直接用web去下载)
---------------
训练过程
---------------
++语料必须是UTF8的
++Giza++在训练过程中,遇到一些core溢出的问题,经过google找回来的问题,我做了如下更改,好用!
*** file_spec.h 2009/07/10 21:38:39 1.1
--- file_spec.h 2009/07/13 11:37:21
! char time_stmp[17];
! sprintf(time_stmp, "%02d-%02d-%02d.%02d%02d%02d.", local->tm_year,
(local->tm_mon + 1), local->tm_mday, local->tm_hour,
local->tm_min, local->tm_sec);
--- 37,49 ----
! char time_stmp[19];
! sprintf(time_stmp, "%04d-%02d-%02d.%02d%02d%02d.", 1900 + local->tm_year,
(local->tm_mon + 1), local->tm_mday, local->tm_hour,
local->tm_min, local->tm_sec);
++MERT训练的时候,应该加入--mertdir 来指定路径,是不是旧版本没有这个问题?我不是很清楚。
++本文用了64位机器,脚本路径应该是i686-m64
大致就这样,其他要做的事情就等。。。直到模型训练成功。
-------------
初步试验结果
--------------
++设置
FBIS作为双语语料
GIGA_xin来训练语料模型(只使用头1M句)
GIGA_xin来训练Recaser(所有的)
没有MERT
++BLUE
19.79
哇,这么高!休息先
2011.1.24
Wednesday, 8 December 2010
抽取subtree居然抽错了
在百忙之中,居然发现抽取3元的双语subtree列表过程中,漏掉很多组合。TMD
下次要小心。
下次要小心。
Monday, 28 June 2010
Tuesday, 22 June 2010
如何训练一个中文的Berkeley Parser
Berkeley Parser - 短语结构的句法分析器
网站:http://code.google.com/p/berkeleyparser/
版本: V1.1
任务目的:中文树库(Penn Chinese Treebank 4.0/5.1)上训练模型。并且不想更改任何Parser内部代码。
=Section 1 数据处理=
可采用如下步骤:
1. 数据文件命名
问题:程序里面是按照英文WSJ树库来的。导致加载树失败。
方案:命名更改为chtb_xxx.fid ==>wsj_xxx.mrg。改完名的文件放在一个目录下(比如NewCTBData)。
2. 数据内容
问题:中文多了一些 SGML的格式。导致加载树失败。
方案:去掉这些标记。
3. 少数数据格式问题
问题1:包含"(IP"这样开头的句子。导致split失败。
方案:在这类句子前后加入 "("和")"
问题2:文件1031.fid
ID=12409
----------------------------------------
..........
(NP (NN 政府
)))
..........
----------------------------------------
方案:应该修改为 “(NP (NN 政府)))”
问题3:文件1117.fid
ID=16046
----------------------------------------
..........
(NP-PN (NR Ken Madsen)))
..........
----------------------------------------
方案:可以改成 “(NR Ken_Madsen)”.
4. 数据集的分割
问题:程序里面按照文件ID使用固定分割。Train: 1-25, 26-270, 400-1151;Dev: 301-325;Test: 271-300
方案: 根据自己需要可以把对应的文件进行替换,但是记住每个分段都至少要有一个文件。比如1-25必须至少有一个文件,26-270也至少有一个文件。
5.残留问题
--2010.6.25
在5.1上得到的model,在分析测试句子的时候会出现大量零输出的现象。
可能方案:去掉文件1022.fid-1029.fid,这个是http://ldd2000.blogspot.com/2008/11/berkeley-parser.html提供的方法,理由不详。应该去监测各个句子,到底是哪个句子出错了。
--2010.6.25
如果使用1-270+400-999作为train set, 271-300作为test set。在分析第339句的时候会出现零输出。
目前无解。WS的把这个句子去掉。:-)
经过如上处理,可以训练和测试Model
=Section 2 命令=
使用命令:
Training $java -cp berkeleyParser.jar edu.berkeley.nlp.PCFGLA.GrammarTrainer -path NewCTBData -out chinese.ctb4.gr -treebank CHINESE
Testing $java -cp berkeleyParser.jar edu.berkeley.nlp.PCFGLA.GrammarTester -path-in -treebank CHINESE -section final -maxL 1000
=Section 3 实验结果=
==3.1 使用系统提供的训练好的Model
据Paper: Slav Petrov and Dan Klein, Improved inference for unlexicalized parsing, NAACL2007
-数据切分:
Train=1-270+400-1151; Dev=301-325; Test=271-300
-报告的结果:
ALL: LP/LR=84.8/81.9; <=40: LP/LR=86.9/85.7
===3.1.1 结果
-command: java -jar berkeleyParser.jar -gr TrainedGrammars/chn_sm5.gr -chinese < mysegmented_sents_list
-Output
ALL : LP/LR/F1=81.02/80.81/80.91
<=40: LP/LR/F1=82.33/83.64/82.98
===3.1.2 结果
-command: java -cp berkeleyParser.jar edu.berkeley.nlp.PCFGLA.GrammarTester -path ~/pcfgParsing/dataCN/train3/ -in TrainedGrammars/chn_sm5.gr -treebank CHINESE -section final -maxL 1000
-Output
ALL : LP/LR/F1= 84.30/80.73/82.48
<=40: LP/LR/F1= 86.68/83.50/85.06
问题:用同一个trained model得到2个差距为2%的结果,为啥?并且较好的结果和报告的结果有大约1%的差距,为啥?设置错了?
==3.2 重新训练Model (去掉1022.fid-1029.fid)
-command: java -Xmx15000m -cp berkeleyParser.jar edu.berkeley.nlp.PCFGLA.GrammarTrainer -path $1 -out $2.Default -treebank CHINESE
-command: java -Xmx15000m -cp berkeleyParser.jar edu.berkeley.nlp.PCFGLA.GrammarTrainer -mergeMinIt 6 -mergeMaxIt 6 -splitMinIt 6 -splitMaxIt 6 -path $1 -out $2.EM6 -treebank CHINESE
-Output
====Default (ALL)=
Bracketing Recall = 81.09
Bracketing Precision = 83.92
Bracketing FMeasure = 82.48
Complete match = 27.75
====EM6(ALL)=
Bracketing Recall = 78.18
Bracketing Precision = 82.15
Bracketing FMeasure = 80.12
Complete match = 28.61
结果比文章报告的结果还是要稍微差一些。
=后记=
注:这里提供的方案是偷懒式方案。
再:解决过程中得到xiaozhu的热情帮助。
网站:http://code.google.com/p/berkeleyparser/
版本: V1.1
任务目的:中文树库(Penn Chinese Treebank 4.0/5.1)上训练模型。并且不想更改任何Parser内部代码。
=Section 1 数据处理=
可采用如下步骤:
1. 数据文件命名
问题:程序里面是按照英文WSJ树库来的。导致加载树失败。
方案:命名更改为chtb_xxx.fid ==>wsj_xxx.mrg。改完名的文件放在一个目录下(比如NewCTBData)。
2. 数据内容
问题:中文多了一些 SGML的格式。导致加载树失败。
方案:去掉这些标记。
3. 少数数据格式问题
问题1:包含"(IP"这样开头的句子。导致split失败。
方案:在这类句子前后加入 "("和")"
问题2:文件1031.fid
ID=12409
----------------------------------------
..........
(NP (NN 政府
)))
..........
----------------------------------------
方案:应该修改为 “(NP (NN 政府)))”
问题3:文件1117.fid
ID=16046
----------------------------------------
..........
(NP-PN (NR Ken Madsen)))
..........
----------------------------------------
方案:可以改成 “(NR Ken_Madsen)”.
4. 数据集的分割
问题:程序里面按照文件ID使用固定分割。Train: 1-25, 26-270, 400-1151;Dev: 301-325;Test: 271-300
方案: 根据自己需要可以把对应的文件进行替换,但是记住每个分段都至少要有一个文件。比如1-25必须至少有一个文件,26-270也至少有一个文件。
5.残留问题
--2010.6.25
在5.1上得到的model,在分析测试句子的时候会出现大量零输出的现象。
可能方案:去掉文件1022.fid-1029.fid,这个是http://ldd2000.blogspot.com/2008/11/berkeley-parser.html提供的方法,理由不详。应该去监测各个句子,到底是哪个句子出错了。
--2010.6.25
如果使用1-270+400-999作为train set, 271-300作为test set。在分析第339句的时候会出现零输出。
目前无解。WS的把这个句子去掉。:-)
经过如上处理,可以训练和测试Model
=Section 2 命令=
使用命令:
Training $java -cp berkeleyParser.jar edu.berkeley.nlp.PCFGLA.GrammarTrainer -path NewCTBData -out chinese.ctb4.gr -treebank CHINESE
Testing $java -cp berkeleyParser.jar edu.berkeley.nlp.PCFGLA.GrammarTester -path
=Section 3 实验结果=
==3.1 使用系统提供的训练好的Model
据Paper: Slav Petrov and Dan Klein, Improved inference for unlexicalized parsing, NAACL2007
-数据切分:
Train=1-270+400-1151; Dev=301-325; Test=271-300
-报告的结果:
ALL: LP/LR=84.8/81.9; <=40: LP/LR=86.9/85.7
===3.1.1 结果
-command: java -jar berkeleyParser.jar -gr TrainedGrammars/chn_sm5.gr -chinese < mysegmented_sents_list
-Output
ALL : LP/LR/F1=81.02/80.81/80.91
<=40: LP/LR/F1=82.33/83.64/82.98
===3.1.2 结果
-command: java -cp berkeleyParser.jar edu.berkeley.nlp.PCFGLA.GrammarTester -path ~/pcfgParsing/dataCN/train3/ -in TrainedGrammars/chn_sm5.gr -treebank CHINESE -section final -maxL 1000
-Output
ALL : LP/LR/F1= 84.30/80.73/82.48
<=40: LP/LR/F1= 86.68/83.50/85.06
问题:用同一个trained model得到2个差距为2%的结果,为啥?并且较好的结果和报告的结果有大约1%的差距,为啥?设置错了?
==3.2 重新训练Model (去掉1022.fid-1029.fid)
-command: java -Xmx15000m -cp berkeleyParser.jar edu.berkeley.nlp.PCFGLA.GrammarTrainer -path $1 -out $2.Default -treebank CHINESE
-command: java -Xmx15000m -cp berkeleyParser.jar edu.berkeley.nlp.PCFGLA.GrammarTrainer -mergeMinIt 6 -mergeMaxIt 6 -splitMinIt 6 -splitMaxIt 6 -path $1 -out $2.EM6 -treebank CHINESE
-Output
====Default (ALL)=
Bracketing Recall = 81.09
Bracketing Precision = 83.92
Bracketing FMeasure = 82.48
Complete match = 27.75
====EM6(ALL)=
Bracketing Recall = 78.18
Bracketing Precision = 82.15
Bracketing FMeasure = 80.12
Complete match = 28.61
结果比文章报告的结果还是要稍微差一些。
=后记=
注:这里提供的方案是偷懒式方案。
再:解决过程中得到xiaozhu的热情帮助。
Subscribe to:
Posts (Atom)