Giter Site home page Giter Site logo

rllll / albert_text_classification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from percent4/albert_text_classification

0.0 0.0 0.0 78.23 MB

利用ALBERT实现文本二分类,判别是否属于政治上的出访类事件,提升模型训练和预测速度。

Shell 0.29% Python 99.71%

albert_text_classification's Introduction

任务介绍:

文本二分类任务。对文档进行分类,判断是否属于政治上的出访类事件。

准备工作

下载requiments.txt中的第三方模块,本项目的Python版本为3.6.9。

数据集介绍:

训练集:280个样本,测试集:60个样本

模型:

1. ALBERT作为特征提取,模型采用最简单的神经网络模型:DNN. 直接运行model_train.py即可。
2. ALBERT作为特征提取,采用LR,NB, SVM等机器学习模型来进行分类,直接运行ml_model_train.py即可。

模型效果:

  1. DNN模型在训练集的acc为0.9857,在测试集上的acc为0.9500,如下图所示:

  1. 在机器学习上的效果如下:
Logistic Regression Model
混淆矩阵 [[33  5]
 [ 2 40]]
正确率: 0.9125
              precision    recall  f1-score   support

           0     0.9429    0.8684    0.9041        38
           1     0.8889    0.9524    0.9195        42

   micro avg     0.9125    0.9125    0.9125        80
   macro avg     0.9159    0.9104    0.9118        80
weighted avg     0.9145    0.9125    0.9122        80

Naive Bayes Model
混淆矩阵 [[37  1]
 [ 1 41]]
正确率: 0.975
              precision    recall  f1-score   support

           0     0.9737    0.9737    0.9737        38
           1     0.9762    0.9762    0.9762        42

   micro avg     0.9750    0.9750    0.9750        80
   macro avg     0.9749    0.9749    0.9749        80
weighted avg     0.9750    0.9750    0.9750        80

SVM Model
混淆矩阵 [[35  3]
 [ 1 41]]
正确率: 0.95
              precision    recall  f1-score   support

           0     0.9722    0.9211    0.9459        38
           1     0.9318    0.9762    0.9535        42

   micro avg     0.9500    0.9500    0.9500        80
   macro avg     0.9520    0.9486    0.9497        80
weighted avg     0.9510    0.9500    0.9499        80
  1. model_predict.py中的预测语句预测全部正确。

HTTP服务

将模型预测写成HTTP服务,用Postman测试预测时间,如下图:

albert_text_classification's People

Contributors

jclian91 avatar rllll avatar

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.