Skip to main content

Binary Classification of Toxic Comments on Imbalanced Datasets Using Recurrent Neural Networks

  • Conference paper
  • First Online:
Machine Intelligence and Smart Systems

Part of the book series: Algorithms for Intelligent Systems ((AIS))

  • 529 Accesses

Abstract

Toxic (hateful and rude) behaviour is a huge problem in social media websites since toxic comments prevent constructive discussions and discourage people from starting conversations. Since millions of comments are posted daily, there needs to be some automated way to identify comments that are toxic and take action accordingly. In this paper, we aim to create a deep neural network that uses word embeddings for feature extraction and classifies comments into two classes—“Toxic” and “Non-toxic”. We have used a single recurrent layer, either LSTM, GRU, Bi-LSTM or Bi-GRU, in combination with other layers in our deep neural network to determine which architecture best suits this application. To handle class imbalance, we have used random under sampling on the majority class and data augmentation on the minority class. Our model was tested on Wikipedia Comments and Twitter Hate Comments datasets and achieved F1 scores of 0.89 and 0.84, respectively, outperforming the other works in this domain.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 219.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 279.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 279.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

References

  1. Davidson T, Warmsley D, Macy M, Weber I (2017) Automated hate speech detection and the problem of offensive language. In: Proceedings of the International AAAI conference on web and social media, vol 11(1). The AAAI Press, Palo Alto, California, pp 512–515

    Google Scholar 

  2. Yin D, Xue Z, Hong L, Davison BD, Kontostathis A, Edwards L (2009) Detection of harassment on web 2.0. Proc Content Anal WEB 2:1–7

    Google Scholar 

  3. Zaheri S, Leath J, Stroud D (2020) Toxic comment classification. SMU Data Sci Rev 3(1)

    Google Scholar 

  4. Nguyen H, Nguyen ML (2017) A deep neural architecture for sentence-level sentiment classification in Twitter social networking. In: Hasida K, Pa W (eds) International conference of the Pacific association for computational linguistics. Springer, Singapore, pp 15–27

    Google Scholar 

  5. Beniwal R, Maurya A (2021) Toxic comment classification using hybrid deep learning model. In: Karuppusamy P, Perikos I, Shi F, Nguyen TN (eds) Sustainable communication networks and application. Springer, Singapore, pp 461–473

    Chapter  Google Scholar 

  6. Yu LC, Wang J, Lai KR, Zhang X (2017) Refining word embeddings for sentiment analysis. In: Proceedings of conference on empirical methods in natural language processing. Copenhagen, Denmark, pp 534–539

    Google Scholar 

  7. Chu T, Jue K, Wang M (2017) Comment abuse classification with deep learning. http://web.stanford.edu/class/archive/cs/cs224n/cs224n.1174/reports/2762092.pdf. Accessed 12 Jun 2021

  8. Khieu K, Narwal N (2018) Detecting and classifying toxic comments. https://web.stanford.edu/class/archive/cs/cs224n/cs224n.1184/reports/6837517.pdf. Accessed 12 Jun 2021

  9. Van Aken B, Risch J, Krestel R, Löser A (2018) Challenges for toxic comment classification: an in-depth error analysis. arXiv preprint arXiv:1809.07572

  10. Pennington J, Socher R, Manning CD (2014) Glove: Global vectors for word representation. In: Proceedings of the 2014 conference on empirical methods in natural language processing (EMNLP), pp 1532–1543

    Google Scholar 

  11. Cho K, Van Merriënboer B, Gulcehre C, Bahdanau D, Bougares F, Schwenk H, Bengio Y (2014) Learning phrase representations using RNN encoder-decoder for statistical machine translation. arXiv preprint arXiv:1406.1078

  12. Keskar NS, Mudigere D, Nocedal J, Smelyanskiy M, Tang PT (2016) On large-batch training for deep learning: generalization gap and sharp minima. arXiv preprint arXiv:1609.04836

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2022 The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd.

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Saxena, A., Mittal, A., Verma, R. (2022). Binary Classification of Toxic Comments on Imbalanced Datasets Using Recurrent Neural Networks. In: Agrawal, S., Gupta, K.K., Chan, J.H., Agrawal, J., Gupta, M. (eds) Machine Intelligence and Smart Systems. Algorithms for Intelligent Systems. Springer, Singapore. https://doi.org/10.1007/978-981-16-9650-3_27

Download citation

Publish with us

Policies and ethics