首页 \ 问答 \ 对于基于Mahout Item的CF,我们的Hadoop集群中的数据太多而机器不够(Too much data and not enough machines in our Hadoop cluster for Mahout Item-based CF)

对于基于Mahout Item的CF,我们的Hadoop集群中的数据太多而机器不够(Too much data and not enough machines in our Hadoop cluster for Mahout Item-based CF)

在工作中,我正在尝试基于Mahout的基于项目的CF包构建基于项目的推荐系统。 这是我们正在处理的问题:

用户数:6,000,000项目数:200,000首选项:10,000,000,000

如果我们的Hadoop集群中有数百台机器,我们可能会在几个小时内完成RecommenderJob。 然而,问题是因为我们是一个小型创业公司,我们的Hadoop集群在这个阶段只有大约10台机器。 理想情况下,我们希望每两天运行一次推荐工作。

为了理解问题的规模,我们在一小部分数据上应用了Mahout的基于项目的CF:

用户数:100,000项目数:80,000首选项:3,000,000

在我们的Hadoop集群上,RecommenderJob所花费的时间约为10分钟。

我的问题是,鉴于我们的硬件限制(短期内不太可能改变),我们可以做些什么来加快Mahout基于物品的CF的速度?


At work I'm trying to build an Item-based recommendation system based on Mahout's Item-based CF package. Here's the problem that what we are dealing with:

Number of users: 6,000,000 Number of items: 200,000 Preferences: 10,000,000,000

If we have hundreds of machines in our Hadoop cluster, we might be able to finish the RecommenderJob within several hours. However, the problem is that because we are a small startup, our Hadoop cluster has only about 10 machines at this stage. Ideally, we would like to run the recommendation job once every couple of days.

In order to appreciate the scale of the problem, we have applied Mahout's Item-based CF on a small subset of the data:

Number of users: 100,000 Number of items: 80,000 Preferences: 3,000,000

Time taken for the RecommenderJob is about 10 minutes on our Hadoop cluster.

My question is, given our hardware limitation(unlikely to change in the short term), what can we do to speed things up with Mahout's Item-based CF?


原文:https://stackoverflow.com/questions/20794327
更新时间:2021-10-30 15:10

最满意答案

尝试这个:

int number = (int)(Math.random()*last);

问题是你在将math.random值乘以之前将其转换为int。 演员阵容具有更高的运算符优先级(有关完整列表,请参阅http://introcs.cs.princeton.edu/java/11precedence/

此外,您的代码永远不会选择列表中的最后一个学生,您不应该-1''last'int。

您还可以考虑使用Random类,即new java.util.Random().nextInt(list.size()); 所以你不必担心演员阵容以及整理的方式。 如果需要多次执行,您甚至可以重用Random实例。


Try this:

int number = (int)(Math.random()*last);

The problem is you're casting the math.random value to an int before multiplying it. The cast has a higher operator precedence (for a complete list, see http://introcs.cs.princeton.edu/java/11precedence/)

Additionally, your code will never pick the last Student in the list, you shouldn't -1 the 'last' int.

You could also consider using the Random class, i.e. new java.util.Random().nextInt(list.size()); so you don't have to worry about casts and how ints get rounded. You can even re-use the Random instance if you need to do it more than once.

相关问答

更多
  • Math.random()将创建一个从0到1的数字(不包括1)。 因此,您的代码将创建一个介于0和i之间的值,获得0的机会较少,并且i与该范围中的其他值进行比较(它只会在0.5或更小的情况下向下舍入为0,并且在'我'-0.5或更多)。 更好的方法是使用 public function getRandom(from:uint, to:uint):uint { return Math.floor(Math.random()*(to-from+1))+from; } (IIRC)。 Math.random( ...
  • 不要使用Math.random。 它依赖于使用AtomicLong的java.util.Random的全局实例。 尽管java.util.Random使用的PRNG算法非常简单 ,但性能主要受原子CAS和相关缓存一致性流量的影响。 对于多线程应用程序(如本示例中 ),这可能特别糟糕,但即使在单线程情况下也会受到惩罚。 ThreadLocalRandom始终优于Math.random。 它不依赖于原子操作,也不会受到争用。 它只更新线程本地状态并使用几个算术和按位运算 。 这是一个JMH基准测试,用于将Mat ...
  • 指数在这里没有意义。 退后:[0,1]上均匀分布的数字小于相同范围内的x,概率为x,因此: function randomHit(modifier) { return Math.random() < modifier; } 测试: function randomHit(modifier) { return Math.random() < modifier; } function probCheck(modifier) { var totalTries = 100; var ...
  • 尝试: Min + (int)(Math.random() * ((Max - Min) + 1)) 。 输出应为1到3之间的数字。填写1表示最小值,3表示最大值。 而已。 数字范围应该是:[1,3]这意味着包括1 AND 3。 这里另一个建议: int number = 1 + (int)(Math.random() * ((3 - 1) + 1)); System.out.println(number); //alternative way: // return number; Try: Mi ...
  • 尝试这个: int number = (int)(Math.random()*last); 问题是你在将math.random值乘以之前将其转换为int。 演员阵容具有更高的运算符优先级(有关完整列表,请参阅http://introcs.cs.princeton.edu/java/11precedence/ ) 此外,您的代码永远不会选择列表中的最后一个学生,您不应该-1''last'int。 您还可以考虑使用Random类,即new java.util.Random().nextInt(list.siz ...
  • 这将返回一个14-16的随机长度的字符串 function getRandomString(min, max) { num= Math.ceil(Math.random()*3)+14; var text=""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" for( var i=0; i < num; i++ ) { ...
  • Math.floor()将在括号内的任何内容上工作,在计算之后。 Math.floor(Math.random() * 5 + 1) 是相同的 var i = Math.random() * 5; i += 1; Math.floor(i); Math.floor() will work on whatever is inside the brackets, after it has been calculated. Math.floor(Math.random() * 5 + 1) is the s ...
  • 你遇到了一个叫做生日问题的问题:尽管有366个可能的生日,但是当你在一个房间里只有26个人时,有些人会有同样的生日的机会比50-50更好。 一般来说,当你的数字接近样本规模的平方根时,可能会发生碰撞(26在366的平方根附近)。 Javascript的Math.random()具有大约52位的随机性。 因此,碰撞应该是可能的,因为您的记录数接近2 ** 26,大约是6000万,这对于数据库来说是相当小的大小。 您应该使用至少有128位(最好是256)的密码安全PRNG来避免冲突。 可能有可用的即用型UUID ...
  • 你可以使用像下面这样的函数来获得一个随机的大写字符: function getRandomUppercaseChar() { var r = Math.floor(Math.random() * 26); return String.fromCharCode(65 + r); } 因此,如您使用双字母前缀指定的那样生成代码: function generateCode() { var prefix = new Array(2).fill().map(() => getRandomU ...
  • return Math.floor(Math.random() * (57 - 48 + 1)) + 48; return Math.floor(Math.random() * (90 - 65 + 1)) + 65; return Math.floor(Math.random() * (122 - 97 + 1)) + 97; 这是为你做的吗? return Math.floor(Math.random() * (57 - 48 + 1)) + 48; return Math.floor(Math.ra ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)