贝叶斯算法 mapreduce实现

该博客介绍了一个使用Hadoop MapReduce实现贝叶斯算法的Java程序。通过BayesMapper和BayesReducer类,分别处理特征概率的计算和类别条件概率的统计。最终输出各个特征在不同类别下的概率。
摘要由CSDN通过智能技术生成
/**
 * 找到抽样用户的特征,得到每个特征的概率
 * 输入:属性1   属性2   属性3   属性4    类别
 * 命令:hadoop jar recommend_cf.jar com.funshion.machine.bayes.Bayes2 /dw/logs/user/xincl/bayes.txt /dw/logs/recommend/result/machine/Bayes2
 * 输出:
 * @author clxin
 * 
 */

public class Bayes2 extends Configured implements Tool {

    // 输出 : mac media
    public static class BayesMapper extends MapReduceBase implements
            Mapper<LongWritable, Text, StringSecondSortAsce, Text> {
        StringSecondSortAsce tKey = new StringSecondSortAsce();
        Text tValue = new Text();

        @Override
        public void map(LongWritable key, Text value,
                OutputCollector<StringSecondSortAsce, Text> output,
                Reporter report) throws IOException {
            String [] strArr = value.toString().split("
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值