当前位置:   article > 正文

Python新闻等文本情感分析实战【源码分享】_文本分析实战代码

文本分析实战代码

1、注:源码放置文末

1.1 环境配置要求:https://blog.csdn.net/qq_42279468/article/details/124987801

2、展示效果:https://www.bilibili.com/video/BV1bP411f7iv/

3、代码

  本项目通过textcnn卷积神经网络实现对文本情感分析识别,由python 3.6.5+Pytorch训练所得。
  • 1

在这里插入图片描述

3.1 数据集展示

在这里插入图片描述

3.2 模型训练过程

Training and evaluating...
Epoch: 1
Iter:      0, Train Loss:    1.4, Train Acc:  10.94%, Val Loss:    1.4, Val Acc:  13.82%, Time: 0:00:02 *
Iter:    100, Train Loss:    0.8, Train Acc:  70.31%, Val Loss:   0.74, Val Acc:  73.88%, Time: 0:00:33 *
Iter:    200, Train Loss:   0.68, Train Acc:  71.88%, Val Loss:   0.71, Val Acc:  73.88%, Time: 0:01:05 
Iter:    300, Train Loss:   0.68, Train Acc:  75.00%, Val Loss:   0.66, Val Acc:  74.54%, Time: 0:01:37 *
Iter:    400, Train Loss:   0.59, Train Acc:  79.69%, Val Loss:   0.62, Val Acc:  74.97%, Time: 0:02:06 *
Iter:    500, Train Loss:   0.56, Train Acc:  79.69%, Val Loss:    0.6, Val Acc:  76.71%, Time: 0:02:37 *
Iter:    600, Train Loss:   0.64, Train Acc:  78.12%, Val Loss:   0.62, Val Acc:  75.84%, Time: 0:03:08 
Iter:    700, Train Loss:   0.53, Train Acc:  79.69%, Val Loss:   0.57, Val Acc:  79.00%, Time: 0:03:39 *
Iter:    800, Train Loss:   0.67, Train Acc:  76.56%, Val Loss:   0.56, Val Acc:  78.56%, Time: 0:04:08 
Iter:    900, Train Loss:   0.71, Train Acc:  65.62%, Val Loss:   0.54, Val Acc:  78.24%, Time: 0:04:39 
Iter:   1000, Train Loss:   0.64, Train Acc:  68.75%, Val Loss:   0.52, Val Acc:  79.43%, Time: 0:05:10 *
Epoch: 2
Iter:   1100, Train Loss:   0.53, Train Acc:  82.81%, Val Loss:   0.51, Val Acc:  80.74%, Time: 0:05:41 *
Iter:   1200, Train Loss:   0.61, Train Acc:  79.69%, Val Loss:   0.49, Val Acc:  81.94%, Time: 0:06:12 *
Iter:   1300, Train Loss:    0.5, Train Acc:  81.25%, Val Loss:   0.48, Val Acc:  80.85%, Time: 0:06:43 
Iter:   1400, Train Loss:   0.42, Train Acc:  81.25%, Val Loss:   0.46, Val Acc:  82.15%, Time: 0:07:14 *
Iter:   1500, Train Loss:   0.49, Train Acc:  78.12%, Val Loss:   0.46, Val Acc:  81.50%, Time: 0:07:45 
Iter:   1600, Train Loss:   0.43, Train Acc:  81.25%, Val Loss:   0.42, Val Acc:  83.57%, Time: 0:08:16 *
Iter:   1700, Train Loss:   0.42, Train Acc:  84.38%, Val Loss:   0.43, Val Acc:  84.98%, Time: 0:08:47 *
Iter:   1800, Train Loss:   0.37, Train Acc:  84.38%, Val Loss:   0.42, Val Acc:  83.13%, Time: 0:09:18 
Iter:   1900, Train Loss:   0.52, Train Acc:  81.25%, Val Loss:   0.41, Val Acc:  85.20%, Time: 0:09:49 *
Iter:   2000, Train Loss:   0.83, Train Acc:  62.50%, Val Loss:   0.42, Val Acc:  82.26%, Time: 0:10:20 
Iter:   2100, Train Loss:   0.55, Train Acc:  76.56%, Val Loss:    0.4, Val Acc:  86.72%, Time: 0:10:52 *
Epoch: 3
Iter:   2200, Train Loss:    0.4, Train Acc:  84.38%, Val Loss:   0.37, Val Acc:  85.64%, Time: 0:11:22 
Iter:   2300, Train Loss:    0.4, Train Acc:  85.94%, Val Loss:   0.35, Val Acc:  85.09%, Time: 0:11:53 
Iter:   2400, Train Loss:   0.36, Train Acc:  84.38%, Val Loss:   0.33, Val Acc:  88.47%, Time: 0:12:24 *
Iter:   2500, Train Loss:    0.4, Train Acc:  82.81%, Val Loss:   0.36, Val Acc:  86.40%, Time: 0:12:53 
Iter:   2600, Train Loss:   0.43, Train Acc:  81.25%, Val Loss:   0.32, Val Acc:  88.57%, Time: 0:13:24 *
Iter:   2700, Train Loss:    0.4, Train Acc:  82.81%, Val Loss:   0.32, Val Acc:  88.47%, Time: 0:13:56 
Iter:   2800, Train Loss:   0.28, Train Acc:  90.62%, Val Loss:    0.3, Val Acc:  89.12%, Time: 0:14:27 *
Iter:   2900, Train Loss:   0.23, Train Acc:  93.75%, Val Loss:   0.29, Val Acc:  90.10%, Time: 0:14:58 *
Iter:   3000, Train Loss:   0.34, Train Acc:  82.81%, Val Loss:   0.31, Val Acc:  87.92%, Time: 0:15:29 
Iter:   3100, Train Loss:   0.25, Train Acc:  92.19%, Val Loss:   0.29, Val Acc:  90.86%, Time: 0:16:00 *
Iter:   3200, Train Loss:   0.35, Train Acc:  87.50%, Val Loss:   0.26, Val Acc:  90.97%, Time: 0:16:31 *
Epoch: 4
Iter:   3300, Train Loss:   0.26, Train Acc:  92.19%, Val Loss:   0.23, Val Acc:  92.06%, Time: 0:17:02 *
Iter:   3400, Train Loss:   0.32, Train Acc:  89.06%, Val Loss:   0.23, Val Acc:  92.17%, Time: 0:17:33 *
Iter:   3500, Train Loss:   0.22, Train Acc:  92.19%, Val Loss:   0.23, Val Acc:  91.62%, Time: 0:18:04 
Iter:   3600, Train Loss:   0.27, Train Acc:  90.62%, Val Loss:   0.22, Val Acc:  92.27%, Time: 0:18:36 *
Iter:   3700, Train Loss:   0.26, Train Acc:  93.75%, Val Loss:   0.26, Val Acc:  90.97%, Time: 0:19:08 
Iter:   3800, Train Loss:   0.27, Train Acc:  89.06%, Val Loss:   0.23, Val Acc:  92.60%, Time: 0:19:39 *
Iter:   3900, Train Loss:   0.38, Train Acc:  84.38%, Val Loss:    0.2, Val Acc:  92.71%, Time: 0:20:10 *
Iter:   4000, Train Loss:   0.48, Train Acc:  85.94%, Val Loss:   0.19, Val Acc:  93.80%, Time: 0:20:41 *
Iter:   4100, Train Loss:   0.25, Train Acc:  90.62%, Val Loss:   0.22, Val Acc:  92.60%, Time: 0:21:13 
Iter:   4200, Train Loss:   0.19, Train Acc:  92.19%, Val Loss:   0.18, Val Acc:  94.99%, Time: 0:21:44 *
Iter:   4300, Train Loss:   0.27, Train Acc:  90.62%, Val Loss:   0.18, Val Acc:  94.45%, Time: 0:22:15 
Epoch: 5
Iter:   4400, Train Loss:   0.15, Train Acc:  96.88%, Val Loss:   0.15, Val Acc:  95.32%, Time: 0:22:46 *
Iter:   4500, Train Loss:   0.21, Train Acc:  92.19%, Val Loss:   0.18, Val Acc:  93.69%, Time: 0:23:15 
Iter:   4600, Train Loss:   0.11, Train Acc:  96.88%, Val Loss:   0.16, Val Acc:  95.32%, Time: 0:23:47 
Iter:   4700, Train Loss:   0.15, Train Acc:  93.75%, Val Loss:   0.14, Val Acc:  95.21%, Time: 0:24:18 
Iter:   4800, Train Loss:   0.18, Train Acc:  95.31%, Val Loss:   0.15, Val Acc:  95.87%, Time: 0:24:49 *
Iter:   4900, Train Loss:   0.17, Train Acc:  95.31%, Val Loss:   0.17, Val Acc:  94.45%, Time: 0:25:21 
Iter:   5000, Train Loss:   0.24, Train Acc:  92.19%, Val Loss:   0.16, Val Acc:  95.65%, Time: 0:25:52 
Iter:   5100, Train Loss:   0.19, Train Acc:  95.31%, Val Loss:   0.13, Val Acc:  95.87%, Time: 0:26:23 *
Iter:   5200, Train Loss:   0.15, Train Acc:  95.31%, Val Loss:   0.15, Val Acc:  95.32%, Time: 0:26:54 
Iter:   5300, Train Loss:   0.21, Train Acc:  90.62%, Val Loss:   0.14, Val Acc:  96.30%, Time: 0:27:26 *
Epoch: 6
Iter:   5400, Train Loss:   0.13, Train Acc:  95.31%, Val Loss:   0.15, Val Acc:  94.12%, Time: 0:28:02 
Iter:   5500, Train Loss:   0.21, Train Acc:  98.44%, Val Loss:   0.12, Val Acc:  95.97%, Time: 0:28:35 
Iter:   5600, Train Loss:   0.21, Train Acc:  93.75%, Val Loss:   0.16, Val Acc:  94.89%, Time: 0:29:12 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64

3.3 模型训练损失

在这里插入图片描述
在这里插入图片描述

3.4 模型测试

在这里插入图片描述

3.5 技术文档展示

在这里插入图片描述

4 源码下载

https://download.csdn.net/download/qq_42279468/20398625

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/198505?site
推荐阅读
相关标签
  

闽ICP备14008679号