Oi,
Assim como postou o usuário Luan há algumas semanas atrás, estou pegando uma saída estranha ao executar o meu Avaliador.java.
Minha saída:
[main] 17:33:30 INFO org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:185)-Creating FileDataModel for file dados.csv
[main] 17:33:30 INFO org.apache.mahout.cf.taste.impl.model.file.FileDataModel.processFile(FileDataModel.java:357)-Reading file info...
[main] 17:33:30 INFO org.apache.mahout.cf.taste.impl.model.file.FileDataModel.processFile(FileDataModel.java:368)-Read lines: 32
[main] 17:33:30 INFO org.apache.mahout.cf.taste.impl.model.GenericDataModel.<init>(GenericDataModel.java:113)-Processed 4 users
[main] 17:33:30 INFO org.apache.mahout.cf.taste.impl.eval.AbstractDifferenceRecommenderEvaluator.evaluate(AbstractDifferenceRecommenderEvaluator.java:105)-Beginning evaluation using 0.9 of FileDataModel[dataFile:/home/lamps/eclipse-workspace/recomendador/dados.csv]
[main] 17:33:30 INFO org.apache.mahout.cf.taste.impl.model.GenericDataModel.<init>(GenericDataModel.java:113)-Processed 1 users
[main] 17:33:30 INFO org.apache.mahout.cf.taste.impl.eval.AbstractDifferenceRecommenderEvaluator.getEvaluation(AbstractDifferenceRecommenderEvaluator.java:181)-Beginning evaluation of 1 users
[main] 17:33:30 INFO org.apache.mahout.cf.taste.impl.eval.AbstractDifferenceRecommenderEvaluator.execute(AbstractDifferenceRecommenderEvaluator.java:194)-Starting timing of 1 tasks in 4 threads
[pool-1-thread-1] 17:33:30 INFO org.apache.mahout.cf.taste.impl.eval.StatsCallable.call(StatsCallable.java:55)-Average time per recommendation: 1ms
[pool-1-thread-1] 17:33:30 INFO org.apache.mahout.cf.taste.impl.eval.StatsCallable.call(StatsCallable.java:58)-Approximate memory used: 21MB / 126MB
[pool-1-thread-1] 17:33:30 INFO org.apache.mahout.cf.taste.impl.eval.StatsCallable.call(StatsCallable.java:59)-Unable to recommend in 1 cases
[main] 17:33:30 INFO org.apache.mahout.cf.taste.impl.eval.AbstractDifferenceRecommenderEvaluator.evaluate(AbstractDifferenceRecommenderEvaluator.java:127)-Evaluation result: NaN
NaN
Meu Avaliador.java:
package xyz.cajueiro.recomendador;
import java.io.File;
import java.io.IOException;
import org.apache.mahout.cf.taste.common.TasteException;
import org.apache.mahout.cf.taste.eval.RecommenderBuilder;
import org.apache.mahout.cf.taste.impl.eval.AverageAbsoluteDifferenceRecommenderEvaluator;
import org.apache.mahout.cf.taste.impl.model.file.FileDataModel;
import org.apache.mahout.cf.taste.model.DataModel;
public class Avaliador {
public static void main(String[] args) throws IOException, TasteException {
File file = new File("dados.csv");
DataModel model = new FileDataModel(file);
AverageAbsoluteDifferenceRecommenderEvaluator evaluator = new AverageAbsoluteDifferenceRecommenderEvaluator();
RecommenderBuilder recommenderBuilder = new RecomendadorDeProdutosBuilder();
double erro = evaluator.evaluate(recommenderBuilder, null, model, 0.9, 0.1);
System.out.println(erro);
}
}
E meu RecomendadorDeProdutosBuilder.java:
package xyz.cajueiro.recomendador;
import org.apache.mahout.cf.taste.common.TasteException;
import org.apache.mahout.cf.taste.eval.RecommenderBuilder;
import org.apache.mahout.cf.taste.impl.neighborhood.ThresholdUserNeighborhood;
import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender;
import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity;
import org.apache.mahout.cf.taste.model.DataModel;
import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood;
import org.apache.mahout.cf.taste.recommender.Recommender;
import org.apache.mahout.cf.taste.recommender.UserBasedRecommender;
import org.apache.mahout.cf.taste.similarity.UserSimilarity;
public class RecomendadorDeProdutosBuilder implements RecommenderBuilder {
public Recommender buildRecommender(DataModel dataModel) throws TasteException {
UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
UserNeighborhood hood = new ThresholdUserNeighborhood(0.1, similarity, dataModel);
UserBasedRecommender genericUserBasedRecommender = new GenericUserBasedRecommender(dataModel, hood, similarity);
return genericUserBasedRecommender;
}
}
Onde estou errando?