• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RMSRecommenderEvaluator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.mahout.cf.taste.impl.eval.RMSRecommenderEvaluator的典型用法代码示例。如果您正苦于以下问题:Java RMSRecommenderEvaluator类的具体用法?Java RMSRecommenderEvaluator怎么用?Java RMSRecommenderEvaluator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RMSRecommenderEvaluator类属于org.apache.mahout.cf.taste.impl.eval包,在下文中一共展示了RMSRecommenderEvaluator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildEvaluator

import org.apache.mahout.cf.taste.impl.eval.RMSRecommenderEvaluator; //导入依赖的package包/类
public static RecommenderEvaluator buildEvaluator(EVALUATOR type) {
    switch (type) {
        case RMS:
            return new RMSRecommenderEvaluator();
        case AVERAGE_ABSOLUTE_DIFFERENCE:
        default:
            return new AverageAbsoluteDifferenceRecommenderEvaluator();
    }
}
 
开发者ID:Hope6537,项目名称:hope-tactical-equipment,代码行数:10,代码来源:RecommendFactory.java


示例2: analyze

import org.apache.mahout.cf.taste.impl.eval.RMSRecommenderEvaluator; //导入依赖的package包/类
/**
 * <b>[推薦の評価方法]</b><br>
 * cf.)70%のデータを使用してレコメンダーを生成→30%のデータを使用して評価
 * @param dataModel
 * @throws TasteException
 */
@Override
public void analyze() throws TasteException {

    super.i("◆ EVAL ======= Start ======");
    super.i("◆ -------------------------");

    final int size = super.dto.size;
    final Map<EvalName, EvaluationVO> evalMap = super.dto.evalMap;

    RandomUtils.useTestSeed();

    /* 実際の評価値と推定値の誤差 */
    // 絶対値を求める=意味平均誤差(mean average error)
    RecommenderEvaluator maeEval = new AverageAbsoluteDifferenceRecommenderEvaluator();
    // 自乗を足し合わせ平方根を取ったRMS(root mean squared)
    RecommenderEvaluator rmsEval = new RMSRecommenderEvaluator();

    RecommenderBuilder builder = new RecommenderBuilder() {

        @Override
        public Recommender buildRecommender(DataModel dataModel) throws TasteException {
            UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);
            UserNeighborhood neighborhood = new NearestNUserNeighborhood(size, similarity, dataModel);
            return new GenericUserBasedRecommender(dataModel, neighborhood, similarity);
        }
    };

    // evaluate(RecommenderBuilder, DataModelBuilder, DataModel, 学習用データの割合, 検証用データの割合)
    EvaluationVO mae = evalMap.get(EvalName.MAE);
    EvaluationVO rms = evalMap.get(EvalName.RMS);
    double maeScore = maeEval.evaluate(builder, null, super.dataModel, mae.trainingPercentage, mae.evaluationPercentage);
    double rmsScore = rmsEval.evaluate(builder, null, super.dataModel, rms.trainingPercentage, rms.evaluationPercentage);

    super.i("◆ " + EvalName.MAE.name + " : " + maeScore);
    super.i("◆ " + EvalName.RMS.name + " : " + rmsScore);
    super.i("◆ -------------------------");
    super.iln("◆ EVAL ======= END ======");
}
 
开发者ID:pollseed,项目名称:machine-learning,代码行数:45,代码来源:Evaluator.java


示例3: runALSSVDRecommender

import org.apache.mahout.cf.taste.impl.eval.RMSRecommenderEvaluator; //导入依赖的package包/类
private static void runALSSVDRecommender(DataModel dataModel)
		throws TasteException {

	System.out.println("Start of Running an ALS SVD Recommendation");
	RecommenderBuilder recommenderBuilder = EEGVideoRecommender.buildSVDRecommender();

	SVDRecommender recommender = (SVDRecommender) recommenderBuilder
			.buildRecommender(dataModel);

	RunningAverage runningAverage = new FullRunningAverage();

	LongPrimitiveIterator userIDs = dataModel.getUserIDs();

	while (userIDs.hasNext()) {
		long userID = userIDs.nextLong();

		for (Preference pref : dataModel.getPreferencesFromUser(userID)) {

			double ratingValue = pref.getValue();
			double preferenceEstimate = recommender.estimatePreference(
					userID, pref.getItemID());

			System.out.println(userID + "," + pref.getItemID() + ","
					+ ratingValue);
			double errorValue = ratingValue - preferenceEstimate;
			runningAverage.addDatum(errorValue * errorValue);
		}
	}

	double rmse = Math.sqrt(runningAverage.getAverage());
	System.out.println(rmse);

	// Recommender Evaluation -- Average Absolute Difference Evaluator
	RecommenderEvaluator absoluteDifferenceEvaluator = new AverageAbsoluteDifferenceRecommenderEvaluator();
	double score = absoluteDifferenceEvaluator.evaluate(recommenderBuilder,
			null, dataModel, 0.9, 1.0);
	System.out.println("ALS-based Recommender Average Score is: " + score);

	// Recommender Evaluation -- RMS Evaluator
	RecommenderEvaluator rmsEvaluator = new RMSRecommenderEvaluator();
	double rmsscore = rmsEvaluator.evaluate(recommenderBuilder, null,
			dataModel, 0.9, 1.0);
	System.out.println("ALS-based Recommender RMS Score is:" + rmsscore);

	// Recommender Evaluation -- IRStats Evaluator
	RecommenderIRStatsEvaluator irStatsEvaluator = new GenericRecommenderIRStatsEvaluator();
	IRStatistics stats = irStatsEvaluator.evaluate(recommenderBuilder,
			null, dataModel, null, 2,
			GenericRecommenderIRStatsEvaluator.CHOOSE_THRESHOLD, 1.0);

	System.out.println("Precision Valus is : " + stats.getPrecision());
	System.out.println("Recall Value is : " + stats.getRecall());

	System.out.println("End of Running an ALS SVD Recommendation");
}
 
