资源简介
this is the recommendation system implement about the Latent Factor Model(Matrix Factorization)-SVD++ model.
代码片段和文件信息
package org.apache.mahout.cf.taste.hadoop.svd;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License Version 2.0
* (the “License“); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing software
* distributed under the License is distributed on an “AS IS“ BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.IOException;
import java.util.Iterator;
import org.apache.hadoop.io.FloatWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
import org.apache.mahout.math.Vector;
import org.apache.mahout.math.VectorWritable;
public class AverageUserRatingMapper extends
Mapper {
public void map(LongWritable userID VectorWritable userVector
OutputCollector output Reporter reporter)
throws IOException {
//initialise variables
float sum = 0;
int count = 0;
//iterate through user vector
Iterator userVectorIterator = userVector.get().iterateNonZero();
while (userVectorIterator.hasNext()) {
//add up all non-zero user prefs
sum += userVectorIterator.next().index();
//count how many prefs there are
count++;
}
//calculate average user pref
float avgUserPref = sum / count;
//output key = userID value = average user pref
output.collect(userID new FloatWritable(avgUserPref));
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2417 2010-09-25 02:20 svd java\svd\pom.xm
文件 2086 2010-08-09 09:38 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd\AverageUserRatingMapper.java
文件 1941 2010-08-09 09:38 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd\AvgItemPrefMapper.java
文件 1914 2010-08-09 09:38 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd\AvgItemPrefReducer.java
文件 2380 2010-08-25 21:43 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd\CardinalityCorrectionMapper.java
文件 5747 2010-09-29 18:54 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd\DistributedSVDItemRecommenderJob.java
文件 8731 2010-09-29 18:26 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd\DistributedSVDRecommenderJob.java
文件 1541 2010-09-29 18:54 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd\SVDItemItemSimilarityJob.java
文件 2644 2010-09-29 18:27 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd\SVDItemItemSimilarityJobMapper.java
文件 1683 2010-09-29 18:27 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd\SVDItemItemSimilarityJobReducer.java
文件 1736 2010-09-29 18:54 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd\SVDItemRecommenderReducer.java
文件 3547 2010-09-29 18:24 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd\SVDPredictionJob.java
文件 2995 2010-09-29 18:26 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd\SVDRecommenderMapper.java
文件 8172 2010-09-29 18:54 svd java\svd\src\test\java\org\apache\mahout\cf\taste\hadoop\svd\SVDItemItemSimilarityJobMapperTest.java
文件 3266 2010-09-29 18:54 svd java\svd\src\test\java\org\apache\mahout\cf\taste\hadoop\svd\SVDItemItemSimilarityJobReducerTest.java
目录 0 2010-09-29 18:54 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop\svd
目录 0 2010-09-29 18:56 svd java\svd\src\test\java\org\apache\mahout\cf\taste\hadoop\svd
目录 0 2010-08-11 05:35 svd java\svd\src\main\java\org\apache\mahout\cf\taste\hadoop
目录 0 2010-08-09 09:36 svd java\svd\src\test\java\org\apache\mahout\cf\taste\hadoop
目录 0 2010-08-09 09:36 svd java\svd\src\main\java\org\apache\mahout\cf\taste
目录 0 2010-08-09 09:36 svd java\svd\src\test\java\org\apache\mahout\cf\taste
目录 0 2010-08-09 09:36 svd java\svd\src\main\java\org\apache\mahout\cf
目录 0 2010-08-09 09:36 svd java\svd\src\test\java\org\apache\mahout\cf
目录 0 2010-08-09 09:36 svd java\svd\src\main\java\org\apache\mahout
目录 0 2010-08-09 09:36 svd java\svd\src\test\java\org\apache\mahout
目录 0 2010-08-09 09:36 svd java\svd\src\main\java\org\apache
目录 0 2010-08-09 09:36 svd java\svd\src\test\java\org\apache
目录 0 2010-08-09 09:36 svd java\svd\src\main\java\org
目录 0 2010-08-09 09:36 svd java\svd\src\test\java\org
目录 0 2010-09-29 18:55 svd java\svd\src\main\java
............此处省略9个文件信息
- 上一篇:JAVA计算器268139
- 下一篇:JavaToExe,jar转exe
评论
共有 条评论