Giter VIP home page Giter VIP logo

naive-bayes's Introduction

Naive Bayes的基本实现以及分布式实现

基于Java实现。

项目内容

项目简介

项目起因

本项目主要实现大规模文本分类,提供快速高效的情感分析框架。

项目框架

simple: 单线程、单机器的Navie Bayes算法的实现。

mapred: 分布式部分包含四个MapReduce作业:

  • 两个训练作业
  • 一个用于将训练模型与测试数据集联接的作业
  • 一个用于分类的作业
  • 一个用于与DB联接的作业

mapred.core: 将训练和预测拆分:

1)训练部分包含4个作业:两个计算类别的先验概率、两个计算词语在类中的条件概率;

2)预测部分包含2个作业:预测数据与模型的联结、预测算法;

web: 提供web服务:

使用训练好的模型,提供在线情感分析服务。

输入数据示例:
    cate1,cate2  测试 数据 集合
    cate2,cate3  测试 数据 集合
    
运行主作业:
    hadoop jar NaiveBayesDriver.jar naiveBayesDistribute -D train=/path/to/training/data -D test=/path/to/test/data -D output=/output/dir [-D reducers=10]

情感分析

主要包含两部分:2类情感分析和8类情感分析,最后制作大规模语料库集合。

2类情感分析

情感类别 分类 描述
正面 positive 期待(except)、高兴(glad)、喜爱(love)、惊讶(amazed)
负面 negative 焦虑(anxious)、悲伤(sad)、生气(angry、憎恨(hate)

8类情感分析

情感类别 分类 描述
期待 except
高兴 glad
喜爱 love
惊讶 amazed
焦虑 anxious
悲伤 sad
生气 angry
憎恨 hate

语料库

最后对10亿条微博内容进行情感分析,制作8类情感语料库。

数据预处理

对以下几类微博数据进行相关测试,分别是:
  1. 原始微博:0
  2. 在1>基础上去掉用户名(@后面的名称)剩下的:1
  3. 在2>基础上去掉表情信息的:2
  4. 在1>基础上去掉转发的内容,以及用户名:3
  5. 在4>基础上去掉表情信息的:4
    例如:

1:支[高兴]持!//@投行新闻:表示服了 //@Andie是肥乔:上下折服。。。[汗] 

2:支[高兴]持!表示服了 上下折服。。。[汗]

3:支持!表示服了 上下折服。。。 

4:支[高兴]持!

5:支持!

测评结果

处理级别 分类精度
0 83.71%
1 85.93%
2 49%
3 76.61%
4 48%

细节数据


0. 验证了35。8w条数据,其中30万条数据验证一致
  正确率在83.71%
 300072/358458, accuracy 83.71
用时:3min不到
开始时间:                 结束时间
Fri Jul 11 17:03:52 CST 2014    Fri Jul 11 17:06:37 CST 2014

1. 第1>类数据 原始微博去掉用户名剩下的
验证了27w 条微博,其中23.5w 条微博分类正确
正确率 85.93%
235082/273586, accuracy 85.93
用时:2 min
开始时间:                 结束时间
Fri Jul 11 15:25:10 CST 2014     Fri Jul 11 15:27:09 CST 2014       

2. 第2>类数据 在1>基础上去掉表情信息的
验证了28.6w 条微博,其中14w 条微博分类正确
正确率 49%
140356/286422, accuracy 49.00
用时:2 min
开始时间:                 结束时间
Fri Jul 11 15:51:22 CST 2014     Fri Jul 11 15:53:32 CST 2014

3. 在1>基础上去掉转发的内容,以及用户名
验证了27w 条微博,其中20.8w 条微博分类正确
正确率 76.61%
208414/272028, accuracy 76.61
用时:2 min
开始时间:                 结束时间
Fri Jul 11 16:32:54 CST 2014     Fri Jul 11 16:34:42 CST 2014

4. 在4>基础上去掉表情信息的
验证了20w条微博,其中10w条微博分类正确
正确率 48%
98683/205198, accuracy 48.09
用时:不到 2min
开始时间:                     结束时间
Fri Jul 11 16:40:53 CST 2014        Fri Jul 11 16:42:37 CST 2014

备注: 结果待补充。

开发人员

WeChat: wgybzb

QQ: 1010437118

E-mail: [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.