开发者ID:melrefaey,项目名称:EEGoVid,代码行数:56,代码来源:EEGVideoEvaluator.java


示例4: runUserBasedRecommender

import org.apache.mahout.cf.taste.impl.eval.RMSRecommenderEvaluator; //导入依赖的package包/类
private static void runUserBasedRecommender(DataModel dataModel)
		throws TasteException {

	UserSimilarity userSimilarity = RecommParametersMeasures
			.getLogLikelihoodSimilarity(dataModel);

	UserNeighborhood neighborhood = RecommParametersMeasures.getThreshold(
			dataModel, userSimilarity, 0.1);

	RecommenderBuilder recommenderBuilder = EEGVideoRecommender.userBuilder(
			userSimilarity, neighborhood);

	for (LongPrimitiveIterator users = dataModel.getUserIDs(); users
			.hasNext();) {
		long userId = users.nextLong();

		List<RecommendedItem> recommendations = recommenderBuilder
				.buildRecommender(dataModel).recommend(userId, 1);

		for (RecommendedItem recommendation : recommendations) {
			System.out.println(userId + "," + recommendation.getItemID()
					+ "," + recommendation.getValue());
		}

	}

	// Recommender Evaluation -- Average Absolute Difference Evaluator
	RecommenderEvaluator absoluteDifferenceEvaluator = new AverageAbsoluteDifferenceRecommenderEvaluator();
	double score = absoluteDifferenceEvaluator.evaluate(recommenderBuilder,
			null, dataModel, 0.9, 1.0);
	System.out.println("User-based Recommender Average Score is: " + score);

	// Recommender Evaluation -- RMS Evaluator
	RecommenderEvaluator rmsEvaluator = new RMSRecommenderEvaluator();
	double rmsscore = rmsEvaluator.evaluate(recommenderBuilder, null,
			dataModel, 0.7, 0.3);
	System.out.println("User-based Recommende RMS Score is:" + rmsscore);

	// Recommender Evaluation -- IRStats Evaluator
	RecommenderIRStatsEvaluator irStatsEvaluator = new GenericRecommenderIRStatsEvaluator();
	IRStatistics stats = irStatsEvaluator.evaluate(recommenderBuilder,
			null, dataModel, null, 1,
			GenericRecommenderIRStatsEvaluator.CHOOSE_THRESHOLD, 1);
	System.out.println("Precision Valus is : " + stats.getPrecision());
	System.out.println("Recall Value is : " + stats.getRecall());

}
 
开发者ID:melrefaey,项目名称:EEGoVid,代码行数:48,代码来源:EEGVideoEvaluator.java


示例5: runItemBasedRecommender

import org.apache.mahout.cf.taste.impl.eval.RMSRecommenderEvaluator; //导入依赖的package包/类
private static void runItemBasedRecommender(DataModel dataModel)
		throws TasteException {

	TanimotoCoefficientSimilarity tanimotoSimilarity = new TanimotoCoefficientSimilarity(
			dataModel);

	GenericItemBasedRecommender recommender = new GenericItemBasedRecommender(
			dataModel, tanimotoSimilarity);

	RecommenderBuilder recommenderBuilder = EEGVideoRecommender
			.itemBuilder(tanimotoSimilarity);

	for (LongPrimitiveIterator items = dataModel.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());
		}

	}

	// Recommender Evaluation -- Average Absolute Difference Evaluator
	RecommenderEvaluator absoluteDifferenceEvaluator = new AverageAbsoluteDifferenceRecommenderEvaluator();
	double score = absoluteDifferenceEvaluator.evaluate(recommenderBuilder,
			null, dataModel, 0.7, 0.3);
	System.out.println("Item-based Recommender Average Score is: " + score);

	// Recommender Evaluation -- RMS Evaluator
	RecommenderEvaluator rmsEvaluator = new RMSRecommenderEvaluator();
	double rmsscore = rmsEvaluator.evaluate(recommenderBuilder, null,
			dataModel, 0.7, 0.3);
	System.out.println("Item-based Recommende RMS Score is:" + rmsscore);

	// Recommender Evaluation -- IRStats Evaluator
	RecommenderIRStatsEvaluator irStatsEvaluator = new GenericRecommenderIRStatsEvaluator();
	IRStatistics stats = irStatsEvaluator.evaluate(recommenderBuilder,
			null, dataModel, null, 1,
			GenericRecommenderIRStatsEvaluator.CHOOSE_THRESHOLD, 1);
	System.out.println("Precision Valus is : " + stats.getPrecision());
	System.out.println("Recall Value is : " + stats.getRecall());

}
 
