introduction.js

Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests.

This guide is running against Jasmine version 1.2.0 revision 1337005947.

赛题4:难舍难分

下载PDF版本赛题

1. 概述

百度网页搜索是影响力和覆盖率最大的网页搜索工具,每天会有数亿人通过百度网页搜索提交搜索词,查看和点击搜索结果,找到所求。对搜索词进行分析和研究,是搜索引擎的基本技术之一。我们通过它来不断加深对用户需求的理解,改进搜索结果,提高用户对搜索结果满意率。

对搜索词(以下简称query)的一个研究方向就是尝试做搜索词分类。优质的搜索词分类能够让我们更清晰地区分用户需求,了解流量变化趋势。分类问题首先必须面向具体应用建立合理的分类体系。

搜索词分类涉及到多个技术领域,如自然语言处理(NLP)、机器学习、文本分类等等,是一项难度很高的工作。大体来说,短文本的分类难度较高,它具有表义模糊或有歧义、语法形式不规范、难提取有效特征等特点。同时,百度网页query的数量巨大(数十亿),涉及领域广,分类的类别数量多(几百到几千),这些特性让该问题更具有挑战性。

2. 数据集描述

本题目会提供给参赛者两类文件:标注的查询词分类及查询词特征数据。参赛者基于标注的查询词分类及这些查询词对应的特征数据设计算法、训练并检测模型,并利用训练好的算法对待分类查询词进行分类,并给出分类结果。

本题目的数据分为两个阶段公布。第一阶段公布的数据用于初赛阶段,数据内容介绍如下。第二阶段将会提供新的待分类查询词及特征数据,数据含有更多噪音且特征空间变大。

2.1. 标注的查询词类别

初赛阶段公布的用于模型训练和检测的标注查询词包含480个分类,每类约200条查询词。每个查询词占一行,包括三个字段即query_id, query明文和类别标号,每项字段以制表符(\t)分隔开,每行以\n结尾。需要注意的是每个类别的含义并未公布,但从每个类别所含查询词可以了解其类别含义。下面两行为查询词类别文件中的两行,表明“八月桂”这个查询词的id为22,所属类别为185;而“百叶窗”这个查询词的id为23,所属类别为34。表1为查询词类别文件中各个字段含义介绍。

22 八月桂 185

23 百叶窗 34

1 查询词类别文件中各个字段的含义

字段

格式

含义和取值范围

query_id

unsigned int32

query的编号,取值范围为0-10,000,000

query明文

字符串

query的明文,可用于了解查询词内容

class_id

unsigned int32

分类类别标号,0-479

2.2. 查询词特征数据

查询词特征数据分为两类:标注查询词特征数据和待分类查询词特征数据,分别位于不同的文件中,但他们的文件格式相同,只是标注查询词特征数据与标注查询词类别相结合用于模型训练,而待分类查询词用于题目测试。参赛者所提交的算法将对待分类查询词的特征数据进行处理后给出待分类查询词的分类。

每一个查询词的特征数据为一行,包括的字段有query_id, 特征向量长度,每一个特征的特征id和特征权重。每行一个query,每项字段以制表符(\t)分隔开,每行以\n结尾。即:

query_id \t size \t feature_id_1 \t feature_weight_1 \t feature_id_2 \t feature_weight_2 \t ……

如下例所示查询词id为0,含有22个特征,第一个特征的id为7797,特征权重值为4.19117,后续特征id和特征属性依次类推。关于特征数据文件中每行每个字段含义见表2。

0 22 77597 4.19117 57907 2.52463 102261 2.7777 100179 2.28435 100704 4.23765 2409 2.80831 25442 2.76276 138662 11.8289 150839 9.51083 87205 6.54339 137685 4.13053 136771 8.02004 79270 6.00066 80632 8.31261 51236 10.5543 106239 3.78187 102222 6.13974 16484 4.27566 150014 1.47338 69932 6.45025 95094 4.80892 113717 13.1069

2 特征数据文件中各字段含义

字段名

格式

字段含义

query_id

unsigned int32

查询词的编号,全局唯一

size

unsigned int32

表示一个查询词有size个 <feature_id, feature_weight>的pair数据

feature_id

unsigned int32

feature_id是特征的标号,每个特征标号的含义未公布,可以大致认为提取的特征是中文词语。特征空间是153564维度,也就是意味着feature_id的标号是在0到153563之间。

feature_weight

float

对应于特征属性的特征权重,即该特征对query的重要程度,为浮点数

需要注意的是,每个查询词的特征数目不等,平均约在50个左右。标注查询词的特征数据包含约15万个查询词,而待分类查询词特征数据包含1000万个查询词,在这些文件中查询词文本已省略。

3. 任务描述

本题目从百度query分类体系里,选出五百个预先定义好的分类,提供训练样本和测试样本,以及所有样本的特征数据,主要是考察参赛者面对海量真实的中文query数据以及较大类别数的分类体系,如何设计算法,提高短文本的分类准确率。

参赛者可以利用预先标注好分类的query数据进行模型训练和效果自评。最终评估待分类查询词特征数据统一进行。参赛者只需要提供分好类的结果文件并调用相应的命令,则会得到结果文件分类的评估结果。

3.1. 输入

参赛者进行模型训练时可以使用标注的查询词类别和标注的查询词特征数据两个文件。参赛者需要应用所得到的算法和模型对待分类查询词特征数据文件进行处理后给出待分类查询词的类别。

在竞赛所提供的Hadoop平台的/share/data/qc目录下包括本题目所需的数据,名为query-to-classify-features.txt是待分类的查询词特征数据文件,包括约1000万个待分类的查询词。名为query-classified.txt是标注的查询词类别文件,名为query-classified-features.txt是标注的查询词特征数据文件。

