{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "8DF-QiZIlCau" }, "source": [ "# Import libraries" ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5", "execution": { "iopub.execute_input": "2023-05-20T09:57:18.884233Z", "iopub.status.busy": "2023-05-20T09:57:18.883438Z", "iopub.status.idle": "2023-05-20T09:57:27.009157Z", "shell.execute_reply": "2023-05-20T09:57:27.008085Z", "shell.execute_reply.started": "2023-05-20T09:57:18.884079Z" }, "id": "xSsSrswIlCbJ", "trusted": true }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd \n", "import tensorflow as tf\n", "import nltk\n", "import seaborn as sns\n", "import re\n", "import matplotlib.pyplot as plt\n", "\n", "from tensorflow.keras.layers import Embedding, Dense, LSTM, Dropout, Bidirectional\n", "from tensorflow.keras.preprocessing.sequence import pad_sequences\n", "from tensorflow.keras.models import Sequential\n", "from tensorflow.keras.preprocessing.text import one_hot, Tokenizer\n", "from tensorflow.keras.callbacks import ModelCheckpoint\n", "from nltk.corpus import stopwords\n", "from nltk.stem.porter import PorterStemmer\n", "from sklearn import preprocessing\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.metrics import accuracy_score, classification_report, confusion_matrix" ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Od8s_dawlvmX", "outputId": "b7469730-880e-4801-b80b-26ddf4086962" }, "outputs": [], "source": [ "# from google.colab import drive\n", "# drive.mount('/content/drive')" ] }, { "cell_type": "markdown", "metadata": { "id": "GToU1HyYlCbO" }, "source": [ "# Read and clean data" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 206 }, "execution": { "iopub.execute_input": "2023-05-20T09:57:27.011197Z", "iopub.status.busy": "2023-05-20T09:57:27.010830Z", "iopub.status.idle": "2023-05-20T09:57:27.124001Z", "shell.execute_reply": "2023-05-20T09:57:27.122911Z", "shell.execute_reply.started": "2023-05-20T09:57:27.011157Z" }, "id": "3dx_SWZ9lCbR", "outputId": "34dbeca7-4f75-407f-ad15-bfb1d0c00e7f", "trusted": true }, "outputs": [ { "data": { "text/html": [ "
\n", " | Text | \n", "Emotion | \n", "
---|---|---|
0 | \n", "i didnt feel humiliated | \n", "sadness | \n", "
1 | \n", "i can go from feeling so hopeless to so damned... | \n", "sadness | \n", "
2 | \n", "im grabbing a minute to post i feel greedy wrong | \n", "anger | \n", "
3 | \n", "i am ever feeling nostalgic about the fireplac... | \n", "love | \n", "
4 | \n", "i am feeling grouchy | \n", "anger | \n", "
\n", " | Text | \n", "Emotion | \n", "
---|---|---|
11898 | \n", "i am feeling stressed and more than a bit anxious | \n", "sadness | \n", "
16501 | \n", "i am feeling stressed and more than a bit anxious | \n", "anger | \n", "
8246 | \n", "i am not amazing or great at photography but i... | \n", "love | \n", "
3508 | \n", "i am not amazing or great at photography but i... | \n", "happy | \n", "
15704 | \n", "i began to feel accepted by gaia on her own terms | \n", "happy | \n", "
... | \n", "... | \n", "... | \n", "
11354 | \n", "i write these words i feel sweet baby kicks fr... | \n", "love | \n", "
7685 | \n", "im still not sure why reilly feels the need to... | \n", "surprise | \n", "
2908 | \n", "im still not sure why reilly feels the need to... | \n", "fear | \n", "
9069 | \n", "ive also made it with both sugar measurements ... | \n", "love | \n", "
9596 | \n", "ive also made it with both sugar measurements ... | \n", "happy | \n", "
102 rows × 2 columns
\n", "