diff --git a/Data Science Project/hateSpeech recognition.ipynb b/Data Science Project/hateSpeech recognition.ipynb new file mode 100644 index 00000000..6d651b7a --- /dev/null +++ b/Data Science Project/hateSpeech recognition.ipynb @@ -0,0 +1,870 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Classification of hate-speech detection of twitter \n", + "data using machine learning algorithm" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Importing essential Library" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "import sklearn\n", + "import numpy as np\n", + "import pandas as pd" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "importing Dataset" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [], + "source": [ + "labeleddata=pd.read_csv('labeled_data.csv')\n", + "train=pd.read_csv('train.csv')\n", + "test=pd.read_csv('test.csv')" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + " | id | \n", + "label | \n", + "tweet | \n", + "
---|---|---|---|
0 | \n", + "1 | \n", + "0 | \n", + "@user when a father is dysfunctional and is s... | \n", + "
1 | \n", + "2 | \n", + "0 | \n", + "@user @user thanks for #lyft credit i can't us... | \n", + "
2 | \n", + "3 | \n", + "0 | \n", + "bihday your majesty | \n", + "
3 | \n", + "4 | \n", + "0 | \n", + "#model i love u take with u all the time in ... | \n", + "
4 | \n", + "5 | \n", + "0 | \n", + "factsguide: society now #motivation | \n", + "
\n", + " | id | \n", + "tweet | \n", + "
---|---|---|
0 | \n", + "31963 | \n", + "#studiolife #aislife #requires #passion #dedic... | \n", + "
1 | \n", + "31964 | \n", + "@user #white #supremacists want everyone to s... | \n", + "
2 | \n", + "31965 | \n", + "safe ways to heal your #acne!! #altwaystohe... | \n", + "
3 | \n", + "31966 | \n", + "is the hp and the cursed child book up for res... | \n", + "
4 | \n", + "31967 | \n", + "3rd #bihday to my amazing, hilarious #nephew... | \n", + "
\n", + " | id | \n", + "label | \n", + "tweet | \n", + "clean_tweet | \n", + "
---|---|---|---|---|
0 | \n", + "1 | \n", + "0 | \n", + "@user when a father is dysfunctional and is s... | \n", + "when a father is dysfunctional and is so selfi... | \n", + "
1 | \n", + "2 | \n", + "0 | \n", + "@user @user thanks for #lyft credit i can't us... | \n", + "thanks for credit i cant use cause they dont o... | \n", + "
2 | \n", + "3 | \n", + "0 | \n", + "bihday your majesty | \n", + "bihday your majesty | \n", + "
3 | \n", + "4 | \n", + "0 | \n", + "#model i love u take with u all the time in ... | \n", + "i love u take with u all the time in ur | \n", + "
4 | \n", + "5 | \n", + "0 | \n", + "factsguide: society now #motivation | \n", + "factsguide society now | \n", + "
5 | \n", + "6 | \n", + "0 | \n", + "[2/2] huge fan fare and big talking before the... | \n", + "2 2 huge fan fare and big talking before they ... | \n", + "
6 | \n", + "7 | \n", + "0 | \n", + "@user camping tomorrow @user @user @user @use... | \n", + "camping tomorrow danny | \n", + "
7 | \n", + "8 | \n", + "0 | \n", + "the next school year is the year for exams.ð... | \n", + "the next school year is the year for exams can... | \n", + "
8 | \n", + "9 | \n", + "0 | \n", + "we won!!! love the land!!! #allin #cavs #champ... | \n", + "we won love the land | \n", + "
9 | \n", + "10 | \n", + "0 | \n", + "@user @user welcome here ! i'm it's so #gr... | \n", + "welcome here im its so | \n", + "
\n", + " | id | \n", + "tweet | \n", + "clean_tweet | \n", + "
---|---|---|---|
17192 | \n", + "49155 | \n", + "thought factory: left-right polarisation! #tru... | \n", + "thought factory left right polarisation >3 | \n", + "
17193 | \n", + "49156 | \n", + "feeling like a mermaid ð #hairflip #neverre... | \n", + "feeling like a mermaid | \n", + "
17194 | \n", + "49157 | \n", + "#hillary #campaigned today in #ohio((omg)) &am... | \n", + "today in omg & used words like assets&li... | \n", + "
17195 | \n", + "49158 | \n", + "happy, at work conference: right mindset leads... | \n", + "happy at work conference right mindset leads t... | \n", + "
17196 | \n", + "49159 | \n", + "my song \"so glad\" free download! #shoegaze ... | \n", + "my song so glad free download | \n", + "
\n", + " | and | \n", + "channel | \n", + "data | \n", + "fun | \n", + "import | \n", + "is | \n", + "it | \n", + "my | \n", + "passion | \n", + "please | \n", + "science | \n", + "subscribe | \n", + "this | \n", + "to | \n", + "youtube | \n", + "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", + "0 | \n", + "1 | \n", + "1 | \n", + "0 | \n", + "1 | \n", + "1 | \n", + "0 | \n", + "0 | \n", + "0 | \n", + "0 | \n", + "0 | \n", + "0 | \n", + "1 | \n", + "0 | \n", + "1 | \n", + "
1 | \n", + "1 | \n", + "0 | \n", + "1 | \n", + "1 | \n", + "0 | \n", + "2 | \n", + "1 | \n", + "1 | \n", + "1 | \n", + "0 | \n", + "1 | \n", + "0 | \n", + "0 | \n", + "0 | \n", + "0 | \n", + "
2 | \n", + "0 | \n", + "1 | \n", + "0 | \n", + "0 | \n", + "0 | \n", + "0 | \n", + "0 | \n", + "1 | \n", + "0 | \n", + "1 | \n", + "0 | \n", + "1 | \n", + "0 | \n", + "1 | \n", + "0 | \n", + "