3.2. 输出

参赛者给出待分类查询词的类别。其格式为每行一个查询词,每行包括两个字段,第一个字段为查询词的query_id,第二个字段为该查询词所属class_id,如下所示:

query_id \t class_id

3.3. 约束条件

参赛者通过参赛网站进入计算平台http://cc-ws.duapp.com(参赛网站有相关指示),登录后可以操作hadoop命令。本题目所有的数据放置在HDFS的共享目录:/share/data/qc下。这个目录下的文件为只读文件,参赛者在计算平台所提供的Hadoop环境上通过MapReduce编程对数据进行处理。

计算平台也提供了在线评估答案的命令,其使用方式为:

evaluate-pr|qc result_file

其中evaluate为命令名,"-pr|qc"为评估的题目名称。对于本题目选择qc参数,result_file为参赛者所输出的最终文件在参赛者的工作目录中的路径及文件名。如果结果文件位于HDFS系统中,参赛者可以首先使用“hadoop fs –get”命令拷贝到其工作目录中,然后调用evaluate命令。evaluate命令比较参赛者所提供的最终结果文件中的分类结果和本题目标注的分类结果,并输出此次分类的正确率。

参赛者必须提供相应的源代码,才能参与评奖。相关程序的知识产权归参赛选手所有(不得侵犯他人权益),大赛组委会取得的相关资料仅用于评奖使用。

4. 评价标准

在1000万个待分类查询词里,我们会抽样一部分作为评估对象进行统计。抽取哪些样本是不公开的,但是会均匀涵盖480个类别。我们以正确率作为分类效果的评估指标。设总共有K个类,对于第i个类有个用于评估的查询词,参赛者的方法正确给出个查询词的类别为i。则第i个类的分类正确率为。分类正确率R计为所有这些类别的分类正确率的平均值:

参赛者给出所有待分类查询词的分类后,他可以调用“evaluate”命令来计算分类正确率。每次调用都会立刻给出分类正确率,用于评估其算法的优劣。同时,在规定的时间调用“evaluate”命令所给出的分类正确率将会记录在案以作为成绩评定的标准。

Effing Package Management.

Preface

Package maintainers work hard and take a lot of shit. You can't please
everyone. So, if you're a maintainer: Thanks for maintaining packages!

What is fpm?

It helps you build packages quickly (Packages like RPM and DEB formats).

Here is a presentation I gave on fpm at BayLISA: http://goo.gl/sWs3Z (I
included speaker notes you can read, too)

At BayLISA in April 2011, I gave a talk about fpm. At the end, I asked "What
can I package for you?"

Someone asked for memcached.

Google for 'memcached', download the source, unpack, ./configure, make, make
install, fpm, deploy.

In 60 seconds, starting from nothing, I had both an RPM and a .DEB of memcached
ready to deploy, and I didn't need to know how to use rpmbuild, rpm specfiles,
dh_make, debian control files, etc.

Backstory

Sometimes packaging is done wrong (because you can't do it right for all
situations), but small tweaks can fix it.

And sometimes, there isn't a package available for the tool you need.

And sometimes if you ask "How do I get python 3 on CentOS 5?" some unhelpful
trolls will tell you to "Use another distro"

Further, a job switches have me flipping between Ubuntu and CentOS. These use
two totally different package systems with completely different packaging
policies and support tools. Learning both was painful and confusing. I want to
save myself (and you) that pain in the future.

It should be easy to say "here's my install dir and here's some dependencies;
please make a package"

The Solution - FPM

I want a simple way to create packages without all the bullshit. In my own
infrastructure, I have no interest in Debian policy and RedHat packaging
guidelines - I have interest in my group's own style culture and have a very strong
interest in getting work done.

(This is not to say that you can't create packages with FPM that obey Debian or
RedHat policies, you can and should if that is what you desire)

The goal of FPM is to be able to easily build platform-native packages.

  • Creating packages easily (deb, rpm, etc)
  • Tweaking existing packages (removing files, changing metadata/dependencies)
  • Stripping pre/post/maintainer scripts from packages

Get with the download

You can install fpm with gem:

gem install fpm

Running it:

fpm -s TYPE -t TYPE ...

Things that are in the works or should work:

Sources:

  • gem (even autodownloaded for you)
  • python modules (autodownload for you)
  • pear (also downloads for you)
  • directories
  • rpm
  • deb
  • node packages (npm)

Targets:

  • deb
  • rpm
  • solaris
  • tar
  • directories

Need Help or Want to Contribute?

All contributions are welcome: ideas, patches, documentation, bug reports,
complaints, and even something you drew up on a napkin.

It is more important to me that you are able to contribute and get help if you
need it..

That said, some basic guidelines, which you are free to ignore :)

  • Have a problem you want fpm to solve for you? You can email the
    mailing list, or
    join the IRC channel #fpm on irc.freenode.org, or email me personally
    (jls@semicomplete.com)
  • Have an idea or a feature request? File a ticket on
    github, or email the
    mailing list, or email
    me personally (jls@semicomplete.com) if that is more comfortable.
  • If you think you found a bug, it probably is a bug. File it on
    jira or send details to
    the mailing list.
  • If you want to send patches, best way is to fork this repo and send me a pull
    request. If you don't know git, I also accept diff(1) formatted patches -
    whatever is most comfortable for you.
  • Want to lurk about and see what others are doing? IRC (#fpm on
    irc.freenode.org) is a good place for this as is the
    mailing list

More Documentation

See the wiki for more docs

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。