对于基于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
最满意答案
尝试这个:
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.random()* 5 + 1)?(Order of operations for Math.floor(Math.random() * 5 + 1)?)[2023-04-07]
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 ...
-
Math.random没有给我一个我正在寻找的范围内的变量?(Math.random not giving me a variable within the range I'm looking for?)[2023-05-24]
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 ...