开发者ID:melrefaey,项目名称:EEGoVid,代码行数:47,代码来源:EEGVideoEvaluator.java


示例6: runUserRecommender

import org.apache.mahout.cf.taste.impl.eval.RMSRecommenderEvaluator; //导入依赖的package包/类
/****************************************** Running Demo for User-based Recommender ******************************************/
private static void runUserRecommender(DataModel dataModel, int n,
		double threshold, double training, double evaluation, int atValue,
		String similarity) throws TasteException {

	System.out.println("Start of Running a User-based Recommender, with:"
			+ similarity + " Similarity and training % = " + training
			+ " and evaluation % = " + evaluation);

	UserSimilarity userSimilarity = null;
	UserNeighborhood neighborhood;

	if (similarity.equals("pearson")) {
		userSimilarity = RecommParametersMeasures
				.getPearsonCorrelation(dataModel);

	} else if (similarity.equals("likelyhood")) {
		userSimilarity = RecommParametersMeasures
				.getLogLikelihoodSimilarity(dataModel);

	} else if (similarity.equals("tanimoto")) {
		userSimilarity = RecommParametersMeasures
				.getTanimotoCoefficientSimilarity(dataModel);
	} else if (similarity.equals("cityblock")) {
		userSimilarity = RecommParametersMeasures
				.getCityBlockSimilarity(dataModel);

	} else if (similarity.equals("ecludian")) {
		userSimilarity = RecommParametersMeasures
				.getEuclideanDistance(dataModel);
	} else if (similarity.equals("uncenteredcosine")) {
		userSimilarity = RecommParametersMeasures.getUncenteredCosine(dataModel);
	}

	if (n > 0) {
		System.out.println("N Size = " + n);
		neighborhood = RecommParametersMeasures.getNearestN(dataModel,
				userSimilarity, n);
	} else {
		System.out.println("Threshold value = " + threshold);

		neighborhood = RecommParametersMeasures.getThreshold(dataModel,
				userSimilarity, threshold);
	}

	RecommenderBuilder recommenderBuilder = EEGVideoRecommender.userBuilder(
			userSimilarity, neighborhood);
	recommenderBuilder.buildRecommender(dataModel).recommend(26, 1);

	// Recommender Evaluation -- Average Absolute Difference Evaluator
	RecommenderEvaluator absoluteDifferenceEvaluator = new AverageAbsoluteDifferenceRecommenderEvaluator();
	double score = absoluteDifferenceEvaluator.evaluate(recommenderBuilder,
			null, dataModel, training, evaluation);
	System.out.println("The Average Score for this recommender is: "
			+ score);

	// Recommender Evaluation -- RMS Evaluator
	RecommenderEvaluator rmsEvaluator = new RMSRecommenderEvaluator();
	double rmsscore = rmsEvaluator.evaluate(recommenderBuilder, null,
			dataModel, training, evaluation);
	System.out.println("The RMS Score for Pearson and threshold is:"
			+ rmsscore);

	// Recommender Evaluation -- IRStats Evaluator
	RecommenderIRStatsEvaluator irStatsEvaluator = new GenericRecommenderIRStatsEvaluator();
	IRStatistics stats = irStatsEvaluator
			.evaluate(recommenderBuilder, null, dataModel, null, 1,
					GenericRecommenderIRStatsEvaluator.CHOOSE_THRESHOLD,
					evaluation);
	System.out.println("The Precision Valus is : " + stats.getPrecision());
	System.out.println("The Recall Value is : " + stats.getRecall());
	System.out.println("End of Run of user based recommender");
}
 
开发者ID:melrefaey,项目名称:EEGoVid,代码行数:74,代码来源:EEGVideoEvaluator.java



注:本文中的org.apache.mahout.cf.taste.impl.eval.RMSRecommenderEvaluator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GotoRelatedProvider类代码示例发布时间:2022-05-23
下一篇:
Java INVOKEVIRTUAL类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap