0
を使用してアイテムbetweebの類似度を計算するために、NIは、いくつかのjarファイルのエラーは、エラーアイテムベースの協調フィルタリング・アルゴリズムが、私はこのコードを使用している象使い
Exception in thread "main" java.util.NoSuchElementException
at com.google.common.base.AbstractIterator.next(AbstractIterator.java:75)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.processLine(FileDataModel.java:385)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.processFile(FileDataModel.java:340)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.buildModel(FileDataModel.java:239)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.reload(FileDataModel.java:208)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:194)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:149)
at ItemRecommender.main(ItemRecommender.java:22)
をあります取得しています。..
import java.io.File;
import java.util.List;
import java.io.IOException;
import org.apache.mahout.cf.taste.impl.common.LongPrimitiveIterator;
import org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender;
import org.apache.mahout.cf.taste.impl.similarity.LogLikelihoodSimilarity;
import org.apache.mahout.cf.taste.recommender.RecommendedItem;
import org.apache.mahout.cf.taste.similarity.ItemSimilarity;
public class ItemRecommender {
public static void main(String[] args) {
try{
DataModel dm = new FileDataModel(new File("data/movies.csv"));
ItemSimilarity sim = new LogLikelihoodSimilarity(dm);
GenericItemBasedRecommender recommender = new GenericItemBasedRecommender(dm, sim);
int x=1;
for(LongPrimitiveIterator items = dm.getItemIDs(); items.hasNext();){
long itemId = items.nextLong();
List<RecommendedItem> recommendations = recommender.mostSimilarItems(itemId, 5);
for(RecommendedItem recommendation : recommendations){
System.out.println(itemId + "," + recommendation.getItemID() + "," + recommendation.getValue());
}
x++;
//if(x>10) System.exit(1);
}
}catch(IOException e)
{ System.out.println("There was an error.");
e.printStackTrace();
} catch(TasteException e)
{
System.out.println("There was a taste exception.");
e.printStackTrace();
}
}}