{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "cilIdrLI_45O" }, "source": [ "**Import Libraries and Data** " ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "id": "JQombcEn_45S" }, "outputs": [], "source": [ "import numpy as np \n", "import pandas as pd\n", "import os" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "id": "DXvzRjJA_45Y" }, "outputs": [], "source": [ "# import BERT tokenization\n", "\n", "!wget --quiet https://raw.githubusercontent.com/tensorflow/models/master/official/nlp/bert/tokenization.py" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "w78aCQUjAPrO", "outputId": "059c06ee-6569-44b9-9a8b-3db63408b400" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n", "Collecting tokenization\n", " Downloading tokenization-1.0.7-py3-none-any.whl (10 kB)\n", "Requirement already satisfied: regex in /usr/local/lib/python3.8/dist-packages (from tokenization) (2022.6.2)\n", "Installing collected packages: tokenization\n", "Successfully installed tokenization-1.0.7\n" ] } ], "source": [ "pip install tokenization" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "id": "if3e9neA_45a" }, "outputs": [], "source": [ "import tokenization\n", "import tensorflow as tf\n", "import tensorflow_hub as hub\n", "from tensorflow.keras.utils import to_categorical\n", "from sklearn import preprocessing\n", "from sklearn.model_selection import train_test_split" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "LKDX7i3jAbNz", "outputId": "c68a6631-e570-4c3a-be08-b36c9d354535" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Mounted at /content/drive\n" ] } ], "source": [ "from google.colab import drive\n", "import os\n", "drive.mount('/content/drive')" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "id": "lC91JoTC_45c" }, "outputs": [], "source": [ "data_t = pd.read_csv('/content/drive/My Drive/smartphone_preprocessed_sentiments.csv')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "zKckPxr2m1sv" }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 7, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 243 }, "id": "xFhCh4RZ_45e", "outputId": "af15ca6a-5a8b-4ebe-f6e5-a20ad14c9dcb" }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " | Unnamed: 0 | \n", "Unnamed: 0.1 | \n", "Date | \n", "User | \n", "Location | \n", "Tweets | \n", "c_Tweets | \n", "cleanText | \n", "Subjectivity | \n", "Polarity | \n", "Sentiment | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|
1 | \n", "1 | \n", "1.0 | \n", "2022-10-30 23:00:47+00:00 | \n", "GhostlyOwl | \n", "British Columbia | \n", "I will go anywhere provided it be forward. ~ D... | \n", "I will go anywhere provided it be forward. ~ D... | \n", "anywher provid forward david livingston anasta... | \n", "0.0 | \n", "0.0 | \n", "Neutral | \n", "
2 | \n", "2 | \n", "2.0 | \n", "2022-10-30 22:48:15+00:00 | \n", "Sensible_George | \n", "London, England | \n", "@them_apples Compel parking companies to retai... | \n", "Compel parking companies to retain pay machine... | \n", "compel park compani retain pay machin five mil... | \n", "0.0 | \n", "0.0 | \n", "Neutral | \n", "