algorithm - 蛋糕比较算法

标签 algorithm statistics ranking android-1.5-cupcake

这实际上是关于比较蛋糕。我的 friend 正在举办纸杯蛋糕派对,目的是确定曼哈顿最好的纸杯蛋糕店。实际上,它的野心远不止于此。继续阅读。

有 27 家面包店和 19 人参加(可能有一两个人没有出现)。每个面包店将有 4 个纸杯蛋糕,如果可能的话,包括主食—— Vanilla 、巧克力和红色天鹅绒——并在 4 个中加入通配符口味。有 4 个属性可以用来评价纸杯蛋糕:味道、湿度、外观(漂亮)和整体质量。人们将为他们采样的每个纸杯蛋糕的每个属性提供 5 分制的评级。最后,每个纸杯蛋糕可以切成 4 或 5 block 。

问题是:针对每个属性和每种口味(将“通配符”视为一种口味)得出具有统计意义的面包店排名的程序是什么?具体来说,我们想对面包店进行 8 次排名:对于每种口味,我们希望根据品质对面包店进行排名(品质是属性之一),对于每个属性,我们希望对所有口味的面包店进行排名(即独立于 flavor ) ,即聚合所有口味)。大奖颁给了善良属性排名第一的面包店。

当然,推广这一点会加分。

这将在大约 12 小时后发生,因此如果在此期间没有人回答,我将发布我们最终所做的事情作为答案。

PS:这是关于它的派对后博客文章:http://gracenotesnyc.com/2009/08/05/gracenotes-nycs-cupcake-cagematch-the-sweetest-battle-ever/

最佳答案

这就是我们最终所做的。我在 http://etherpad.com/sugarorgy 做了一个巨大的表格来收集每个人的评分(修订版 25,以防万一它被我添加这个公共(public)链接破坏)然后使用以下 Perl 脚本将数据解析为 CSV 文件:

#!/usr/bin/env perl
# Grabs the cupcake data from etherpad and parses it into a CSV file.

use LWP::Simple qw(get);

$content = get("http://etherpad.com/ep/pad/export/sugarorgy/latest?format=txt");
$content =~ s/^.*BEGIN_MAGIC\s*//s;
$content =~ s/END_MAGIC.*$//s;
$bakery = "none";
for $line (split('\n', $content)) {
  next if $line =~ /sar kri and deb/;
  if ($line =~ s/bakery\s+(\w+)//) { $bakery = $1; }
  $line =~ s/\([^\)]*\)//g; # strip out stuff in parens.
  $line =~ s/^\s+(\w)(\w)/$1 $2/;
  $line =~ s/\-/\-1/g;
  $line =~ s/^\s+//;
  $line =~ s/\s+$//;
  $line =~ s/\s+/\,/g;
  print "$bakery,$line\n"; 
}

然后我在 Mathematica 中做了平均和诸如此类的事情:

data = Import["!~/svn/sugar.pl", "CSV"];

(* return a bakery's list of ratings for the given type of cupcake *)
tratings[bak_, t_] := Select[Drop[First@Select[data, 
                        #[[1]]==bak && #[[2]]==t && #[[3]]=="g" &], 3], #!=-1&]

(* return a bakery's list of ratings for the given cupcake attribute *)
aratings[bak_, a_] := Select[Flatten[Drop[#,3]& /@ 
                        Select[data, #[[1]]==bak && #[[3]]==a&]], #!=-1&]

(* overall rating for a bakery *)
oratings[bak_] := Join @@ (tratings[bak, #] & /@ {"V", "C", "R", "W"})

bakeries = Union@data[[All, 1]]

SortBy[{#, oratings@#, Round[Mean@oratings[#], .01]}& /@ bakeries, -#[[3]]&]

结果在http://etherpad.com/sugarorgy的底部.

关于algorithm - 蛋糕比较算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1215949/

相关文章:

c++ - 将 gsl_ran_hypergeometric_pdf(k, n1, n2, t) 翻译成 boost::math::hypergeometric_distribution

machine-learning - 如何区分结构化数据和非结构化数据?

mysql - MySQL是否维护您正在查询的表的顺序

c++ - 删除元素的算法

string - 包含字符列表的所有固定长度子串(子集的任意 1 个排列)的最短字符串

java - java备用备份轮换算法

algorithm - 基于相邻节点计算节点值的图形算法

python - 如何在numpy中计算超过num_classes - 1 LDA方向?

algorithm - 简单的排名算法

algorithm - 多因子排序算法