<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>R2S &#187; 统计之路</title> <atom:link href="http://www.road2stat.com/cn/category/statistics/feed" rel="self" type="application/rss+xml" /><link>http://www.road2stat.com/cn</link> <description>江湖一散人</description> <lastBuildDate>Thu, 26 Jan 2012 08:18:36 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>豆瓣评分计算策略的猜想</title><link>http://www.road2stat.com/cn/statistics/douban_rank.html</link> <comments>http://www.road2stat.com/cn/statistics/douban_rank.html#comments</comments> <pubDate>Sat, 31 Dec 2011 12:48:49 +0000</pubDate> <dc:creator>Xiao Nan</dc:creator> <category><![CDATA[统计之路]]></category> <category><![CDATA[douban]]></category> <category><![CDATA[IMDB]]></category> <category><![CDATA[quantreg]]></category> <category><![CDATA[XML]]></category> <category><![CDATA[公式]]></category> <category><![CDATA[分位回归]]></category> <category><![CDATA[参数]]></category> <category><![CDATA[排序]]></category> <category><![CDATA[测度]]></category> <category><![CDATA[计算]]></category> <category><![CDATA[评分]]></category> <category><![CDATA[豆瓣]]></category> <category><![CDATA[豆瓣电影250]]></category> <category><![CDATA[距离]]></category><guid isPermaLink="false">http://www.road2stat.com/cn/?p=985</guid> <description><![CDATA[1 引 在九月短文 [1] 中, 我们对豆瓣电影评分的一个侧面有了简单认识. 其实, 我们对评分计算规则本身也是很感兴趣的. 这里以豆瓣电影为例作一简单猜想和分析, 音乐图书同理. 题中"策略"是相对"机制"来说的, 所指其实是比较具体的. 2 单个条目 有群众表示, 单个条目的评分计算只是对各个星级打分人数简单的加权平均, 由于页面上显示的评分结果满分是10分, 而打分时只有5个星级, 所以每个星级对应2分, 单个条目评分的计算公式即为: 评分 = (10 x 5星比例) + (8 x 4星比例) + ... + (2 x 1星比例) 抽取部分条目对此假设进行手工验证, 可以发现的确如此. 但是, 这里存在的一个陷阱是, 由于评分数据的特殊性和抽样的限制, &#8230; <a href="http://www.road2stat.com/cn/statistics/douban_rank.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/12/simpsons_movie.jpg"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/12/simpsons_movie.jpg" alt="simpsons_movie" title="simpsons_movie" width="500" height="325" class="aligncenter size-full wp-image-986" /></a></p><h2>1 引</h2><p>在九月短文 [1] 中, 我们对豆瓣电影评分的一个侧面有了简单认识. 其实, 我们对评分计算规则本身也是很感兴趣的. 这里以豆瓣电影为例作一简单猜想和分析, 音乐图书同理. 题中"策略"是相对"机制"来说的, 所指其实是比较具体的.</p><h2>2 单个条目</h2><p>有群众表示, 单个条目的评分计算只是对各个星级打分人数简单的加权平均, 由于页面上显示的评分结果满分是10分, 而打分时只有5个星级, 所以每个星级对应2分, 单个条目评分的计算公式即为:</p><p><code>评分 = (10 x 5星比例) + (8 x 4星比例) + ... + (2 x 1星比例)</code></p><p>抽取部分条目对此假设进行手工验证, 可以发现的确如此.</p><p>但是, 这里存在的一个陷阱是, 由于评分数据的特殊性和抽样的限制, 如果我们抽取一部分数据做回归, 结果可能会受到样本的影响而与手工验证的结果产生偏移. 由于1星(很差)和2星(较差)在大量条目样本中所占往往比例非常小, 普通的回归非常容易倾向于使X1, X2, X3的系数减小. 举例来说, 从<a href="http://movie.douban.com/people/road2stat/collect?sort=time&#038;mode=list" target="_blank">我看过</a>的443部电影中抽取前400个条目作为样本 <a href='http://www.road2stat.com/cn/wp-content/attachments/2011/12/rateSample.csv'>[rateSample.csv]</a> 作回归.</p><p><span id="more-985"></span></p><p>回归结果:<br /> <code>Call:<br /> lm(formula = Y ~ . - 1, data = rateSample)</p><p>Residuals:<br /> Min        1Q    Median        3Q       Max<br /> -0.248949 -0.036126  0.001084  0.042101  0.217110</p><p>Coefficients:<br /> Estimate Std. Error t value  Pr(>|t|)<br /> X5  9.97216    0.01884  529.436 <2e-16 ***<br /> X4  7.98297    0.03287  242.901 <2e-16 ***<br /> X3  5.64024    0.05587  100.962 <2e-16 ***<br /> X2  4.41272    0.29841   14.787 <2e-16 ***<br /> X1  1.38666    0.64675    2.144  0.0326 *<br /> ---<br /> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</p><p>Residual standard error: 0.06798 on 395 degrees of freedom<br /> Multiple R-squared: 0.9999,	Adjusted R-squared: 0.9999<br /> F-statistic: 1.053e+06 on 5 and 395 DF,  p-value: < 2.2e-16</code></p><p>由于这里的评分人数比例存在四舍五入现象, 所以每个条目5个星级的评分人数比例之和并不一定严格为1, 不过画图可知基本都处于[0.999, 1.001], 存在4个和为0.998, 1.002的样本, 不影响结果.</p><p>观察回归结果发现, 样本的这种特殊情况确对X3, X2, X1项有影响, 虽然检验结果是显著的, 但偏离了真实值6, 4, 2很远.</p><p>插句题外话, Box(是的, 就是你知道的那个Box)曾曰, <em>Statisticians, like artists, have the bad habit of falling in love with their models</em>.</p><p>爱不爱上模特的事情我不是很懂, 不过, 真的不要爱上模型. 原因么, 我们续写一下名句就知道了:</p><p><em>Models are always with their assumptions</em>.</p><p>题外话完毕. 使用平行坐标图展示一下这400部的评分数据:</p><p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/12/rate_para_coord.png"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/12/rate_para_coord.png" alt="rate_para_coord" title="rate_para_coord" width="500" height="309" class="aligncenter size-full wp-image-988" /></a></p><p>可见大部分样本的整体评分状况. 1, 2星的数量远不及3, 4, 5星.</p><p>猜想这种情况可能是两种原因所致:</p><ul><li>豆瓣的电影推荐让用户更倾向于去看他人评价较高的影片, 越是评分较低的影片越无人光顾, 于是拉高了整体评分;</li><li>用户可能对那些质量一般的电影疏于打分, 而对自己喜欢的片子倾向于打分. 这就造成了客观上部分低分评分数据的缺失, 特别是在5分制(不同于IMDB的10分制)对于影片的区分度比较低的情况下.</li></ul><h2>3 豆瓣电影250榜单</h2><p>豆瓣电影和IMDB都有TOP 250榜单. 关于豆瓣电影250的计算方法, 之前已经有一些讨论 [2]. 一个有趣的问题是, 假设豆瓣的确使用了IMDB公式 [3] 计算得到此榜单, 可否由数据反演出公式中的两个参数?</p><p>其实, 这是一个以排序为因变量的回归问题, 既不同于传统的纯回归问题, 又不同于经典的排序学习问题. 事实上, 这个问题对两方面都提出了比较高的要求:</p><ol><li>对于传统的回归问题, 这里我们虽然想求得回归系数, 但目标变量是一种排序;</li><li>对于经典的排序学习问题, 这里我们虽然目标变量是排序, 但要求针对回归方程求出显式的回归系数;</li><li>如果转化为传统的分类问题, 信息会有比较大的损失.</li></ol><p>翻箱倒柜, 发现KDD10'的一片文章中, 来自Google的D. Sculley提出了一种方法 [4] (给出了现成工具 [5], 还有人port了R包 [6]) 来处理这类问题, 但由于这里的问题是非线性的, 不好直接处理.</p><p>不过不要对生活失去信心. 由于维度较低, 最终仍然有一种方法是可行的: 我们可以估计出参数所在的大致区间, 然后针对某种排序准确性的测度(这里单纯地采用了街区距离和欧氏距离), 暴力搜索这些区间组成的空间, 最后取排序结果最准确的点或点集. 按这个思路做了一下, 在<strong>使用这个公式的假设下</strong>, 可以估计取得数据时 (2011/12/26) 的参数C约为[6.0, 6.1], 参数m大致在[2900, 3100].</p><p>由于豆瓣电影250的榜单并非实时更新, 而榜单中的评分人数和得分却是实时更新的, 且网格的密度有限, 猜解结果理应存在误差. 我们猜测, 这种现实情况可能对于位于榜单后半部分的影片产生更强的影响, 而榜单上排名靠前的影片则会相对稳定. 对各个元素所在位置与其真实位次产生的偏移做分位回归 [7]:</p><p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/12/rank_shift_quantreg.png"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/12/rank_shift_quantreg.png" alt="rank_shift_quantreg" title="rank_shift_quantreg" width="500" height="470" class="aligncenter size-full wp-image-989" /></a></p><p>红色虚线为最小二乘估计, 灰色实线为0.1, 0.25, 0.75, 0.9五个分位点处的分位回归估计, 黑色实线为0.5分位点.</p><p>看图说话:</p><ul><li>榜单偏后部分的偏移比前半部分稍强;</li><li>不同分位点的样本点偏移程度受其所在榜单位置的影响稍有不同.</li></ul><p>有兴趣的同学还可以跟踪观察榜单更新时得到的计算结果将有何变化.</p><h2>4 结</h2><p>有益的思考:</p><ol><li>单个条目的评分就是单纯的对5个得分进行加权平均. 此法尚有修正空间, 如果未考虑不同用户的评分权重, 则容易引入恶意评分问题;</li><li>豆瓣250榜单的计算可能借鉴了IMDB公式, 也可能对其设计进行了修改. 关于这个公式本身, 存在一些评论 [8], 或可对其进行修正;</li><li>在<strong>使用这个公式的假设下</strong>, 可以根据豆瓣电影250榜单的变化情况即时猜解参数, 从而了解当时(设定的)所有电影的平均分和上榜最低评分人数标准. 由这两个参数, 结合现有榜单所含信息, 我们可以在榜单更新延迟时, 提前推得某个条目在有一定评价人数(>m)时, 达到某个位置所需的最低得分; 或保持一定得分前提下, 分析上榜所需的最少评分人数.</li></ol><p>存在的问题:</p><ol><li>如果实际上未使用原始公式, 则以上估计是几乎没有什么意义的;</li><li>如果榜单有人为因素的干预, 例如只计算经常打分的用户的打分, 将对这种估计造成影响 [8];</li><li>排序准确性测度有待商榷;</li><li>这种解法虽然给出了全局最小, 但这个全局最小并不一定与真实参数等价, 真实参数也有可能隐匿在其它较小值的集合中.</li></ol><p>最后, 有代码有真相. <a href='http://www.road2stat.com/cn/wp-content/attachments/2011/12/dbrank.R'>[dbrank.R]</a></p><h2>参考</h2><p>[1] R2S. <a href="http://www.road2stat.com/cn/statistics/douban_rating.html" title="豆瓣用户对不同类型影片的打分是否真的有倾向性?" target="_blank">豆瓣用户对不同类型影片的打分是否真的有倾向性?</a></p><p>[2] 麻油四. <a href="http://www.douban.com/group/topic/2426734/" target="_blank">豆瓣250算法浅析</a>.</p><p>[3] Wikipedia. <a href="http://en.wikipedia.org/wiki/Internet_Movie_Database" target="_blank">Internet Movie Database</a>.</p><p>[4] D. Sculley. Combined Regression and Ranking. Proceedings of the 16th Annual SIGKDD Conference on Knowledge Discover and Data Mining, 2010.</p><p>[5] D. Sculley. <a href="http://code.google.com/p/sofia-ml/" target="_blank">sofia-ml</a> - Suite of Fast Incremental Algorithms for Machine Learning.</p><p>[6] Michael King and Fernando Cela Diaz. (2011). <a href="http://CRAN.R-project.org/package=RSofia" target="_blank">RSofia</a>: Port of sofia-ml to R.</p><p>[7] Roger Koenker (2011). <a href="http://CRAN.R-project.org/package=quantreg" target="_blank">quantreg</a>: Quantile Regression.</p><p>[8] <a href="http://www.azillionmonkeys.com/qed/imdbfix.shtml" target="_blank">Corrected IMDb Movie Rankings</a>.</p> ]]></content:encoded> <wfw:commentRss>http://www.road2stat.com/cn/statistics/douban_rank.html/feed</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Ten Typical Symptoms of Potential Academic Paranoia</title><link>http://www.road2stat.com/cn/statistics/academic_paranoia.html</link> <comments>http://www.road2stat.com/cn/statistics/academic_paranoia.html#comments</comments> <pubDate>Tue, 11 Oct 2011 16:42:26 +0000</pubDate> <dc:creator>Xiao Nan</dc:creator> <category><![CDATA[统计之路]]></category> <category><![CDATA[academic]]></category> <category><![CDATA[Lisa Simpson]]></category> <category><![CDATA[paranoia]]></category> <category><![CDATA[symptoms]]></category><guid isPermaLink="false">http://www.road2stat.com/cn/?p=956</guid> <description><![CDATA[Getting used to writing articles that begin with a section named 'Introduction' or end up with section 'Conclusions'. Always cites several references in any type/length of essays; strongly believes that without the citations, the work will not be recognized by &#8230; <a href="http://www.road2stat.com/cn/statistics/academic_paranoia.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/10/Frink.png"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/10/Frink.png" alt="Prof.Frink" title="Prof.Frink" width="480" height="445" class="aligncenter size-full wp-image-958" /></a></p><ol><li>Getting used to writing articles that begin with a section named 'Introduction' or end up with section 'Conclusions'.</li><li>Always cites several references in any type/length of essays; strongly believes that without the citations, the work will not be recognized by anybody.</li><li>Hates magazines with huge pictures and imprecise textual materials; has a special fondness for two-column, small font, tight dissertations with formulas, three-line tables, and stylish,  dot-and-line formed scalable graphics.</li><li>Uses a reference manager, instead of regular tools such as Google Calendar, to organize daily life.</li><li>Blogs academic topics constantly for 2.5+ years, or has set up a stand-alone blog about  current research.</li><li>Talks academic in 50%+ Twitter/Facebook status in last 2 years, or has pure academic purpose social accounts.</li><li>Used to have at least one horrible nightmares about a B+ ruined perfect straight As, just like Lisa Simpson did.</li><li>Once encountered some data from the middle of nowhere, always considers what its underlying patterns look like; imagines constructing a quantitative model for it, very seriously.</li><li>When saw a problem, couldn't help diving into scholar databases to retrieve related papers, thoroughly read the references and dug recursively; Gigabytes of papers are storaged in the hard-drive eventually.</li><li>Blogs academic paranoia and doesn't feel anything, until now.</li></ol> ]]></content:encoded> <wfw:commentRss>http://www.road2stat.com/cn/statistics/academic_paranoia.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Visualizing CRAN Package Dependency Network: Reveal Hidden Patterns with Martin Krzywinski&#039;s Hive Panel</title><link>http://www.road2stat.com/cn/statistics/hivepanel.html</link> <comments>http://www.road2stat.com/cn/statistics/hivepanel.html#comments</comments> <pubDate>Thu, 29 Sep 2011 12:06:10 +0000</pubDate> <dc:creator>Xiao Nan</dc:creator> <category><![CDATA[统计之路]]></category> <category><![CDATA[community]]></category> <category><![CDATA[CRAN]]></category> <category><![CDATA[dependency]]></category> <category><![CDATA[hive panel]]></category> <category><![CDATA[hive plots]]></category> <category><![CDATA[network]]></category> <category><![CDATA[package]]></category> <category><![CDATA[R]]></category> <category><![CDATA[Visualization]]></category><guid isPermaLink="false">http://www.road2stat.com/cn/?p=937</guid> <description><![CDATA[1 Introduction Studying the networks of online software community is fascinating. CPAN Explorer is a typical project aiming at analyzing the relationships in CPAN community [1]. CRAN package dependency network is another excellent source for this type of research. A &#8230; <a href="http://www.road2stat.com/cn/statistics/hivepanel.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<h1>1 Introduction</h1><p>Studying the networks of online software community is fascinating. <a href="http://cpan-explorer.org/" target="_blank">CPAN Explorer</a> is a typical project aiming at analyzing the relationships in CPAN community [1]. CRAN package dependency network is another excellent source for this type of research. A state-of-art visualization is usually required to understand the network [2].</p><p>A common problem of conventional hairball style network visualization is: the graph becomes uninterpretable when it meets very large networks [3]. Researchers developed techniques such as hierarchical edge bundles [4] to tackle this problem. However, that's just too ideal for real world visualization problems. When it's emphasizing the strong connections in the network, the less strong part and the key details could possibly be ignored. Conventional visualization methods have constrained us to take a further step: revealing more hidden information of the internal structure (vertices, connectivity, etc.) in the network.</p><h1>2 Hive Plots</h1><p>Martin Krzywinski, author of the circular style genome visualization tool circos, proposed the hive plots in 2010 [5]. The most significant difference between hive plots and traditional layout is: its graphic design is based on the network's meaningful properties (vertices' degree, connectivity, centrality, etc.) instead of aesthetics. This design makes the graph interpretable and thus simplifies the presentation of relational data.</p><h1>3 The Visualization</h1><p>We selected 27 representative packages and visualize every three of them in one hive plot to make a 3x3 hive panel. Each panel represents a specific research field. Each node of the network is mapped on the axes by its degree information: green axis represents out-degree, orange axis represents in-degree, and purple axis combines in/out-degrees together. On each axis, outer nodes have higher degrees. The white connections, as the background, show us the overall connectivity of the network: the nodes have higher out-degrees are heavily depended by all ranges of nodes in the network, and the brighter parts of the arcs tend to indicate potential cluster patterns.</p><p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/09/hiveplot.png"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/09/hiveplot.png" alt="hiveplot" title="hiveplot" width="500" height="500" class="aligncenter size-full wp-image-938" /></a></p><blockquote><p><a href="http://www.flickr.com/photos/road2stat/6194849428/" target="_blank">Click here to see a larger version.</a></p></blockquote><p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/09/hivepanel.png"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/09/hivepanel.png" alt="hivepanel" title="hivepanel" width="500" height="500" class="aligncenter size-full wp-image-939" /></a></p><blockquote><p><a href="http://www.flickr.com/photos/road2stat/6194849550/" target="_blank">Click here to see a larger version.</a></p></blockquote><p>Meanwhile, we highlight three of the interested packages in each research field in one panel with three different colors to reveal its specific connection patterns. For the first panel, green connections represents <strong>lattice</strong> package. It's a fundamental package for graphic design in R, which is heavily depended by packages of all degrees. The purple connections represent the <strong>rgl</strong> package. It depends a little but it's depended by much more packages that distributed more discretely on the orange axis than <strong>lattice</strong> was. Orange lines represent the <strong>gplots</strong> package, which contains various miscellaneous tools for plotting. Obviously, the dependency patterns indicate its different role between the previous ones: it's more of a handy toolset for plotting, rather than a core package. The upper right panel shows us three of the data import/export packages: <strong>DBI</strong>, <strong>RODBC</strong> and <strong>RSQLite</strong>. Amazingly, althought they play different roles in the whole community, their dependency patterns are almost the same, except for a little difference between their degrees. The central panel, which highlights the finance-related packages <strong>fBasics</strong>, <strong>fOptions</strong>, and <strong>fGarch</strong>, reveals similar features.</p><p>Hive plots are relatively much more informative and comprehensive than conventional hairball-style visualizations, especially for large networks. You could discover much more interesting patterns in other panels yourself with this visualization.</p><p>The selected packages (ordered by panel 11, 12, 13, 21, 22 …) are:<ul><li>Graphics: lattice / rgl / gplots (Green / Purple / Orange)</li><li>Programming: tools / rJava / Rcpp</li><li>Data Import/Export: DBI / RODBC / RSQLite</li><li>GUI Dev Tools &#038; Framework: tcltk / gWidgets / Rcmdr</li><li>Finance: fBasics / fOptions / fGarch</li><li>Machine Learning: e1071 / rpart / randomForest</li><li>Regression Analysis: car / leaps / quantreg</li><li>Spatial and Geo Statistics: sp / maps / fields</li><li>Time Series Analysis: forecast / timeDate / tseries</li></ul><h1>4 Details</h1><p>The creation of this visualization is really simple; highly reproducible for anyone who has a little knowledge of SNA [6]:</p><ol><li>The original data was retrieved from<br /> <a href="http://cran.r-project.org/bin/windows/contrib/2.13/PACKAGES" target="_blank">http://cran.r-project.org/bin/windows/contrib/2.13/PACKAGES</a><br /> on September 14, 2011. We only extracted the 'Depends' section of each package. After parsing and a bit of cleaning, a network consisted of <strong>2,500</strong> vertices and <strong>5,900</strong> arcs was constructed.</li><li>To shrink the network, perform k-core analysis and extract the 4-6 cores partition to form a new network, a denser one, with less noise. Now it's reduced to about <strong>600</strong> vertices and <strong>2,500</strong> arcs.</li><li>Draw the shrinked network permuted by degree information with Martin's linnet tool. Each single panel implies a package's degree and dependency distribution properties. Combine the 9 separated hive plots to form a complete hive panel.</li></ol><h1>References</h1><p>[1] Julian Bilcke. CPAN Explorer - An Interactive Exploration of the Perl Ecosystem. <a href="http://cpan-explorer.org/" target="_blank">http://cpan-explorer.org/</a>, 2009.<br /> [2] Xiao Nan. R2S - PKU Vis Summer School. <a href="http://www.road2stat.com/cn/statistics/pku_vis_summer_school.html" target="_blank">http://www.road2stat.com/cn/statistics/pku_vis_summer_school.html</a>, 2010.<br /> [3] Koon-Kiu Yana, Gang Fanga, Nitin Bhardwaja, Roger P. Alexandera, Mark Gerstein. Comparing Genomes to Computer Operating Systems in Terms of the Topology and Evolution of their Regulatory Control Networks. Proceedings of the National Academy of Sciences, 107 (20): 9186 - 9191, 2006.<br /> [4] Danny Holten. Hierarchical Edge Bundles: Visualization of Adjacency Relations in Hierarchical Data. IEEE Transactions on Visualization and Computer Graphics (TVCG; Proceedings of Vis/InfoVis 2006), Vol. 12, No. 5, 741 - 748, 2006.<br /> [5] Martin Krzywinski. Hive Plots - Linear Layout for Network Visualization - Visually Interpreting Network Structure and Content Made Possible. <a href="http://www.hiveplot.com/" target="_blank">http://www.hiveplot.com/</a>, 2010.<br /> [6] Wouter de Nooy, Andrej Mrvar, Vladimir Batagelj. Exploratory Social Network Analysis with Pajek. Cambridge University Press, 2005.<br /> [7] J.R. Heard. World Economic Forum Hive Plot. <a href="http://www.visualizing.org/visualizations/world-economic-forum-hive-plot/" target="_blank">http://www.visualizing.org/visualizations/world-economic-forum-hive-plot/</a>, 2010.</p> ]]></content:encoded> <wfw:commentRss>http://www.road2stat.com/cn/statistics/hivepanel.html/feed</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>豆瓣用户对不同类型影片的打分是否真的有倾向性?</title><link>http://www.road2stat.com/cn/statistics/douban_rating.html</link> <comments>http://www.road2stat.com/cn/statistics/douban_rating.html#comments</comments> <pubDate>Tue, 06 Sep 2011 16:27:28 +0000</pubDate> <dc:creator>Xiao Nan</dc:creator> <category><![CDATA[统计之路]]></category> <category><![CDATA[Mann-Whitney检验]]></category> <category><![CDATA[stripplot]]></category> <category><![CDATA[Wilcoxon检验]]></category> <category><![CDATA[倾向性]]></category> <category><![CDATA[小提琴图]]></category> <category><![CDATA[恐怖片]]></category> <category><![CDATA[打分]]></category> <category><![CDATA[核密度估计]]></category> <category><![CDATA[箱线图]]></category> <category><![CDATA[豆瓣]]></category><guid isPermaLink="false">http://www.road2stat.com/cn/?p=920</guid> <description><![CDATA[1 起 在豆瓣上为数不少的恐怖/惊悚片的讨论中, 我们常常可以发现类似于这样的说法 [1]: 像这部片子 也有吸引人看下去的地方 为什么分数总是那么低? 那么, 豆瓣用户对这类影片的打分上, 是否真的存在普遍低于其他类型的影片的情况? 为了验证这个猜想, 我们不妨利用豆瓣提供的评分数据来简单分析一下. 2 承 首先明确问题的定义. 这里我们不去比较恐怖片和其他所有类型片的总体. 其实, 更让人感兴趣的问题是, 将恐怖片与其他同级别类型的影片分别进行两两比较, 结果会如何. 豆瓣的电影条目是采用tag来进行分类的. 此时样本的选取成了一个问题. 总的来说, 要保证各类型影片的类型特征区别要尽量大, 比如恐怖片和惊悚片之间的差别没有恐怖片和励志片的差别明显, 又如有可能一部影片既有"爱情"标签, 也有"喜剧"标签, 也就是说, 各类型的影片将存在交集. 同时, 也要保证各类样本在其他方面的差别尽量小, 如不同类型影片的总体规模差距不能过于悬殊等等. 我是这样做的. 2.1 选取分类 参考IMDB的Genre分类, 在豆瓣电影标签页面选取8个比较主流的Genre, 标准是各类含有个数的差别不能过大, 因此剔除了动作/爱情/科幻等远超过100万部的类别. &#8230; <a href="http://www.road2stat.com/cn/statistics/douban_rating.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<h1>1 起</h1><p>在豆瓣上为数不少的恐怖/惊悚片的讨论中, 我们常常可以发现类似于这样的说法 [1]:</p><blockquote><p>像这部片子<br /> 也有吸引人看下去的地方<br /> 为什么分数总是那么低?</p></blockquote><p>那么, 豆瓣用户对这类影片的打分上, 是否真的存在普遍低于其他类型的影片的情况? 为了验证这个猜想, 我们不妨利用豆瓣提供的评分数据来简单分析一下.</p><h1>2 承</h1><p>首先明确问题的定义. 这里我们不去比较恐怖片和其他所有类型片的总体. 其实, 更让人感兴趣的问题是, 将恐怖片与其他同级别类型的影片分别进行两两比较, 结果会如何.</p><p>豆瓣的电影条目是采用tag来进行分类的. 此时样本的选取成了一个问题. 总的来说, 要保证各类型影片的类型特征区别要尽量大, 比如恐怖片和惊悚片之间的差别没有恐怖片和励志片的差别明显, 又如有可能一部影片既有"爱情"标签, 也有"喜剧"标签, 也就是说, 各类型的影片将存在交集. 同时, 也要保证各类样本在其他方面的差别尽量小, 如不同类型影片的总体规模差距不能过于悬殊等等.</p><p>我是这样做的.</p><p><span id="more-920"></span></p><h2>2.1 选取分类</h2><p>参考IMDB的<a href="http://www.imdb.com/genre" target="_blank">Genre分类</a>, 在<a href="http://movie.douban.com/tag/" target="_blank">豆瓣电影标签</a>页面选取8个比较主流的Genre, 标准是各类含有个数的差别不能过大, 因此剔除了动作/爱情/科幻等远超过100万部的类别. 同时, 各类之间的类型区别要明晰. 这8类和各类中的条目数分别为:</p><blockquote><p>纪录 (592406)<br /> 励志 (579749)<br /> 犯罪 (545789)<br /> 恐怖 (524562)<br /> 科幻 (1463871)<br /> 战争 (480216)<br /> 文艺 (471861)<br /> 动画短片 (432140)</p></blockquote><h2>2.2 提取条目链接</h2><p>各类按标注次数排序(<code>type=O</code>), 各类分别提取1600部(20部/页 x 80页)的条目链接:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p920code3'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9203"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p920code3"><pre class="rsplus" style="font-family:monospace;"><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/require.html"><span style="color: #0000FF; font-weight: bold;">require</span></a><span style="color: #080;">&#40;</span>XML<span style="color: #080;">&#41;</span>
idParser <span style="color: #080;">=</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/function.html"><span style="color: #0000FF; font-weight: bold;">function</span></a><span style="color: #080;">&#40;</span>genre, <span style="color: #0000FF; font-weight: bold;">start</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/url.html"><span style="color: #0000FF; font-weight: bold;">url</span></a> <span style="color: #080;">=</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/paste.html"><span style="color: #0000FF; font-weight: bold;">paste</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;http://movie.douban.com/tag/&quot;</span>, 
                    genre, <span style="color: #ff0000;">&quot;?start=&quot;</span>, <span style="color: #0000FF; font-weight: bold;">start</span>, <span style="color: #ff0000;">&quot;&amp;type=O&quot;</span>, sep <span style="color: #080;">=</span> <span style="color: #ff0000;">''</span><span style="color: #080;">&#41;</span>
	idPage <span style="color: #080;">=</span> htmlTreeParse<span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/url.html"><span style="color: #0000FF; font-weight: bold;">url</span></a>, useInternal <span style="color: #080;">=</span> TRUE<span style="color: #080;">&#41;</span>
	x <span style="color: #080;">=</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/rep.html"><span style="color: #0000FF; font-weight: bold;">rep</span></a><span style="color: #080;">&#40;</span>NA, <span style="color: #ff0000;">20</span><span style="color: #080;">&#41;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/for.html"><span style="color: #0000FF; font-weight: bold;">for</span></a> <span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/seq.html"><span style="color: #0000FF; font-weight: bold;">seq</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">22</span>, <span style="color: #ff0000;">61</span>, <span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	x<span style="color: #080;">&#91;</span><span style="color: #080;">&#40;</span>i<span style="color: #080;">/</span><span style="color: #ff0000;">2</span><span style="color: #080;">-</span><span style="color: #ff0000;">10</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span> <span style="color: #080;">=</span> xpathApply<span style="color: #080;">&#40;</span>idPage, path <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;//a&quot;</span>, 
                                 xmlGetAttr, <span style="color: #ff0000;">&quot;href&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span>
	<span style="color: #080;">&#125;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/return.html"><span style="color: #0000FF; font-weight: bold;">return</span></a><span style="color: #080;">&#40;</span>x<span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span></pre></td></tr></table></div><p>这里考虑了评价人数的问题: 评分人数过少的条目不予入选. 豆瓣的评分计算方法中虽然像IMDB一样考虑了评分人数多少的问题 -- 评分人数少的条目虽然得分不会特别高或特别低, 但从反映主流观影口味角度, 选取观看人数较少的影片毕竟存在着较大风险. 同时不难发现, 每类在1600条处基本都有1000+左右的标注, 评分人数能够得到保证, 可以认为样本的评分比较公正.</p><h2>2.3 剔除冗余条目</h2><p>8类之间两两比较, 首先剔除本类中重复的条目(的确存在!), 然后剔除掉同时属于多类的条目. 此时每类剩余约1100 - 1300部互无任何交集的影片.</p><h2>2.4 抽样</h2><p>在剩余样本中, 每类随机抽取1000个条目.</p><h2>2.5 读取评分</h2><p>利用豆瓣API [2] 读取1000 x 8 = 8000个评分数据(平均分).</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p920code4'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9204"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p920code4"><pre class="rsplus" style="font-family:monospace;">rateParser <span style="color: #080;">=</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/function.html"><span style="color: #0000FF; font-weight: bold;">function</span></a><span style="color: #080;">&#40;</span>id<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/url.html"><span style="color: #0000FF; font-weight: bold;">url</span></a> <span style="color: #080;">=</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/paste.html"><span style="color: #0000FF; font-weight: bold;">paste</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;http://api.douban.com/movie/subject/&quot;</span>, id, 
				<span style="color: #ff0000;">&quot;?apikey={your api key}&quot;</span>, sep <span style="color: #080;">=</span> <span style="color: #ff0000;">''</span><span style="color: #080;">&#41;</span>
	moviePage <span style="color: #080;">=</span> htmlTreeParse<span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/url.html"><span style="color: #0000FF; font-weight: bold;">url</span></a>, useInternal <span style="color: #080;">=</span> TRUE<span style="color: #080;">&#41;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/return.html"><span style="color: #0000FF; font-weight: bold;">return</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/as.numeric.html"><span style="color: #0000FF; font-weight: bold;">as.<span style="">numeric</span></span></a><span style="color: #080;">&#40;</span>xpathApply<span style="color: #080;">&#40;</span>moviePage, 
	path <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;//rating&quot;</span>, xmlGetAttr, <span style="color: #ff0000;">&quot;average&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span></pre></td></tr></table></div><p>读数据时要注意, 即使申请了豆瓣的API key以后也有40次请求/分钟的限制. 我用的是最简单的方法: 把请求嵌入到循环中, 每请求一次后<code>Sys.sleep(1.5)</code>一下, 以保证每分钟请求不会超过40次. 我们可以在shell中开一个<code>tail -f filename</code>来实时监视文件写入情况.</p><h1>3 转</h1><p>有了数据先画图.</p><h2>3.1 散点图</h2><p>先画个散点图(由于是一维变量, 可称为strip plot)热身, 看一下各类评分的分布情况. 由于给出的评分值只精确到小数点后一位, 重复值很多, 先在原始数据上增加随机值把点打散, 同时使用alpha混合让点部分透明, 以争取避免叠加时产生的问题.</p><p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/09/stripplot.png"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/09/stripplot.png" alt="stripplot" title="stripplot" width="504" height="504" class="aligncenter size-full wp-image-921" /></a></p><p>纪录片的绝大部分平均分都集中在7以上, 明显有别于其他Genre. 而8分以上的恐怖片则显得比较稀有. 所以, 在豆瓣看到8分以上的恐怖片, 就收了吧 ... 同时可以发现有一部励志片得分为0(事实上, 评价人数也为0)却能在tag标记人数方面上榜, 是哪部影片如此诡异呢? 此处略去不表 ...</p><p>由于样本量比较大, overplotting的情况比较严重, 散点图的效果实际上非常一般, 能够提取的信息有限.</p><h2>3.2 核密度估计</h2><p>对评分作核密度估计后画图.</p><p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/09/densityplot.png"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/09/densityplot.png" alt="densityplot" title="densityplot" width="504" height="648" class="aligncenter size-full wp-image-922" /></a></p><p>各panel中的评分密度基本上都是单峰, 形状大致相同. 战争片/励志片是如此类似, 纪录片和文艺片也十分相像, 只是纪录片峰值处对应的评分要稍高于文艺片. 所以, 在豆瓣看到很多8-9分的纪录片, 不要惊讶.</p><h2>3.3 箱线图</h2><p>作箱线图.</p><p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/09/bwplot.png"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/09/bwplot.png" alt="bwplot" title="bwplot" width="504" height="504" class="aligncenter size-full wp-image-923" /></a></p><p>可以看到带有文艺/犯罪标签的影片的评分分布最为稳定, 离群点很少, 可能也在一定程度上说明了这类影片的同质化比较严重. 恐怖片的中位数位置的确低于其他类型的影片, 高分也很少.</p><h2>3.4 小提琴图</h2><p>作小提琴图.</p><p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/09/violinplot.png"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/09/violinplot.png" alt="violinplot" title="violinplot" width="504" height="504" class="aligncenter size-full wp-image-924" /></a></p><p>小提琴图综合了箱线图和核密度估计图的特点, 不过在这里的效果不算很理想, 不多说了.</p><h1>4 合</h1><p>最后, 是欢乐的统计检验环节. 由于分布的具体类型未知, 我们也不好随便假设, 所以还是用非参方法检验中位数吧.</p><p>设<br /> u_1: 恐怖片评分的中位数<br /> u_2: 其他某类影片评分的中位数<br /> H_0: 豆瓣用户对恐怖片的打分与其他类无区别 u_1 = u_2<br /> H_1: 豆瓣用户对恐怖片的打分比其他某类偏低 u_1 < u_2</p><p>作两样本Wilcoxon(Mann-Whitney)检验, 该检验需要的唯一假定就是两个总体的分布有类似的形状. 由前述核密度估计图以及小提琴图可知, 各总体分布的形状的确大致相同, 可以认为满足要求.</p><p>结果呢?</p><p>7次检验都拒绝了原假设.</p><p>恐怖片导演的确不好混, 一方面是想要拍出好的恐怖片的确不容易, 而且一不小心就被打上B级/cult的烙印. 知名导演很少会去拍纯粹的恐怖片, 尤其是多年以前的《电锯惊魂》这样的小成本惊悚/恐怖片出现以后, 近年涌现了越来越多的小制作影片和新人导演试水惊悚/恐怖类影片. 另一方面, 是不是人在看了比较精彩的恐怖片以后, 也被吓得倾向于打低分了呢? 不能不说, 这是一个有趣的问题.</p><h1>参考</h1><p>[1] <a href="http://www.douban.com/group/topic/9434945/" target="_blank">为什么恐怖片在豆瓣上的评分普遍很低</a>.<br /> [2] <a href="http://www.douban.com/service/apidoc/reference/" target="_blank">豆瓣API参考手册</a>.<br /> [3] Deepayan Sarkar. Lattice: Multivariate Data Visualization with R. pp. 37-52.<br /> [4] 吴喜之. 统计学: 从数据到结论. pp. 266-269.</p> ]]></content:encoded> <wfw:commentRss>http://www.road2stat.com/cn/statistics/douban_rating.html/feed</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>搜索引擎之人肉学习</title><link>http://www.road2stat.com/cn/statistics/blekko_game.html</link> <comments>http://www.road2stat.com/cn/statistics/blekko_game.html#comments</comments> <pubDate>Sun, 24 Jul 2011 13:58:09 +0000</pubDate> <dc:creator>Xiao Nan</dc:creator> <category><![CDATA[统计之路]]></category> <category><![CDATA[3 engine monte]]></category> <category><![CDATA[Blekko]]></category> <category><![CDATA[人肉学习]]></category> <category><![CDATA[游戏]]></category><guid isPermaLink="false">http://www.road2stat.com/cn/?p=842</guid> <description><![CDATA[夏日炎炎, 多多灌水, 有益身心健康. Blekko的logo好像在前些日子由原来的beta升级为beta^2了, 页面正下方出现了一个名为"3 engine monte"的游戏. 玩法是, 输入"关键词 /Monte", 即可平行显示去格式后的Blekko, Google, Bing三方搜索结果, 用户可以根据经验猜测哪个结果是来自Blekko的, 点选以后即可显示猜测是否正确: 这里我以R为关键词进行搜索, 三个结果虽然都只有一页, 不过各有千秋. Google的结果明显偏重技术, bing的结果很杂, 不太靠谱. 而Blekko的结果的人为控制痕迹则比较明显, 基本上是一些比较权威信息源的首页. 有一种主流评论是, 你会发现Google和Bing的结果中往往会出现spam/内容农场等等无意义内容, 而Blekko的结果则相对干净. 而我想, 这或许会是一个不错的用户行为数据采集方式: 用户有意识作出的选择直接体现了他们更想要的搜索结果, 有了这些选择记录, 理论上可以更有针对性地改进搜索结果, 而宝贵的数据就这么到手了, 思路很好, 应该给Rich Skrenta发朵小红花. 一个不太恰当的比方, 想想整个过程在表面上有点像无监督学习向有监督学习的转化, 我更想将Blekko的做法叫做"人肉学习". 其实有时候, 无监督是迫不得已的无监督, &#8230; <a href="http://www.road2stat.com/cn/statistics/blekko_game.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>夏日炎炎, 多多灌水, 有益身心健康.</p><p><a href="http://blekko.com/" target="_blank">Blekko</a>的logo好像在前些日子由原来的beta升级为beta^2了, 页面正下方出现了一个名为"3 engine monte"的游戏. 玩法是, 输入"关键词 /Monte", 即可平行显示去格式后的Blekko, Google, Bing三方搜索结果, 用户可以根据经验猜测哪个结果是来自Blekko的, 点选以后即可显示猜测是否正确:</p><p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/07/blekko_game.jpg"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/07/blekko_game.jpg" alt="blekko_game" title="blekko_game" width="500" height="318" class="aligncenter size-full wp-image-843" /></a></p><p>这里我以R为关键词进行搜索, 三个结果虽然都只有一页, 不过各有千秋. Google的结果明显偏重技术, bing的结果很杂, 不太靠谱. 而Blekko的结果的人为控制痕迹则比较明显, 基本上是一些比较权威信息源的首页.</p><p><span id="more-842"></span></p><p>有一种主流评论是, 你会发现Google和Bing的结果中往往会出现spam/内容农场等等无意义内容, 而Blekko的结果则相对干净. 而我想, 这或许会是一个不错的用户行为数据采集方式: 用户有意识作出的选择直接体现了他们更想要的搜索结果, 有了这些选择记录, 理论上可以更有针对性地改进搜索结果, 而宝贵的数据就这么到手了, 思路很好, 应该给Rich Skrenta发朵小红花. 一个不太恰当的比方, 想想整个过程在表面上有点像无监督学习向有监督学习的转化, 我更想将Blekko的做法叫做"人肉学习". 其实有时候, 无监督是迫不得已的无监督, 缺因变量的数据, 你真真儿的伤不起.</p><p>为了验证Skrenta大人是不是真的这么想的, 用Live HTTP Headers看了一下, 用户选择结果似乎的确是有跟踪的:</p><p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/07/blekko_capture.png"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/07/blekko_capture.png" alt="blekko_capture" title="blekko_capture" width="490" height="375" class="aligncenter size-full wp-image-844" /></a></p><p>三种点选结果分别指向:<br /> <code><br /> http://blekko.com/a/monteguess?q=R /monte &#038;g=blekko<br /> http://blekko.com/a/monteguess?q=R /monte &#038;g=bing<br /> http://blekko.com/a/monteguess?q=R /monte &#038;g=google<br /> </code></p><p>打开以后一片空白, 感觉上应该是个tracker.</p><p>如果这个游戏的设计目的真是人肉学习, 那么不难让人联想到那个传说中的《最佳路径》的故事. 似乎这故事还入选了我朝某小学语文课本, 不过我用"Gropius Disney"之类的关键词Google了半天也没找到原始出处, 要么这故事是生编硬套的伪作, 要么就是我英文搜索水平太差了. 暂且不论真假, 先贴上来瞧瞧:</p><blockquote><p> 世界建筑大师格罗培斯设计的迪斯尼乐园，经过3年的精心施工，马上就要对外开放了，然而各景点之间的道路该怎样设计还没有具体的方案。施工部打电报给正在法国参加庆典的格罗培斯大师，请他赶快定稿。</p><p>格罗培斯从事建筑研究40多年，攻克过无数个建筑方面的难题，然而建筑学中最微不足道的一点——路径设计却让他大伤脑筋。对迪斯尼乐园各景点之间的道路安排，他已修改了50多次，没有一次是让他满意的。接到催促电报，他心里更加焦躁。巴黎的庆典一结束，他就让司机驾车带他去了地中海海滨。他想清理一下思绪，争取在回国前把方案定下来。</p><p>汽车在法国南部的乡间公路上奔驰，这儿是法国著名的葡萄产区，漫山遍野都是当地农民的葡萄园。一路上他看到许多园主把摘下来的葡萄提到路边，向过往的车辆和行人吆喝，但却很少有停下来的。</p><p>当他们的车子拐入一个小山谷时，发现那儿停着许多车辆。原来这儿是一个无人看管的葡萄园，你只要在路旁的箱子里投入5法郎就可以摘一篮葡萄上路。据说这是一位老太太的葡萄园，她因年迈无力料理而想出这个办法。起初她还担心这种办法是否能卖出葡萄，谁知在这绵延上百里的葡萄产区，总是她的葡萄最先卖完。她这种给人自由，任其选择的做法使大师深受启发，他下车摘了一篮葡萄，就让司机调转车头，立即返回了巴黎。<br /> 回到住地，他马上给施工部拍了封电报：撒下草种，提前开放。</p><p>施工部按要求在乐园撒下草种。没多久，小草长出来了，整个乐园的空地被绿草所覆盖。在迪斯尼乐园提前开放的半年里，草地被踩出许多小道，这些踩出的小道有宽有窄，优雅自然。第二年，格罗培斯让人按这些踩出的痕迹铺设了人行道。</p></blockquote><p>其实我想说, 这故事简直就是技术流心灵鸡汤啊. 要真的不是伪作的话, 那Walter Gropius还真是思无邪.</p> ]]></content:encoded> <wfw:commentRss>http://www.road2stat.com/cn/statistics/blekko_game.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>《Graphics of Large Datasets》 原书第11章</title><link>http://www.road2stat.com/cn/statistics/gold.html</link> <comments>http://www.road2stat.com/cn/statistics/gold.html#comments</comments> <pubDate>Wed, 20 Jul 2011 14:53:06 +0000</pubDate> <dc:creator>Xiao Nan</dc:creator> <category><![CDATA[统计之路]]></category> <category><![CDATA[InfoVis]]></category> <category><![CDATA[可视化]]></category> <category><![CDATA[大型数据集]]></category> <category><![CDATA[竞赛]]></category><guid isPermaLink="false">http://www.road2stat.com/cn/?p=807</guid> <description><![CDATA[这是Springer Statistics and Computing丛书中《Graphics of Large Datasets: Visualizing a Million》一书的第11章. 内容是对InfoVis 2005会议竞赛单元所提供数据集的可视化和分析. 作者之一的Martin Theus也是R的交互式图形包iPlots和R的Java GUI前端JGR的作者. 单独将这章提出来的原因是, 一般相关书籍和资料比较偏重理论, 例证比较零散, 不够系统, 往往缺乏对现实数据集完整的分析. 这样贴近现实而详尽的材料相对难得. 半年前做了一部分, 这两天放假又整理了一下就放上来了. 图形提取自原书电子版, 在内容和版式上尽力保持了原书风貌. 值得一提的是, 竞赛结果中位列1st的两队之一是来自IAState的Heike Hofmann, Hadley Wickham, Dianne Cook, Junjie Sun, Christian Röttger, 而本书的三位作者之一是Heike Hofmann. 本书也是本章的两位作者所在队位居2nd. PDF, &#8230; <a href="http://www.road2stat.com/cn/statistics/gold.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a href="http://www.road2stat.com/cn/wp-content/attachments/2011/07/gold.gif"><img src="http://www.road2stat.com/cn/wp-content/attachments/2011/07/gold.gif" alt="gold" title="gold" width="381" height="124" class="aligncenter size-full wp-image-809" /></a></p><p>这是Springer Statistics and Computing丛书中《Graphics of Large Datasets: Visualizing a Million》一书的第11章. 内容是对InfoVis 2005会议竞赛单元所提供数据集的可视化和分析. 作者之一的Martin Theus也是R的交互式图形包iPlots和R的Java GUI前端JGR的作者.</p><p>单独将这章提出来的原因是, 一般相关书籍和资料比较偏重理论, 例证比较零散, 不够系统, 往往缺乏对现实数据集完整的分析. 这样贴近现实而详尽的材料相对难得.</p><p>半年前做了一部分, 这两天放假又整理了一下就放上来了. 图形提取自原书电子版, 在内容和版式上尽力保持了原书风貌.</p><p>值得一提的是, 竞赛结果中位列1st的两队之一是来自IAState的Heike Hofmann, Hadley Wickham, Dianne Cook, Junjie Sun, Christian Röttger, 而本书的三位作者之一是Heike Hofmann. 本书也是本章的两位作者所在队位居2nd.</p><p><a href='http://www.road2stat.com/cn/wp-content/attachments/2011/07/infovis05.pdf'>PDF, 3.3 MB</a></p> ]]></content:encoded> <wfw:commentRss>http://www.road2stat.com/cn/statistics/gold.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>PKU Vis Summer School</title><link>http://www.road2stat.com/cn/statistics/pku_vis_summer_school.html</link> <comments>http://www.road2stat.com/cn/statistics/pku_vis_summer_school.html#comments</comments> <pubDate>Sun, 22 Aug 2010 16:23:21 +0000</pubDate> <dc:creator>Xiao Nan</dc:creator> <category><![CDATA[统计之路]]></category> <category><![CDATA[PKU]]></category> <category><![CDATA[Summer School]]></category> <category><![CDATA[Vis]]></category><guid isPermaLink="false">http://www.road2stat.com/cn/?p=546</guid> <description><![CDATA[Prof. Michael McGuffin的热心让人感动. 当Michael问我"... You want to visualize something?"而我只能巨汗地回答"Just want to learn the basic things well ..."时, 我体会到以后还真是需要好好学一下计算几何了 .. Gary对大家都很有教益的Color Science .. 内敛的Patrignani的内敛的意式英语 .. 可爱老头Inselberg的极其无敌极其牛x闪闪的平行坐标 .. 周围低调的群牛 .. 都很值得回味. 感谢和我在同在一个group的Zhang, Wang, Chen三位同学, 你们优秀的想法给了我很多启发. 考虑到自己只是打酱油+纯路过的本质, 其他什么的就不多写了. 最后特别感谢高涛同学的友情食宿赞助. Slides 1 - Group3: &#8230; <a href="http://www.road2stat.com/cn/statistics/pku_vis_summer_school.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a href="http://www.road2stat.com/cn/attachments/2010/08/summerschool.png"><img class="aligncenter size-full wp-image-549" title="viz_cran_package_network" src="http://www.road2stat.com/cn/attachments/2010/08/summerschool.png" alt="viz_cran_package_network" width="492" height="459" /></a></p><p>Prof. Michael McGuffin的热心让人感动. 当Michael问我"... You want to visualize something?"而我只能巨汗地回答"Just want to learn the basic things well ..."时, 我体会到以后还真是需要好好学一下计算几何了 .. Gary对大家都很有教益的Color Science .. 内敛的Patrignani的内敛的意式英语 .. 可爱老头Inselberg的极其无敌极其牛x闪闪的平行坐标 .. 周围低调的群牛 .. 都很值得回味. 感谢和我在同在一个group的Zhang, Wang, Chen三位同学, 你们优秀的想法给了我很多启发. <img src='http://www.road2stat.com/cn/wp-includes/images/smilies/icon_smile.gif' alt=':smile:' class='wp-smiley' /> 考虑到自己只是打酱油+纯路过的本质, 其他什么的就不多写了. 最后特别感谢高涛同学的友情食宿赞助. <img src='http://www.road2stat.com/cn/wp-includes/images/smilies/icon_wink.gif' alt=':wink:' class='wp-smiley' /></p><p>Slides 1 - <a href="http://www.road2stat.com/cn/attachments/2010/08/plan.tar.gz">Group3: Plan(s)</a></p><p>Slides 2 - <a href="http://www.road2stat.com/cn/attachments/2010/08/project.tar.gz">Final Presentation: Visualization of CRAN Package Dependency Network</a></p><p>最后的Name Cards偷了谢老大的创意 .. 脸红ing .. <img src='http://www.road2stat.com/cn/wp-includes/images/smilies/icon_redface.gif' alt=':oops:' class='wp-smiley' /></p><p>原来暑假就要这么华丽丽的没了 ...</p> ]]></content:encoded> <wfw:commentRss>http://www.road2stat.com/cn/statistics/pku_vis_summer_school.html/feed</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>正则简单笔记</title><link>http://www.road2stat.com/cn/statistics/a_note_of_regular_expression.html</link> <comments>http://www.road2stat.com/cn/statistics/a_note_of_regular_expression.html#comments</comments> <pubDate>Thu, 27 May 2010 17:50:52 +0000</pubDate> <dc:creator>Xiao Nan</dc:creator> <category><![CDATA[统计之路]]></category> <category><![CDATA[regular expression]]></category> <category><![CDATA[正则表达式]]></category> <category><![CDATA[笔记]]></category><guid isPermaLink="false">http://www.road2stat.com/cn/?p=491</guid> <description><![CDATA[1. 元字符 (Metacharacter) 匹配字符串的开始(位置):  ^ 匹配字符串的开始(不受处理多行选项影响):  A 匹配字符串的结束(位置):  $ 匹配字符串的结束(不受处理多行选项影响):  z 匹配字符串的开始/结束(位置):  b 匹配字符串的结束/行尾(不受处理多行选项影响):  Z 匹配数字/字母/下划线/汉字:  w 匹配(阿拉伯)数字:  d 匹配空白符(空格/全角空格/制表符/换行符):  s 匹配横向制表符:  t 匹配竖向制表符:  v 匹配回车:  r 匹配换行符:  n 匹配换页符:  f 匹配任意字符(除换行符n):  . 前述表达式重复任意次:  * 2. 元字符转义 (查找元字符本身) .  *  &#8230; <a href="http://www.road2stat.com/cn/statistics/a_note_of_regular_expression.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<h4>1. 元字符 (Metacharacter)</h4><p>匹配字符串的开始(位置):  ^</p><p>匹配字符串的开始(不受处理多行选项影响):  A</p><p>匹配字符串的结束(位置):  $</p><p>匹配字符串的结束(不受处理多行选项影响):  z</p><p>匹配字符串的开始/结束(位置):  b</p><p>匹配字符串的结束/行尾(不受处理多行选项影响):  Z</p><p>匹配数字/字母/下划线/汉字:  w</p><p>匹配(阿拉伯)数字:  d</p><p>匹配空白符(空格/全角空格/制表符/换行符):  s</p><p>匹配横向制表符:  t</p><p>匹配竖向制表符:  v</p><p>匹配回车:  r</p><p>匹配换行符:  n</p><p>匹配换页符:  f</p><p>匹配任意字符(除换行符n):  .</p><p>前述表达式重复任意次:  *</p><h4>2. 元字符转义 (查找元字符本身)</h4><p>.  *  \  ^  $  等.</p><h4>3. 字符类 (自定义的元字符):  [ ]</h4><p>e.g. [13579] 匹配1或3或5或7或9中的任意一个数字.</p><h4>4. 限定符 (规定表达式重复次数)</h4><p>重复至少0次:  *</p><p>重复至少1次:  +</p><p>重复0次或1次:  ?</p><p>重复n次:  {n}</p><p>重复n次或更多次:  {n,}</p><p>重复m到n次:  {m,n}</p><p>e.g. d{2,9} 匹配2-9位阿拉伯数字.</p><h4>5. 分枝:  |</h4><p>p.s. 分枝条件按照从左到右的顺序测试. 如果已满足了某个分枝, 则匹配结束. 故使用分枝条件时, 一定要反复斟酌各个条件的书写顺序.</p><h4>6. 反义</h4><p>对于元字符, 把元字符里的字母小写换为大写即表示反义. 对于字符类, [^13579] 匹配除了1或3或5或7或9以外的任意字符. 一个不错的例子:</p><p>&lt;a[^&gt;]+&gt; 匹配用尖括号括起来的以a开头的字符串</p><h4>7. 分组:  ( )</h4><p>和编程写公式时多加括号防止写错有点类似. 不过这里的现实意义强得多, 可以用来写出比较复杂的表达式.</p><h4>8. 贪婪/懒惰</h4><p>在正则表达式中, [最先开始的匹配] 拥有最高优先权. 其次才是默认的贪婪匹配原则. 与之对应的懒惰匹配原则:</p><p>重复0次或1次:  ??</p><p>重复至少1次:  +?</p><p>重复m到n次:  {m,n}?</p><p>重复n次以上:  {n,}?</p><p>重复任意次:  *?</p><h4>9. 零宽断言</h4><p>(1) 零宽度正预测先行断言:  (?=exp)</p><p>断言此位置之后能匹配表达式exp</p><p>e.g. bw+(?=lyb) 匹配以ly结尾的字符串的前面部分.</p><p>(2) 零宽度正回顾后发断言:  (?&lt;=exp)</p><p>断言此位置之前能匹配表达式exp</p><p>e.g. (?&lt;=bpre)w+b 匹配以pre开头的字符串的后面部分.</p><p>(3) 零宽度负预测先行断言:  (?!exp)</p><p>断言此位置之后不能匹配表达式exp</p><p>e.g. b((?!exe)w)+b 匹配不包含连续字符串exe的字符串.</p><p>(4) 零宽度负回顾后发断言:  (?&lt;!exp)</p><p>断言此位置之前不能匹配表达式exp</p><p>e.g. (?&lt;!010)d{8} 匹配前面不是010的8位数字.</p><h4>10. 注释</h4><p>(?#注释内容)</p> ]]></content:encoded> <wfw:commentRss>http://www.road2stat.com/cn/statistics/a_note_of_regular_expression.html/feed</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>青海地震分布与京津地震传言</title><link>http://www.road2stat.com/cn/statistics/yushu_eq_and_rumor.html</link> <comments>http://www.road2stat.com/cn/statistics/yushu_eq_and_rumor.html#comments</comments> <pubDate>Fri, 23 Apr 2010 13:14:18 +0000</pubDate> <dc:creator>Xiao Nan</dc:creator> <category><![CDATA[统计之路]]></category> <category><![CDATA[京津]]></category> <category><![CDATA[传言]]></category> <category><![CDATA[可视化]]></category> <category><![CDATA[因果]]></category> <category><![CDATA[地震]]></category> <category><![CDATA[玉树]]></category> <category><![CDATA[青海]]></category><guid isPermaLink="false">http://www.road2stat.com/cn/?p=445</guid> <description><![CDATA[2010年4月14日, 我国青海省玉树藏族自治州发生了破坏性地震. 用R简单地看了一下2010年2到4月青海地区(含西藏/甘肃等地)的地震分布情况. 童鞋们对比一下2、3月份与4月的分布概况图, 不难辨识出青海省玉树藏族自治州的位置. 4月的数据截至22日, 图中所示的经纬度范围约为: 31°-39°N, 94°-103°E. 灾难无情, 愿那些已在天堂的人们安息. 我一向很崇拜那些做可视化的人们, 至少那么多复杂的图形控制参数是难倒我了. 吾生性迟钝, 只能隐约感觉到, 可视化方法在过去, 现在和未来探索某些尚未发现深层次规律问题时, 都是一个极其重要的方法. 最近有一种说法是, 京津地区将在某某天发生破坏性地震, 据说还是某些位神人日观天象偶然看到了一种特殊的云而得出的结论, 和人教社的初中语文课文中所谓的“看云识天气”颇有几分相似. 我们暂且不说这种说法的来源有多不靠谱, 首先, 且看这种说法的一个重要论据是, 有xx次国内外的破坏性地震之前, 天空中都出现了特殊形状的云. 但是, 这样的论据显然是文不对题的. 实际上, 正确的论据应该指出, 在多少出现了这种云的情况下发生了破坏性地震. 以贝叶斯的观点看, 这两个概率没有确定的关系, 也无法相互替代. 其次, 在我看来, 这种提法在统计中最多只能算是一种假设，即使经过严格的检验, 也不能断定其成立. 而且, &#8230; <a href="http://www.road2stat.com/cn/statistics/yushu_eq_and_rumor.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>2010年4月14日, 我国青海省玉树藏族自治州发生了破坏性地震. 用R简单地看了一下2010年2到4月青海地区(含西藏/甘肃等地)的地震分布情况.</p><div id="attachment_446" class="wp-caption aligncenter" style="width: 475px"><a href="http://www.road2stat.com/cn/attachments/2010/04/EQ_Feb_2010.png"><img class="size-full wp-image-446" title="图1 2010年2月青海地区地震分布" src="http://www.road2stat.com/cn/attachments/2010/04/EQ_Feb_2010.png" alt="图1 2010年2月青海地区地震分布" width="465" height="475" /></a><p class="wp-caption-text">图1 2010年2月青海地区地震分布</p></div><p><span id="more-445"></span></p><div id="attachment_447" class="wp-caption aligncenter" style="width: 475px"><a href="http://www.road2stat.com/cn/attachments/2010/04/EQ_Mar_2010.png"><img class="size-full wp-image-447" title="图2 2010年3月青海地区地震分布" src="http://www.road2stat.com/cn/attachments/2010/04/EQ_Mar_2010.png" alt="图2 2010年3月青海地区地震分布" width="465" height="475" /></a><p class="wp-caption-text">图2 2010年3月青海地区地震分布</p></div><div id="attachment_448" class="wp-caption aligncenter" style="width: 475px"><a href="http://www.road2stat.com/cn/attachments/2010/04/EQ_Apr_2010.png"><img class="size-full wp-image-448" title="图3 2010年4月青海地区地震分布" src="http://www.road2stat.com/cn/attachments/2010/04/EQ_Apr_2010.png" alt="图3 2010年4月青海地区地震分布" width="465" height="475" /></a><p class="wp-caption-text">图3 2010年4月青海地区地震分布</p></div><p>童鞋们对比一下2、3月份与4月的分布概况图, 不难辨识出青海省玉树藏族自治州的位置. 4月的数据截至22日, 图中所示的经纬度范围约为: 31°-39°N, 94°-103°E. 灾难无情, 愿那些已在天堂的人们安息.</p><p>我一向很崇拜那些做可视化的人们, 至少那么多复杂的图形控制参数是难倒我了. 吾生性迟钝, 只能隐约感觉到, 可视化方法在过去, 现在和未来探索某些尚未发现深层次规律问题时, 都是一个极其重要的方法.</p><p>最近有一种说法是, 京津地区将在某某天发生破坏性地震, 据说还是某些位神人日观天象偶然看到了一种特殊的云而得出的结论, 和人教社的初中语文课文中所谓的“看云识天气”颇有几分相似. 我们暂且不说这种说法的来源有多不靠谱, 首先, 且看这种说法的一个重要论据是, 有xx次国内外的破坏性地震之前, 天空中都出现了特殊形状的云. 但是, 这样的论据显然是文不对题的. 实际上, 正确的论据应该指出, 在多少出现了这种云的情况下发生了破坏性地震. 以贝叶斯的观点看, 这两个概率没有确定的关系, 也无法相互替代. 其次, 在我看来, 这种提法在统计中最多只能算是一种假设，即使经过严格的检验, 也不能断定其成立. 而且, 这个假设描述非常模糊, 以致几乎无法加以有效的检验. 再次, 有些人说, 出现了某种云, 导致发生了地震, 实际上是提出了一个因果模型: 出现某某云 → 发生地震. 对初等的数理统计知识有所了解以后, 我们就会知道, 用统计方法建立一个因果模型是一件多么困难的事情, 何况是这种要数据没有, 样本量更小到可以忽略的情况. 我的概率论学得不好, 数理统计也还没入门, 多说无益, 就不再斗胆细究了. 不过, 我所知道的一个情况是, “预言”这件事情其实有点像押宝, 言中了算运气好, 就算没言中, 也只是被人逐渐淡忘而已. 但从道德角度讲, 对于一些缺乏独立思考能力和精神的人来说, 这大抵可以算得上是一种伤害. 关于这类问题一个有趣的例子, 可以参考[3]中对青少年问题的探讨.</p><h3>扩展阅读</h3><p>[1] <a href="http://www.road2stat.com/cn/r_language/a_brief_intro_to_rgooglemaps.html">从实例看RgoogleMaps包的使用</a></p><p>[2] <a href="http://www.road2stat.com/cn/r_language/satellite_map_earthquake_visualization_with_animation.html">《最近一周中国及周边版图地震情况》之卫星地图版与动画实现</a></p><p>[3] 王小波. <a href="http://book.sina.com.cn/nzt/ele/wangxiaobo2/14.shtml" target="_blank">摆脱童稚状态</a>. 读书, 1993, 6.</p> ]]></content:encoded> <wfw:commentRss>http://www.road2stat.com/cn/statistics/yushu_eq_and_rumor.html/feed</wfw:commentRss> <slash:comments>6</slash:comments> </item> </channel> </rss>
