Olá, a linha de comando UserSimilarity similarity = new PearsonCorrelationSimilarity(model); está exibindo um erro. Pede para remover o argumento PEarson OU Add cast similarity e mesmo assim remover o argumento PEarson depois OU mudar o tipo similarity para Pearson
Segue meu código completo:
package br.com.alura.recomendador;
import java.io.File; import java.io.IOException; import java.util.List;
import org.apache.mahout.cf.taste.common.TasteException; import org.apache.mahout.cf.taste.impl.model.file.FileDataModel; import org.apache.mahout.cf.taste.impl.neighborhood.ThresholdUserNeighborhood; import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender; import org.apache.mahout.cf.taste.model.DataModel; import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood; import org.apache.mahout.cf.taste.recommender.RecommendedItem; import org.apache.mahout.cf.taste.recommender.UserBasedRecommender; import org.apache.mahout.cf.taste.similarity.UserSimilarity; import >org.apache.mahout.math.hadoop.similarity.cooccurrence.measures.PearsonCorrelationSimilarity;
public class RecomendaProdutos { public static void main(String[] args) throws IOException, TasteException { File file = new File("dados.csv"); DataModel model = new FileDataModel(file);
UserSimilarity similarity = new PearsonCorrelationSimilarity(model);
UserNeighborhood neighborhood = new ThresholdUserNeighborhood(0.1, similarity, model);
UserBasedRecommender recommender = new GenericUserBasedRecommender(model, neighborhood, similarity);
List<RecommendedItem> recommendations = recommender.recommend(2,3);
for (RecommendedItem recommendation : recommendations) {
System.out.println(recommendation);
}
}
}