{ "cells": [ { "cell_type": "markdown", "source": [ "# Loading of Data" ], "metadata": { "id": "3O2gRML1CxuY" } }, { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "ClXaJHz3skxq", "outputId": "620e7537-0423-4b59-c9fd-9146b2062a4a" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n" ] } ], "source": [ "# prompt: load the dataset from a Google Drive\n", "\n", "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "from google.colab import drive\n", "\n", "# Load the dataset from a Google Drive file\n", "drive.mount('/content/drive')\n", "data = pd.read_csv('/content/drive/MyDrive/Colab_Notebooks/Twitter_Analysis.csv')\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "y4xKC0BJVd-o", "outputId": "01958e58-4379-487a-c1ef-aabad115e6a6" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n" ] } ], "source": [ "from google.colab import drive\n", "drive.mount('/content/drive')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 707 }, "id": "EsspYImeyQeS", "outputId": "7c076ae0-2533-4439-c347-994aa7d50418" }, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " Unnamed: 0 majority_target \\\n", "0 0 True \n", "1 1 True \n", "2 2 True \n", "3 3 True \n", "4 4 True \n", "\n", " statement BinaryNumTarget \\\n", "0 End of eviction moratorium means millions of A... 1.0 \n", "1 End of eviction moratorium means millions of A... 1.0 \n", "2 End of eviction moratorium means millions of A... 1.0 \n", "3 End of eviction moratorium means millions of A... 1.0 \n", "4 End of eviction moratorium means millions of A... 1.0 \n", "\n", " tweet followers_count \\\n", "0 @POTUS Biden Blunders - 6 Month Update\\n\\nInfl... 4262.0 \n", "1 @S0SickRick @Stairmaster_ @6d6f636869 Not as m... 1393.0 \n", "2 THE SUPREME COURT is siding with super rich pr... 9.0 \n", "3 @POTUS Biden Blunders\\n\\nBroken campaign promi... 4262.0 \n", "4 @OhComfy I agree. The confluence of events rig... 70.0 \n", "\n", " friends_count favourites_count statuses_count listed_count ... \\\n", "0 3619.0 34945.0 16423.0 44.0 ... \n", "1 1621.0 31436.0 37184.0 64.0 ... \n", "2 84.0 219.0 1184.0 0.0 ... \n", "3 3619.0 34945.0 16423.0 44.0 ... \n", "4 166.0 15282.0 2194.0 0.0 ... \n", "\n", " determiners conjunctions dots exclamation questions ampersand \\\n", "0 0 0 5 0 1 0 \n", "1 0 2 1 0 0 0 \n", "2 0 1 0 0 0 0 \n", "3 0 1 3 0 0 1 \n", "4 0 1 3 0 1 0 \n", "\n", " capitals digits long_word_freq short_word_freq \n", "0 33 3 5 19 \n", "1 14 0 2 34 \n", "2 3 0 4 10 \n", "3 6 8 1 30 \n", "4 11 3 2 19 \n", "\n", "[5 rows x 64 columns]" ], "text/html": [ "\n", "
\n", " | Unnamed: 0 | \n", "majority_target | \n", "statement | \n", "BinaryNumTarget | \n", "tweet | \n", "followers_count | \n", "friends_count | \n", "favourites_count | \n", "statuses_count | \n", "listed_count | \n", "... | \n", "determiners | \n", "conjunctions | \n", "dots | \n", "exclamation | \n", "questions | \n", "ampersand | \n", "capitals | \n", "digits | \n", "long_word_freq | \n", "short_word_freq | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@POTUS Biden Blunders - 6 Month Update\\n\\nInfl... | \n", "4262.0 | \n", "3619.0 | \n", "34945.0 | \n", "16423.0 | \n", "44.0 | \n", "... | \n", "0 | \n", "0 | \n", "5 | \n", "0 | \n", "1 | \n", "0 | \n", "33 | \n", "3 | \n", "5 | \n", "19 | \n", "
1 | \n", "1 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@S0SickRick @Stairmaster_ @6d6f636869 Not as m... | \n", "1393.0 | \n", "1621.0 | \n", "31436.0 | \n", "37184.0 | \n", "64.0 | \n", "... | \n", "0 | \n", "2 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "14 | \n", "0 | \n", "2 | \n", "34 | \n", "
2 | \n", "2 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "THE SUPREME COURT is siding with super rich pr... | \n", "9.0 | \n", "84.0 | \n", "219.0 | \n", "1184.0 | \n", "0.0 | \n", "... | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "3 | \n", "0 | \n", "4 | \n", "10 | \n", "
3 | \n", "3 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@POTUS Biden Blunders\\n\\nBroken campaign promi... | \n", "4262.0 | \n", "3619.0 | \n", "34945.0 | \n", "16423.0 | \n", "44.0 | \n", "... | \n", "0 | \n", "1 | \n", "3 | \n", "0 | \n", "0 | \n", "1 | \n", "6 | \n", "8 | \n", "1 | \n", "30 | \n", "
4 | \n", "4 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@OhComfy I agree. The confluence of events rig... | \n", "70.0 | \n", "166.0 | \n", "15282.0 | \n", "2194.0 | \n", "0.0 | \n", "... | \n", "0 | \n", "1 | \n", "3 | \n", "0 | \n", "1 | \n", "0 | \n", "11 | \n", "3 | \n", "2 | \n", "19 | \n", "
5 rows × 64 columns
\n", "\n", " | Unnamed: 0 | \n", "majority_target | \n", "statement | \n", "BinaryNumTarget | \n", "tweet | \n", "followers_count | \n", "friends_count | \n", "favourites_count | \n", "statuses_count | \n", "listed_count | \n", "... | \n", "determiners | \n", "conjunctions | \n", "dots | \n", "exclamation | \n", "questions | \n", "ampersand | \n", "capitals | \n", "digits | \n", "long_word_freq | \n", "short_word_freq | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@POTUS Biden Blunders - 6 Month Update\\n\\nInfl... | \n", "4262.0 | \n", "3619.0 | \n", "34945.0 | \n", "16423.0 | \n", "44.0 | \n", "... | \n", "0 | \n", "0 | \n", "5 | \n", "0 | \n", "1 | \n", "0 | \n", "33 | \n", "3 | \n", "5 | \n", "19 | \n", "
1 | \n", "1 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@S0SickRick @Stairmaster_ @6d6f636869 Not as m... | \n", "1393.0 | \n", "1621.0 | \n", "31436.0 | \n", "37184.0 | \n", "64.0 | \n", "... | \n", "0 | \n", "2 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "14 | \n", "0 | \n", "2 | \n", "34 | \n", "
2 | \n", "2 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "THE SUPREME COURT is siding with super rich pr... | \n", "9.0 | \n", "84.0 | \n", "219.0 | \n", "1184.0 | \n", "0.0 | \n", "... | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "3 | \n", "0 | \n", "4 | \n", "10 | \n", "
3 | \n", "3 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@POTUS Biden Blunders\\n\\nBroken campaign promi... | \n", "4262.0 | \n", "3619.0 | \n", "34945.0 | \n", "16423.0 | \n", "44.0 | \n", "... | \n", "0 | \n", "1 | \n", "3 | \n", "0 | \n", "0 | \n", "1 | \n", "6 | \n", "8 | \n", "1 | \n", "30 | \n", "
4 | \n", "4 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@OhComfy I agree. The confluence of events rig... | \n", "70.0 | \n", "166.0 | \n", "15282.0 | \n", "2194.0 | \n", "0.0 | \n", "... | \n", "0 | \n", "1 | \n", "3 | \n", "0 | \n", "1 | \n", "0 | \n", "11 | \n", "3 | \n", "2 | \n", "19 | \n", "
5 rows × 64 columns
\n", "\n", " | Unnamed: 0 | \n", "majority_target | \n", "statement | \n", "BinaryNumTarget | \n", "tweet | \n", "followers_count | \n", "friends_count | \n", "favourites_count | \n", "statuses_count | \n", "listed_count | \n", "... | \n", "determiners | \n", "conjunctions | \n", "dots | \n", "exclamation | \n", "questions | \n", "ampersand | \n", "capitals | \n", "digits | \n", "long_word_freq | \n", "short_word_freq | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@POTUS Biden Blunders - 6 Month Update\\n\\nInfl... | \n", "4262.0 | \n", "3619.0 | \n", "34945.0 | \n", "16423.0 | \n", "44.0 | \n", "... | \n", "0 | \n", "0 | \n", "5 | \n", "0 | \n", "1 | \n", "0 | \n", "33 | \n", "3 | \n", "5 | \n", "19 | \n", "
1 | \n", "1 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@S0SickRick @Stairmaster_ @6d6f636869 Not as m... | \n", "1393.0 | \n", "1621.0 | \n", "31436.0 | \n", "37184.0 | \n", "64.0 | \n", "... | \n", "0 | \n", "2 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "14 | \n", "0 | \n", "2 | \n", "34 | \n", "
2 | \n", "2 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "THE SUPREME COURT is siding with super rich pr... | \n", "9.0 | \n", "84.0 | \n", "219.0 | \n", "1184.0 | \n", "0.0 | \n", "... | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "3 | \n", "0 | \n", "4 | \n", "10 | \n", "
3 | \n", "3 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@POTUS Biden Blunders\\n\\nBroken campaign promi... | \n", "4262.0 | \n", "3619.0 | \n", "34945.0 | \n", "16423.0 | \n", "44.0 | \n", "... | \n", "0 | \n", "1 | \n", "3 | \n", "0 | \n", "0 | \n", "1 | \n", "6 | \n", "8 | \n", "1 | \n", "30 | \n", "
4 | \n", "4 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@OhComfy I agree. The confluence of events rig... | \n", "70.0 | \n", "166.0 | \n", "15282.0 | \n", "2194.0 | \n", "0.0 | \n", "... | \n", "0 | \n", "1 | \n", "3 | \n", "0 | \n", "1 | \n", "0 | \n", "11 | \n", "3 | \n", "2 | \n", "19 | \n", "
5 rows × 64 columns
\n", "\n", " | Unnamed: 0 | \n", "majority_target | \n", "statement | \n", "BinaryNumTarget | \n", "tweet | \n", "followers_count | \n", "friends_count | \n", "favourites_count | \n", "statuses_count | \n", "listed_count | \n", "... | \n", "determiners | \n", "conjunctions | \n", "dots | \n", "exclamation | \n", "questions | \n", "ampersand | \n", "capitals | \n", "digits | \n", "long_word_freq | \n", "short_word_freq | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@POTUS Biden Blunders - 6 Month Update\\n\\nInfl... | \n", "4262.0 | \n", "3619.0 | \n", "34945.0 | \n", "16423.0 | \n", "44.0 | \n", "... | \n", "0 | \n", "0 | \n", "5 | \n", "0 | \n", "1 | \n", "0 | \n", "33 | \n", "3 | \n", "5 | \n", "19 | \n", "
1 | \n", "1 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@S0SickRick @Stairmaster_ @6d6f636869 Not as m... | \n", "1393.0 | \n", "1621.0 | \n", "31436.0 | \n", "37184.0 | \n", "64.0 | \n", "... | \n", "0 | \n", "2 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "14 | \n", "0 | \n", "2 | \n", "34 | \n", "
2 | \n", "2 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "THE SUPREME COURT is siding with super rich pr... | \n", "9.0 | \n", "84.0 | \n", "219.0 | \n", "1184.0 | \n", "0.0 | \n", "... | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "3 | \n", "0 | \n", "4 | \n", "10 | \n", "
3 | \n", "3 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@POTUS Biden Blunders\\n\\nBroken campaign promi... | \n", "4262.0 | \n", "3619.0 | \n", "34945.0 | \n", "16423.0 | \n", "44.0 | \n", "... | \n", "0 | \n", "1 | \n", "3 | \n", "0 | \n", "0 | \n", "1 | \n", "6 | \n", "8 | \n", "1 | \n", "30 | \n", "
4 | \n", "4 | \n", "True | \n", "End of eviction moratorium means millions of A... | \n", "1.0 | \n", "@OhComfy I agree. The confluence of events rig... | \n", "70.0 | \n", "166.0 | \n", "15282.0 | \n", "2194.0 | \n", "0.0 | \n", "... | \n", "0 | \n", "1 | \n", "3 | \n", "0 | \n", "1 | \n", "0 | \n", "11 | \n", "3 | \n", "2 | \n", "19 | \n", "
5 rows × 64 columns
\n", "