nlp-lab/Project/simple_approach/simple_twitter_learning.ipynb
2018-06-10 14:41:41 +02:00

2289 lines
92 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from IPython.display import clear_output, Markdown, Math\n",
"import ipywidgets as widgets\n",
"import os\n",
"import glob\n",
"import json\n",
"import numpy as np\n",
"import itertools\n",
"import sklearn.utils as sku\n",
"from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer, HashingVectorizer\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn.preprocessing import MultiLabelBinarizer"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"# TODO importing function for sentiment to emoji mapping\n",
"def sent2emoji(sentiment_vector: np.array):\n",
" return '🤦'\n",
"\n",
"def emoji2sent(emoji: str):\n",
" return np.zeros(3)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"SINGLE_LABEL = True"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# simple twitter approach\n",
"*for learning emoji usage by single (in the meaning of unconnected) twitter messages*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## loading train data"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"data_root_folder = \"./data_en/\" # i created a symlink here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* get all json files in `data_root_folder`"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"json_files = sorted(glob.glob(data_root_folder + \"/*.json\"))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"----"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* so far, only load the first file"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>EMOJI</th>\n",
" <th>HASHTAGS</th>\n",
" <th>LINKED_USER</th>\n",
" <th>datetime</th>\n",
" <th>id</th>\n",
" <th>lang</th>\n",
" <th>person</th>\n",
" <th>reply_to</th>\n",
" <th>text</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>[🔥, 👏]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:00</td>\n",
" <td>925716304635547600</td>\n",
" <td>en</td>\n",
" <td>31507978</td>\n",
" <td>NaN</td>\n",
" <td>fashionbombdaily's photo &lt;EMOJI&gt;&lt;EMOJI&gt;🏼</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>[🤦]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:00</td>\n",
" <td>925716304664911900</td>\n",
" <td>en</td>\n",
" <td>231994649</td>\n",
" <td>NaN</td>\n",
" <td>Its scary how on point my horoscope be &lt;EMOJI...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>[😄]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:03</td>\n",
" <td>925716317214089200</td>\n",
" <td>en</td>\n",
" <td>2592765104</td>\n",
" <td>NaN</td>\n",
" <td>Woooaaaahhh &lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>[📷]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:04</td>\n",
" <td>925716321416949800</td>\n",
" <td>en</td>\n",
" <td>278737933</td>\n",
" <td>NaN</td>\n",
" <td>&lt;EMOJI&gt; vivalcli: Portraits by Zhao Guojing an...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>[😩, 😩]</td>\n",
" <td>[]</td>\n",
" <td>[@hiphopphiIes]</td>\n",
" <td>2017-11-01 13:29:06</td>\n",
" <td>925716329801310200</td>\n",
" <td>en</td>\n",
" <td>824586253634981900</td>\n",
" <td>9.257162e+17</td>\n",
" <td>&lt;USER&gt; i wanna know too&lt;EMOJI&gt;&lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>[😭, 💓]</td>\n",
" <td>[]</td>\n",
" <td>[@WizMommma]</td>\n",
" <td>2017-11-01 13:29:02</td>\n",
" <td>925716313019965400</td>\n",
" <td>en</td>\n",
" <td>1581953814</td>\n",
" <td>9.257088e+17</td>\n",
" <td>&lt;USER&gt; veda was yoda too &lt;EMOJI&gt;&lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>[😂]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:05</td>\n",
" <td>925716325607133200</td>\n",
" <td>en</td>\n",
" <td>1001999683</td>\n",
" <td>NaN</td>\n",
" <td>Im less stressed about turning 30 now &lt;EMOJI&gt;...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>[💯]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:07</td>\n",
" <td>925716334008082400</td>\n",
" <td>en</td>\n",
" <td>745222369183043600</td>\n",
" <td>NaN</td>\n",
" <td>Full charged. &lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>[🙄]</td>\n",
" <td>[]</td>\n",
" <td>[@SeaDimon, @lsarsour]</td>\n",
" <td>2017-11-01 13:29:09</td>\n",
" <td>925716342401052700</td>\n",
" <td>en</td>\n",
" <td>798557155217539100</td>\n",
" <td>9.257147e+17</td>\n",
" <td>&lt;USER&gt; Thats part of the problem, (they) &lt;USE...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>[😟, 😥, 😢]</td>\n",
" <td>[]</td>\n",
" <td>[@Ian_khetye]</td>\n",
" <td>2017-11-01 13:29:10</td>\n",
" <td>925716346570240000</td>\n",
" <td>en</td>\n",
" <td>744396039126421500</td>\n",
" <td>9.250629e+17</td>\n",
" <td>&lt;USER&gt; got me emotional there&lt;EMOJI&gt;&lt;EMOJI&gt;&lt;EM...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>[🌻]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:13</td>\n",
" <td>925716359182520300</td>\n",
" <td>en</td>\n",
" <td>721490010118205400</td>\n",
" <td>8.965900e+17</td>\n",
" <td>back to the yellow &lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>[🍁, 🌺, 🍂]</td>\n",
" <td>[]</td>\n",
" <td>[@Dimafadma]</td>\n",
" <td>2017-11-01 13:29:15</td>\n",
" <td>925716367558545400</td>\n",
" <td>en</td>\n",
" <td>520536723</td>\n",
" <td>9.257159e+17</td>\n",
" <td>&lt;USER&gt; Happy month to you and your loved ones ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>[🍃]</td>\n",
" <td>[#mortdale, #partofthefamily, #gorgeousboy]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:16</td>\n",
" <td>925716371735900200</td>\n",
" <td>en</td>\n",
" <td>850852815941517300</td>\n",
" <td>NaN</td>\n",
" <td>Maxx and Patricia. Family hangs at For Good He...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>[💭, 🤦]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:20</td>\n",
" <td>925716388513230800</td>\n",
" <td>en</td>\n",
" <td>914145041588867100</td>\n",
" <td>NaN</td>\n",
" <td>I need to STOP beating myself up with my thoug...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>[😍, 😘]</td>\n",
" <td>[#7YearsOfKMH2]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:20</td>\n",
" <td>925716388525645800</td>\n",
" <td>en</td>\n",
" <td>2425405622</td>\n",
" <td>NaN</td>\n",
" <td>Cutest Son &lt;EMOJI&gt;Roll no. 31 &lt;EMOJI&gt; &lt;HASHTAG&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>[😜]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:22</td>\n",
" <td>925716396931240000</td>\n",
" <td>en</td>\n",
" <td>4614871873</td>\n",
" <td>NaN</td>\n",
" <td>By the summer I should have everything up and ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>[😂, 🔥]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:23</td>\n",
" <td>925716401125331000</td>\n",
" <td>en</td>\n",
" <td>2831608345</td>\n",
" <td>NaN</td>\n",
" <td>I know my English is not that good but that do...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>[💕]</td>\n",
" <td>[]</td>\n",
" <td>[@yungbabytate]</td>\n",
" <td>2017-11-01 13:29:23</td>\n",
" <td>925716401133948900</td>\n",
" <td>en</td>\n",
" <td>788571974633009200</td>\n",
" <td>9.255778e+17</td>\n",
" <td>&lt;USER&gt; I &lt;EMOJI&gt; u mama</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>[😉]</td>\n",
" <td>[]</td>\n",
" <td>[@cmckenney]</td>\n",
" <td>2017-11-01 13:29:23</td>\n",
" <td>925716401125544000</td>\n",
" <td>en</td>\n",
" <td>218307802</td>\n",
" <td>9.257115e+17</td>\n",
" <td>&lt;USER&gt; That picture was NOT taken this morning...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>[👅]</td>\n",
" <td>[#footfetishnation]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:25</td>\n",
" <td>925716409489002500</td>\n",
" <td>en</td>\n",
" <td>885261166146179100</td>\n",
" <td>NaN</td>\n",
" <td>Welcome to &lt;HASHTAG&gt; &lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>[👌, 🙂]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:25</td>\n",
" <td>925716409497272300</td>\n",
" <td>en</td>\n",
" <td>831437760833609700</td>\n",
" <td>NaN</td>\n",
" <td>Awkward &lt;EMOJI&gt;&lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>[🤗, 📺]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:26</td>\n",
" <td>925716413699854300</td>\n",
" <td>en</td>\n",
" <td>231664542</td>\n",
" <td>NaN</td>\n",
" <td>back at it with supernatural &lt;EMOJI&gt;&lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>[💯]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:26</td>\n",
" <td>925716413679009800</td>\n",
" <td>en</td>\n",
" <td>3196847035</td>\n",
" <td>NaN</td>\n",
" <td>One of the best things I've learned was to sto...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>[👅, 💦, 🍑]</td>\n",
" <td>[]</td>\n",
" <td>[@ctrlpurp]</td>\n",
" <td>2017-11-01 13:29:29</td>\n",
" <td>925716426278735900</td>\n",
" <td>en</td>\n",
" <td>918492858352635900</td>\n",
" <td>9.257161e+17</td>\n",
" <td>&lt;USER&gt; Can I taste?&lt;EMOJI&gt;&lt;EMOJI&gt;&lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>[💔]</td>\n",
" <td>[]</td>\n",
" <td>[@saunders_court1]</td>\n",
" <td>2017-11-01 13:29:30</td>\n",
" <td>925716430473039900</td>\n",
" <td>en</td>\n",
" <td>3471187337</td>\n",
" <td>9.257163e+17</td>\n",
" <td>&lt;USER&gt; we miss you ☹️&lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>[🤐, 🤐, 🤐]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:31</td>\n",
" <td>925716434667184100</td>\n",
" <td>en</td>\n",
" <td>780060488600199200</td>\n",
" <td>NaN</td>\n",
" <td>Actually my bias in WJSN are Eunseo &amp;amp; Bona...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>[😴]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:32</td>\n",
" <td>925716438853345300</td>\n",
" <td>en</td>\n",
" <td>388380690</td>\n",
" <td>NaN</td>\n",
" <td>I so cannot be bothered with the rest of the d...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>[😂]</td>\n",
" <td>[]</td>\n",
" <td>[@xxxtentacion]</td>\n",
" <td>2017-11-01 13:29:35</td>\n",
" <td>925716451457163300</td>\n",
" <td>en</td>\n",
" <td>899320696869974000</td>\n",
" <td>NaN</td>\n",
" <td>&lt;USER&gt; 2lit4life&lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>[😂, 🙄]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 13:29:35</td>\n",
" <td>925716451461357600</td>\n",
" <td>en</td>\n",
" <td>784790670</td>\n",
" <td>NaN</td>\n",
" <td>Im not stop saying that!&lt;EMOJI&gt;&lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>[🎉, 🎂, 🎈, 🎊, 🎁, 💜]</td>\n",
" <td>[]</td>\n",
" <td>[@justinerooney_]</td>\n",
" <td>2017-11-01 13:29:37</td>\n",
" <td>925716459828936700</td>\n",
" <td>en</td>\n",
" <td>3051266655</td>\n",
" <td>NaN</td>\n",
" <td>&lt;USER&gt; HAPPY BIHDAY &lt;EMOJI&gt;&lt;EMOJI&gt;&lt;EMOJI&gt;&lt;EMOJ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68703</th>\n",
" <td>[😕]</td>\n",
" <td>[#halloweencostumes]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:04</td>\n",
" <td>925624214522036200</td>\n",
" <td>en</td>\n",
" <td>1672876458</td>\n",
" <td>NaN</td>\n",
" <td>&lt;HASHTAG&gt; this one falls under the weird crazy...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68704</th>\n",
" <td>[😂, 😩]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:05</td>\n",
" <td>925624218682777600</td>\n",
" <td>en</td>\n",
" <td>382473866</td>\n",
" <td>NaN</td>\n",
" <td>I'm not allowed to have chocolates yet, then I...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68705</th>\n",
" <td>[😂]</td>\n",
" <td>[#MUFC]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:06</td>\n",
" <td>925624222889766900</td>\n",
" <td>en</td>\n",
" <td>893145405457911800</td>\n",
" <td>NaN</td>\n",
" <td>Manchester United manager Mourinho slams 'spec...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68706</th>\n",
" <td>[💖]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:07</td>\n",
" <td>925624227088121900</td>\n",
" <td>en</td>\n",
" <td>240378516</td>\n",
" <td>NaN</td>\n",
" <td>&lt;EMOJI&gt; en Bushwhick</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68707</th>\n",
" <td>[🌆, 👉, 🚖, 📞]</td>\n",
" <td>[#BurkeCentre]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:18</td>\n",
" <td>925624273237983200</td>\n",
" <td>en</td>\n",
" <td>784620573209002000</td>\n",
" <td>NaN</td>\n",
" <td>: &lt;HASHTAG&gt; &lt;EMOJI&gt; &lt;EMOJI&gt;&lt;EMOJI&gt; For Taxi &lt;E...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68708</th>\n",
" <td>[😁]</td>\n",
" <td>[]</td>\n",
" <td>[@mychosliaheart, @BarrettoJulia, @iamjoshuaga...</td>\n",
" <td>2017-11-01 07:23:18</td>\n",
" <td>925624273212805100</td>\n",
" <td>en</td>\n",
" <td>170998187</td>\n",
" <td>9.254136e+17</td>\n",
" <td>&lt;USER&gt; &lt;USER&gt; &lt;USER&gt; Look, Mammeh and Daddeh! ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68709</th>\n",
" <td>[😋]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:24</td>\n",
" <td>925624298395533300</td>\n",
" <td>en</td>\n",
" <td>1348667816</td>\n",
" <td>NaN</td>\n",
" <td>Life is so good with you &lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68710</th>\n",
" <td>[👌, 🎃, 😘]</td>\n",
" <td>[#portlandoregon, #portlandhalloween, #carrie…]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:24</td>\n",
" <td>925624298378801200</td>\n",
" <td>en</td>\n",
" <td>722481645765300200</td>\n",
" <td>NaN</td>\n",
" <td>Happy Halloween! &lt;EMOJI&gt;🏽&lt;EMOJI&gt;&lt;EMOJI&gt; &lt;HASHT...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68711</th>\n",
" <td>[👍]</td>\n",
" <td>[]</td>\n",
" <td>[@8limbsbondi...]</td>\n",
" <td>2017-11-01 07:23:26</td>\n",
" <td>925624306779897900</td>\n",
" <td>en</td>\n",
" <td>2443251500</td>\n",
" <td>NaN</td>\n",
" <td>Some work on the ropes in todays boxing class...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68712</th>\n",
" <td>[😭]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:27</td>\n",
" <td>925624310974136300</td>\n",
" <td>en</td>\n",
" <td>2406186390</td>\n",
" <td>NaN</td>\n",
" <td>Scotty and Kristens halloween costumes &lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68713</th>\n",
" <td>[😂]</td>\n",
" <td>[]</td>\n",
" <td>[@rfrandrea, @AdaaanAndyyy]</td>\n",
" <td>2017-11-01 07:23:30</td>\n",
" <td>925624323557146600</td>\n",
" <td>en</td>\n",
" <td>1039448149</td>\n",
" <td>9.256150e+17</td>\n",
" <td>&lt;USER&gt; &lt;USER&gt; May pre-month celebration sis &lt;E...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68714</th>\n",
" <td>[😭, 😭, 💘]</td>\n",
" <td>[]</td>\n",
" <td>[@peachshua1230]</td>\n",
" <td>2017-11-01 07:23:31</td>\n",
" <td>925624327755591700</td>\n",
" <td>en</td>\n",
" <td>845085544589672400</td>\n",
" <td>9.256009e+17</td>\n",
" <td>&lt;USER&gt; Awww &lt;EMOJI&gt; Ajsksjdjd im smiling like ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68715</th>\n",
" <td>[😫, ✋]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:34</td>\n",
" <td>925624340342812700</td>\n",
" <td>en</td>\n",
" <td>924752524871131100</td>\n",
" <td>NaN</td>\n",
" <td>I hate when I send a text or snap n I'm so anx...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68716</th>\n",
" <td>[😂, 🙁]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:34</td>\n",
" <td>925624340355280900</td>\n",
" <td>en</td>\n",
" <td>419493819</td>\n",
" <td>NaN</td>\n",
" <td>The answer is no I have no plans and I never l...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68717</th>\n",
" <td>[😭]</td>\n",
" <td>[]</td>\n",
" <td>[@BeachBoy_Gab]</td>\n",
" <td>2017-11-01 07:23:34</td>\n",
" <td>925624340346937300</td>\n",
" <td>en</td>\n",
" <td>2457745952</td>\n",
" <td>9.256219e+17</td>\n",
" <td>&lt;USER&gt; LMAOOO I'm so proud &lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68718</th>\n",
" <td>[😢, 💔]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:34</td>\n",
" <td>925624340338507800</td>\n",
" <td>en</td>\n",
" <td>1955767531</td>\n",
" <td>NaN</td>\n",
" <td>My cousin/little sister is leaving to San Fran...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68719</th>\n",
" <td>[🙃]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:35</td>\n",
" <td>925624344524361700</td>\n",
" <td>en</td>\n",
" <td>796490344581898200</td>\n",
" <td>NaN</td>\n",
" <td>Can't be alone w my thoughts tonight so just g...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68720</th>\n",
" <td>[😂, 😂, 😂, 😂, 😂]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:36</td>\n",
" <td>925624348710285300</td>\n",
" <td>en</td>\n",
" <td>907808317124177900</td>\n",
" <td>NaN</td>\n",
" <td>&lt;EMOJI&gt;&lt;EMOJI&gt;&lt;EMOJI&gt;&lt;EMOJI&gt;&lt;EMOJI&gt; ambot!!!</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68721</th>\n",
" <td>[👌, 👊, 🙌]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:37</td>\n",
" <td>925624352929910800</td>\n",
" <td>en</td>\n",
" <td>262162415</td>\n",
" <td>NaN</td>\n",
" <td>&lt;EMOJI&gt;🏽&lt;EMOJI&gt;🏽 1st of the month!!Happy 1st o...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68722</th>\n",
" <td>[😴]</td>\n",
" <td>[#WednesdayWisdom]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:41</td>\n",
" <td>925624369715515400</td>\n",
" <td>en</td>\n",
" <td>574882525</td>\n",
" <td>NaN</td>\n",
" <td>&lt;HASHTAG&gt; ... stay in bed &lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68723</th>\n",
" <td>[😂, 😂, 😂, 😂]</td>\n",
" <td>[]</td>\n",
" <td>[@Louis_Tomlinson, @NiallOfficial]</td>\n",
" <td>2017-11-01 07:23:44</td>\n",
" <td>925624382269124600</td>\n",
" <td>en</td>\n",
" <td>556175173</td>\n",
" <td>9.254038e+17</td>\n",
" <td>&lt;USER&gt; &lt;USER&gt; THIS IS GOLD. GOLD. &lt;EMOJI&gt;&lt;EMOJ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68724</th>\n",
" <td>[😀]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:45</td>\n",
" <td>925624386455031800</td>\n",
" <td>en</td>\n",
" <td>1610265588</td>\n",
" <td>NaN</td>\n",
" <td>&lt;EMOJI&gt; thank you for the kind compliment</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68725</th>\n",
" <td>[😎]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:45</td>\n",
" <td>925624386454937600</td>\n",
" <td>en</td>\n",
" <td>4760724450</td>\n",
" <td>NaN</td>\n",
" <td>Enjoyed the silence &lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68726</th>\n",
" <td>[✨]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:46</td>\n",
" <td>925624390657572900</td>\n",
" <td>en</td>\n",
" <td>882858115636514800</td>\n",
" <td>NaN</td>\n",
" <td>OS: Spiderman Homecoming &lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68727</th>\n",
" <td>[🤷]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:46</td>\n",
" <td>925624390682849300</td>\n",
" <td>en</td>\n",
" <td>188129628</td>\n",
" <td>NaN</td>\n",
" <td>Go to hell &lt;EMOJI&gt;🏽‍♀️</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68728</th>\n",
" <td>[😘]</td>\n",
" <td>[]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:46</td>\n",
" <td>925624390666129400</td>\n",
" <td>en</td>\n",
" <td>2473135939</td>\n",
" <td>NaN</td>\n",
" <td>Thank you Yomi! &lt;EMOJI&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68729</th>\n",
" <td>[😂]</td>\n",
" <td>[]</td>\n",
" <td>[@discopiggu]</td>\n",
" <td>2017-11-01 07:23:46</td>\n",
" <td>925624390670106600</td>\n",
" <td>en</td>\n",
" <td>2373584209</td>\n",
" <td>9.256241e+17</td>\n",
" <td>&lt;USER&gt; Lol. Just enjoy the stars. Music Kidhar...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68730</th>\n",
" <td>[🙏]</td>\n",
" <td>[#NYCStrong]</td>\n",
" <td>[]</td>\n",
" <td>2017-11-01 07:23:50</td>\n",
" <td>925624407459971100</td>\n",
" <td>en</td>\n",
" <td>181689756</td>\n",
" <td>NaN</td>\n",
" <td>Thoughts and prayers for NY&lt;EMOJI&gt;🏻 &lt;HASHTAG&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68731</th>\n",
" <td>[💁]</td>\n",
" <td>[#GreatSuccess]</td>\n",
" <td>[@BrianyH]</td>\n",
" <td>2017-11-01 07:23:50</td>\n",
" <td>925624407460057100</td>\n",
" <td>en</td>\n",
" <td>60160788</td>\n",
" <td>9.254610e+17</td>\n",
" <td>&lt;USER&gt; I searched COCK, PENIS, SHLONG, WINKY, ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68732</th>\n",
" <td>[🍃, 🌻, 🌻, 🍃, 🍃, 💐, 💐, 🍃, 🙋]</td>\n",
" <td>[]</td>\n",
" <td>[@amitbarman520]</td>\n",
" <td>2017-11-01 07:23:53</td>\n",
" <td>925624420022063100</td>\n",
" <td>en</td>\n",
" <td>3792290725</td>\n",
" <td>9.256215e+17</td>\n",
" <td>&lt;USER&gt; Thank you so much&lt;EMOJI&gt;&lt;EMOJI&gt;&lt;EMOJI&gt;&lt;...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>68733 rows × 9 columns</p>\n",
"</div>"
],
"text/plain": [
" EMOJI \\\n",
"0 [🔥, 👏] \n",
"1 [🤦] \n",
"2 [😄] \n",
"3 [📷] \n",
"4 [😩, 😩] \n",
"5 [😭, 💓] \n",
"6 [😂] \n",
"7 [💯] \n",
"8 [🙄] \n",
"9 [😟, 😥, 😢] \n",
"10 [🌻] \n",
"11 [🍁, 🌺, 🍂] \n",
"12 [🍃] \n",
"13 [💭, 🤦] \n",
"14 [😍, 😘] \n",
"15 [😜] \n",
"16 [😂, 🔥] \n",
"17 [💕] \n",
"18 [😉] \n",
"19 [👅] \n",
"20 [👌, 🙂] \n",
"21 [🤗, 📺] \n",
"22 [💯] \n",
"23 [👅, 💦, 🍑] \n",
"24 [💔] \n",
"25 [🤐, 🤐, 🤐] \n",
"26 [😴] \n",
"27 [😂] \n",
"28 [😂, 🙄] \n",
"29 [🎉, 🎂, 🎈, 🎊, 🎁, 💜] \n",
"... ... \n",
"68703 [😕] \n",
"68704 [😂, 😩] \n",
"68705 [😂] \n",
"68706 [💖] \n",
"68707 [🌆, 👉, 🚖, 📞] \n",
"68708 [😁] \n",
"68709 [😋] \n",
"68710 [👌, 🎃, 😘] \n",
"68711 [👍] \n",
"68712 [😭] \n",
"68713 [😂] \n",
"68714 [😭, 😭, 💘] \n",
"68715 [😫, ✋] \n",
"68716 [😂, 🙁] \n",
"68717 [😭] \n",
"68718 [😢, 💔] \n",
"68719 [🙃] \n",
"68720 [😂, 😂, 😂, 😂, 😂] \n",
"68721 [👌, 👊, 🙌] \n",
"68722 [😴] \n",
"68723 [😂, 😂, 😂, 😂] \n",
"68724 [😀] \n",
"68725 [😎] \n",
"68726 [✨] \n",
"68727 [🤷] \n",
"68728 [😘] \n",
"68729 [😂] \n",
"68730 [🙏] \n",
"68731 [💁] \n",
"68732 [🍃, 🌻, 🌻, 🍃, 🍃, 💐, 💐, 🍃, 🙋] \n",
"\n",
" HASHTAGS \\\n",
"0 [] \n",
"1 [] \n",
"2 [] \n",
"3 [] \n",
"4 [] \n",
"5 [] \n",
"6 [] \n",
"7 [] \n",
"8 [] \n",
"9 [] \n",
"10 [] \n",
"11 [] \n",
"12 [#mortdale, #partofthefamily, #gorgeousboy] \n",
"13 [] \n",
"14 [#7YearsOfKMH2] \n",
"15 [] \n",
"16 [] \n",
"17 [] \n",
"18 [] \n",
"19 [#footfetishnation] \n",
"20 [] \n",
"21 [] \n",
"22 [] \n",
"23 [] \n",
"24 [] \n",
"25 [] \n",
"26 [] \n",
"27 [] \n",
"28 [] \n",
"29 [] \n",
"... ... \n",
"68703 [#halloweencostumes] \n",
"68704 [] \n",
"68705 [#MUFC] \n",
"68706 [] \n",
"68707 [#BurkeCentre] \n",
"68708 [] \n",
"68709 [] \n",
"68710 [#portlandoregon, #portlandhalloween, #carrie…] \n",
"68711 [] \n",
"68712 [] \n",
"68713 [] \n",
"68714 [] \n",
"68715 [] \n",
"68716 [] \n",
"68717 [] \n",
"68718 [] \n",
"68719 [] \n",
"68720 [] \n",
"68721 [] \n",
"68722 [#WednesdayWisdom] \n",
"68723 [] \n",
"68724 [] \n",
"68725 [] \n",
"68726 [] \n",
"68727 [] \n",
"68728 [] \n",
"68729 [] \n",
"68730 [#NYCStrong] \n",
"68731 [#GreatSuccess] \n",
"68732 [] \n",
"\n",
" LINKED_USER datetime \\\n",
"0 [] 2017-11-01 13:29:00 \n",
"1 [] 2017-11-01 13:29:00 \n",
"2 [] 2017-11-01 13:29:03 \n",
"3 [] 2017-11-01 13:29:04 \n",
"4 [@hiphopphiIes] 2017-11-01 13:29:06 \n",
"5 [@WizMommma] 2017-11-01 13:29:02 \n",
"6 [] 2017-11-01 13:29:05 \n",
"7 [] 2017-11-01 13:29:07 \n",
"8 [@SeaDimon, @lsarsour] 2017-11-01 13:29:09 \n",
"9 [@Ian_khetye] 2017-11-01 13:29:10 \n",
"10 [] 2017-11-01 13:29:13 \n",
"11 [@Dimafadma] 2017-11-01 13:29:15 \n",
"12 [] 2017-11-01 13:29:16 \n",
"13 [] 2017-11-01 13:29:20 \n",
"14 [] 2017-11-01 13:29:20 \n",
"15 [] 2017-11-01 13:29:22 \n",
"16 [] 2017-11-01 13:29:23 \n",
"17 [@yungbabytate] 2017-11-01 13:29:23 \n",
"18 [@cmckenney] 2017-11-01 13:29:23 \n",
"19 [] 2017-11-01 13:29:25 \n",
"20 [] 2017-11-01 13:29:25 \n",
"21 [] 2017-11-01 13:29:26 \n",
"22 [] 2017-11-01 13:29:26 \n",
"23 [@ctrlpurp] 2017-11-01 13:29:29 \n",
"24 [@saunders_court1] 2017-11-01 13:29:30 \n",
"25 [] 2017-11-01 13:29:31 \n",
"26 [] 2017-11-01 13:29:32 \n",
"27 [@xxxtentacion] 2017-11-01 13:29:35 \n",
"28 [] 2017-11-01 13:29:35 \n",
"29 [@justinerooney_] 2017-11-01 13:29:37 \n",
"... ... ... \n",
"68703 [] 2017-11-01 07:23:04 \n",
"68704 [] 2017-11-01 07:23:05 \n",
"68705 [] 2017-11-01 07:23:06 \n",
"68706 [] 2017-11-01 07:23:07 \n",
"68707 [] 2017-11-01 07:23:18 \n",
"68708 [@mychosliaheart, @BarrettoJulia, @iamjoshuaga... 2017-11-01 07:23:18 \n",
"68709 [] 2017-11-01 07:23:24 \n",
"68710 [] 2017-11-01 07:23:24 \n",
"68711 [@8limbsbondi...] 2017-11-01 07:23:26 \n",
"68712 [] 2017-11-01 07:23:27 \n",
"68713 [@rfrandrea, @AdaaanAndyyy] 2017-11-01 07:23:30 \n",
"68714 [@peachshua1230] 2017-11-01 07:23:31 \n",
"68715 [] 2017-11-01 07:23:34 \n",
"68716 [] 2017-11-01 07:23:34 \n",
"68717 [@BeachBoy_Gab] 2017-11-01 07:23:34 \n",
"68718 [] 2017-11-01 07:23:34 \n",
"68719 [] 2017-11-01 07:23:35 \n",
"68720 [] 2017-11-01 07:23:36 \n",
"68721 [] 2017-11-01 07:23:37 \n",
"68722 [] 2017-11-01 07:23:41 \n",
"68723 [@Louis_Tomlinson, @NiallOfficial] 2017-11-01 07:23:44 \n",
"68724 [] 2017-11-01 07:23:45 \n",
"68725 [] 2017-11-01 07:23:45 \n",
"68726 [] 2017-11-01 07:23:46 \n",
"68727 [] 2017-11-01 07:23:46 \n",
"68728 [] 2017-11-01 07:23:46 \n",
"68729 [@discopiggu] 2017-11-01 07:23:46 \n",
"68730 [] 2017-11-01 07:23:50 \n",
"68731 [@BrianyH] 2017-11-01 07:23:50 \n",
"68732 [@amitbarman520] 2017-11-01 07:23:53 \n",
"\n",
" id lang person reply_to \\\n",
"0 925716304635547600 en 31507978 NaN \n",
"1 925716304664911900 en 231994649 NaN \n",
"2 925716317214089200 en 2592765104 NaN \n",
"3 925716321416949800 en 278737933 NaN \n",
"4 925716329801310200 en 824586253634981900 9.257162e+17 \n",
"5 925716313019965400 en 1581953814 9.257088e+17 \n",
"6 925716325607133200 en 1001999683 NaN \n",
"7 925716334008082400 en 745222369183043600 NaN \n",
"8 925716342401052700 en 798557155217539100 9.257147e+17 \n",
"9 925716346570240000 en 744396039126421500 9.250629e+17 \n",
"10 925716359182520300 en 721490010118205400 8.965900e+17 \n",
"11 925716367558545400 en 520536723 9.257159e+17 \n",
"12 925716371735900200 en 850852815941517300 NaN \n",
"13 925716388513230800 en 914145041588867100 NaN \n",
"14 925716388525645800 en 2425405622 NaN \n",
"15 925716396931240000 en 4614871873 NaN \n",
"16 925716401125331000 en 2831608345 NaN \n",
"17 925716401133948900 en 788571974633009200 9.255778e+17 \n",
"18 925716401125544000 en 218307802 9.257115e+17 \n",
"19 925716409489002500 en 885261166146179100 NaN \n",
"20 925716409497272300 en 831437760833609700 NaN \n",
"21 925716413699854300 en 231664542 NaN \n",
"22 925716413679009800 en 3196847035 NaN \n",
"23 925716426278735900 en 918492858352635900 9.257161e+17 \n",
"24 925716430473039900 en 3471187337 9.257163e+17 \n",
"25 925716434667184100 en 780060488600199200 NaN \n",
"26 925716438853345300 en 388380690 NaN \n",
"27 925716451457163300 en 899320696869974000 NaN \n",
"28 925716451461357600 en 784790670 NaN \n",
"29 925716459828936700 en 3051266655 NaN \n",
"... ... ... ... ... \n",
"68703 925624214522036200 en 1672876458 NaN \n",
"68704 925624218682777600 en 382473866 NaN \n",
"68705 925624222889766900 en 893145405457911800 NaN \n",
"68706 925624227088121900 en 240378516 NaN \n",
"68707 925624273237983200 en 784620573209002000 NaN \n",
"68708 925624273212805100 en 170998187 9.254136e+17 \n",
"68709 925624298395533300 en 1348667816 NaN \n",
"68710 925624298378801200 en 722481645765300200 NaN \n",
"68711 925624306779897900 en 2443251500 NaN \n",
"68712 925624310974136300 en 2406186390 NaN \n",
"68713 925624323557146600 en 1039448149 9.256150e+17 \n",
"68714 925624327755591700 en 845085544589672400 9.256009e+17 \n",
"68715 925624340342812700 en 924752524871131100 NaN \n",
"68716 925624340355280900 en 419493819 NaN \n",
"68717 925624340346937300 en 2457745952 9.256219e+17 \n",
"68718 925624340338507800 en 1955767531 NaN \n",
"68719 925624344524361700 en 796490344581898200 NaN \n",
"68720 925624348710285300 en 907808317124177900 NaN \n",
"68721 925624352929910800 en 262162415 NaN \n",
"68722 925624369715515400 en 574882525 NaN \n",
"68723 925624382269124600 en 556175173 9.254038e+17 \n",
"68724 925624386455031800 en 1610265588 NaN \n",
"68725 925624386454937600 en 4760724450 NaN \n",
"68726 925624390657572900 en 882858115636514800 NaN \n",
"68727 925624390682849300 en 188129628 NaN \n",
"68728 925624390666129400 en 2473135939 NaN \n",
"68729 925624390670106600 en 2373584209 9.256241e+17 \n",
"68730 925624407459971100 en 181689756 NaN \n",
"68731 925624407460057100 en 60160788 9.254610e+17 \n",
"68732 925624420022063100 en 3792290725 9.256215e+17 \n",
"\n",
" text \n",
"0 fashionbombdaily's photo <EMOJI><EMOJI>🏼 \n",
"1 Its scary how on point my horoscope be <EMOJI... \n",
"2 Woooaaaahhh <EMOJI> \n",
"3 <EMOJI> vivalcli: Portraits by Zhao Guojing an... \n",
"4 <USER> i wanna know too<EMOJI><EMOJI> \n",
"5 <USER> veda was yoda too <EMOJI><EMOJI> \n",
"6 Im less stressed about turning 30 now <EMOJI>... \n",
"7 Full charged. <EMOJI> \n",
"8 <USER> Thats part of the problem, (they) <USE... \n",
"9 <USER> got me emotional there<EMOJI><EMOJI><EM... \n",
"10 back to the yellow <EMOJI> \n",
"11 <USER> Happy month to you and your loved ones ... \n",
"12 Maxx and Patricia. Family hangs at For Good He... \n",
"13 I need to STOP beating myself up with my thoug... \n",
"14 Cutest Son <EMOJI>Roll no. 31 <EMOJI> <HASHTAG> \n",
"15 By the summer I should have everything up and ... \n",
"16 I know my English is not that good but that do... \n",
"17 <USER> I <EMOJI> u mama \n",
"18 <USER> That picture was NOT taken this morning... \n",
"19 Welcome to <HASHTAG> <EMOJI> \n",
"20 Awkward <EMOJI><EMOJI> \n",
"21 back at it with supernatural <EMOJI><EMOJI> \n",
"22 One of the best things I've learned was to sto... \n",
"23 <USER> Can I taste?<EMOJI><EMOJI><EMOJI> \n",
"24 <USER> we miss you ☹️<EMOJI> \n",
"25 Actually my bias in WJSN are Eunseo &amp; Bona... \n",
"26 I so cannot be bothered with the rest of the d... \n",
"27 <USER> 2lit4life<EMOJI> \n",
"28 Im not stop saying that!<EMOJI><EMOJI> \n",
"29 <USER> HAPPY BIHDAY <EMOJI><EMOJI><EMOJI><EMOJ... \n",
"... ... \n",
"68703 <HASHTAG> this one falls under the weird crazy... \n",
"68704 I'm not allowed to have chocolates yet, then I... \n",
"68705 Manchester United manager Mourinho slams 'spec... \n",
"68706 <EMOJI> en Bushwhick \n",
"68707 : <HASHTAG> <EMOJI> <EMOJI><EMOJI> For Taxi <E... \n",
"68708 <USER> <USER> <USER> Look, Mammeh and Daddeh! ... \n",
"68709 Life is so good with you <EMOJI> \n",
"68710 Happy Halloween! <EMOJI>🏽<EMOJI><EMOJI> <HASHT... \n",
"68711 Some work on the ropes in todays boxing class... \n",
"68712 Scotty and Kristens halloween costumes <EMOJI> \n",
"68713 <USER> <USER> May pre-month celebration sis <E... \n",
"68714 <USER> Awww <EMOJI> Ajsksjdjd im smiling like ... \n",
"68715 I hate when I send a text or snap n I'm so anx... \n",
"68716 The answer is no I have no plans and I never l... \n",
"68717 <USER> LMAOOO I'm so proud <EMOJI> \n",
"68718 My cousin/little sister is leaving to San Fran... \n",
"68719 Can't be alone w my thoughts tonight so just g... \n",
"68720 <EMOJI><EMOJI><EMOJI><EMOJI><EMOJI> ambot!!! \n",
"68721 <EMOJI>🏽<EMOJI>🏽 1st of the month!!Happy 1st o... \n",
"68722 <HASHTAG> ... stay in bed <EMOJI> \n",
"68723 <USER> <USER> THIS IS GOLD. GOLD. <EMOJI><EMOJ... \n",
"68724 <EMOJI> thank you for the kind compliment \n",
"68725 Enjoyed the silence <EMOJI> \n",
"68726 OS: Spiderman Homecoming <EMOJI> \n",
"68727 Go to hell <EMOJI>🏽‍♀️ \n",
"68728 Thank you Yomi! <EMOJI> \n",
"68729 <USER> Lol. Just enjoy the stars. Music Kidhar... \n",
"68730 Thoughts and prayers for NY<EMOJI>🏻 <HASHTAG> \n",
"68731 <USER> I searched COCK, PENIS, SHLONG, WINKY, ... \n",
"68732 <USER> Thank you so much<EMOJI><EMOJI><EMOJI><... \n",
"\n",
"[68733 rows x 9 columns]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"twitter_data = pd.read_json(json_files[0], encoding=\"utf-8\")\n",
"twitter_data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* extracting emojis and text"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"emojis = twitter_data['EMOJI']\n",
"plain_text = twitter_data['text']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* make our plain text more \"plain\":\n",
" * removing the keyword `<EMOJI>` (just for the beginning)\n",
" * removing remaining useless emojis, like skin modifier etc."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# defining blacklist for modifier emojis:\n",
"emoji_blacklist = set([\n",
" chr(0x1F3FB),\n",
" chr(0x1F3FC),\n",
" chr(0x1F3FD),\n",
" chr(0x1F3FE),\n",
" chr(0x1F3FF),\n",
" chr(0x2642),\n",
" chr(0x2640)\n",
"])"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# filtering them and the EMOJI keyword out:\n",
"plain_text = plain_text.str.replace(\"<EMOJI>\",\"\").str.replace(\"[\" + \"\".join(list(emoji_blacklist)) + \"]\",\"\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* trying a multi label vectorizer"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"def latest(lst):\n",
" return lst[-1] if len(lst) > 0 else 'X' \n",
"def most_common(lst):\n",
" # trying to find the most common used emoji in the given lst\n",
" return max(set(lst), key=lst.count) if len(lst) > 0 else \"X\" # setting label to 'X' if there is an empty emoji list"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"mlb_multi = MultiLabelBinarizer()\n",
"mlb_single = MultiLabelBinarizer()\n",
"\n",
"multi_labels = mlb_multi.fit_transform(emojis)\n",
"single_labels = mlb_single.fit_transform(np.array([latest(x) for x in emojis]))\n",
"\n",
"mlb = mlb_single if SINGLE_LABEL else mlb_multi\n",
"labels = single_labels if SINGLE_LABEL else multi_labels"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* generate weights:"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# at first count over our table\n",
"emoji_count = {}\n",
"\n",
"\n",
"for e_list in emojis:\n",
" for e in set(e_list):\n",
" if e not in emoji_count:\n",
" emoji_count[e] = 0\n",
" emoji_count[e] += 1\n",
"\n",
"emoji_count\n",
"emoji_sum = sum([emoji_count[e] for e in emoji_count])\n",
"\n",
"emoji_weights = {}\n",
"for e in emoji_count:\n",
" # tfidf for emojis\n",
" emoji_weights[e] = np.log((emoji_sum / emoji_count[e]))\n",
"\n",
"weights_sum= sum([emoji_weights[x] for x in emoji_weights])\n",
" \n",
"# normalize:\n",
"for e in emoji_weights:\n",
" emoji_weights[e] = emoji_weights[e] / weights_sum\n",
"\n",
"emoji_weights['X'] = 0 # dummy values\n",
"emoji_count['X'] = 0"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* generating train and test set:"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"X1, Xt1, y1, yt1 = train_test_split(plain_text, labels, test_size=0.1, random_state=4222)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"y1_weights = np.array([(sum([emoji_weights[e] for e in e_list]) / len(e_list)) if len(e_list) > 0 else 0 for e_list in mlb.inverse_transform(y1)])"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"vectorizer = TfidfVectorizer(stop_words='english')\n",
"vec_train = vectorizer.fit_transform(X1)\n",
"vec_test = vectorizer.transform(Xt1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* train. this can take a very long time..."
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/jonas/.local/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
" from ._conv import register_converters as _register_converters\n",
"Using TensorFlow backend.\n"
]
}
],
"source": [
"from sklearn.neural_network import MLPClassifier as MLP\n",
"from sklearn.multiclass import OneVsRestClassifier as OVRC\n",
"from sklearn.tree import DecisionTreeClassifier as DTC\n",
"\n",
"from keras.models import Sequential\n",
"from keras.layers import Dense"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"def train(max_size = 10000, layers=[(1024, 'relu'),(y1[0].shape[0],'softmax')], random_state=4222, ovrc=False, n_iter=5):\n",
" \n",
" model = Sequential()\n",
" \n",
" # build mlp layers:\n",
" keras_layers = []\n",
" first_layer = True\n",
" for layer in layers:\n",
" if first_layer:\n",
" model.add(Dense(units=layer[0], activation=layer[1], input_dim=vectorizer.transform([\" \"])[0]._shape[1]))\n",
" first_layer = False\n",
" else:\n",
" model.add(Dense(units=layer[0], activation=layer[1]))\n",
" \n",
" #mlp = MLPClassifier(layers=sknn_layers, random_state=random_state, verbose=True, n_iter=n_iter, batch_size=100)\n",
" \n",
" model.compile(loss='categorical_crossentropy',\n",
" optimizer='sgd',\n",
" metrics=['accuracy'])\n",
" \n",
" clf = OVRC(model) if ovrc else model\n",
"\n",
" clf.fit(vec_train[:max_size].A, y1[:max_size], validation_split=0.2, sample_weight=y1_weights[:max_size])\n",
" \n",
" return clf"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train on 8000 samples, validate on 2000 samples\n",
"Epoch 1/1\n",
"8000/8000 [==============================] - 109s 14ms/step - loss: 0.0042 - acc: 0.0012 - val_loss: 0.0042 - val_acc: 0.0020\n"
]
}
],
"source": [
"clf = train(max_size=10000,layers=[(1200, 'relu'),(1200,'relu'),(y1[0].shape[0],'softmax')])"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"62691 <USER> I just finished mine I was extremely ne...\n",
"9959 <USER> <USER> <USER> Kinda Gross but yup it's ...\n",
"39726 Treating myself to a manicure because even une...\n",
"20883 Sarfraz Done it.Congrats.Pakistan Rules the Wo...\n",
"2705 I turn 20 in Just over a month and Ive never ...\n",
"20766 <USER> The coolest &amp; beautiful duo ever ❤❤\n",
"13242 <USER> Studying abroad in Italy for 3 weeks i...\n",
"32951 You're nice to meeeeee thanks I appreciate that \n",
"7297 <USER> hahahha it kinda does look like me \n",
"10913 <HASHTAG> Ya Rasulullah.,You are the Messenger...\n",
"58664 <USER> crying\n",
"28113 Man my Dad crazy but I miss his Bok Choi soup ...\n",
"20698 <USER> <USER> <USER> Well done!!\n",
"45787 Mi mess\n",
"36076 <USER> schooling all the <HASHTAG> \n",
"66970 <USER> Awww but Im sure your man can \n",
"34787 TWEET using the hashtag...<HASHTAG> is the rel...\n",
"9746 Nation is lost y NS boosting tat he will appea...\n",
"64458 <USER> <USER> <USER> <USER> <USER> <USER> <USE...\n",
"9367 I got two test Monday only thing I can do is ...\n",
"29512 <USER> Video dinner medic \n",
"63868 <USER> He wouldn't expect anything less \n",
"7878 Looking for an <HASHTAG> ASAP?🕰Check out our ...\n",
"42253 Cuddled up in a hoodie and fuzzy socks. \n",
"32650 Too true the Buble <HASHTAG> album is out and...\n",
"58945 Woke up late again \n",
"60382 <USER> Damn g well mfs glad you out take adva...\n",
"37224 +<HASHTAG> SATURDAY OFFICIAL CAU VS MOREHOUSE ...\n",
"19488 My back is sore\n",
"36042 Actually, it should be October 31st🕸 vs. Novem...\n",
" ... \n",
"4414 <USER> Absolutely mate \n",
"21768 Running late to pick up the kids, and this tra...\n",
"5359 <USER> Lmao well if you say so \n",
"22550 <USER> <USER> <USER> <USER> <USER> Hardcore \n",
"55252 Click here to watch it: Kane hot office sex i...\n",
"42040 <USER> <USER> <USER> <USER> <USER> <USER> <USE...\n",
"55839 Im always the problem\n",
"25015 <USER> And brother thanks\n",
"19063 <USER> yes Haley \n",
"477 <HASHTAG> Our differences are the real treasur...\n",
"41045 <USER> I just took a two hour nap instead of d...\n",
"52270 Some guy full on grabbed my ass last night whe...\n",
"52102 Can't ever do anything for myself. \n",
"29210 OMFG SHES SO BEAUTIFUL \n",
"2131 Check out what I'm selling on my <USER> shop \n",
"2912 My shordy b boostin \n",
"64797 I pray my nieces NEVER feel this type of hurt ...\n",
"63632 <USER> I should definitely go to sleep and rea...\n",
"30426 Texas asf \n",
"68567 <USER> annyeong! if you have time kindly check...\n",
"61825 He melts me! I want him to stay this small for...\n",
"8057 Sorry Not Sorry By <HASHTAG> is Track 13 on <H...\n",
"57118 <USER> I liked it too \n",
"18808 A mansion gap, maybe \n",
"64643 Happy halloween \n",
"34804 Where is a Civil Rights Lawyer ready to help t...\n",
"62123 I keep having dreams that my family come and v...\n",
"18325 <USER> # May this day bring countless happines...\n",
"66916 Happy Halloween \n",
"63618 This is what happens when I finish a painting \n",
"Name: text, Length: 61859, dtype: object"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* make a prediction and store it in a csv file:"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"pred = clf.predict(vectorizer.transform(Xt1))"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0.00124256, 0.00124216, 0.00123592, ..., 0.00123677, 0.00123611,\n",
" 0.00123534],\n",
" [0.00124442, 0.00123547, 0.00123502, ..., 0.00123892, 0.00123958,\n",
" 0.00123556],\n",
" [0.00124413, 0.00123538, 0.00124574, ..., 0.00123829, 0.00123556,\n",
" 0.00123374],\n",
" ...,\n",
" [0.00123915, 0.00123915, 0.00123916, ..., 0.00123915, 0.00123916,\n",
" 0.00123915],\n",
" [0.00124084, 0.00124438, 0.00123832, ..., 0.00123602, 0.00125055,\n",
" 0.00123963],\n",
" [0.00124321, 0.0012361 , 0.00123488, ..., 0.00123589, 0.00124259,\n",
" 0.00123691]], dtype=float32)"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pred"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"binary_pred = np.zeros_like(pred)\n",
"binary_pred[np.arange(len(pred)), pred.argmax(1)] = 1 "
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0., 0., 0., ..., 0., 0., 0.],\n",
" [0., 0., 0., ..., 0., 0., 0.],\n",
" [0., 0., 0., ..., 0., 0., 0.]], dtype=float32)"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"binary_pred[[0,1,2]]"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
"# build a dataframe to visualize test results:\n",
"testlist = pd.DataFrame({'text': Xt1, 'teacher': (mlb_single if SINGLE_LABEL else mlb).inverse_transform(yt1), 'predict': (mlb_single if SINGLE_LABEL else mlb).inverse_transform(binary_pred)})"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>predict</th>\n",
" <th>teacher</th>\n",
" <th>text</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>15278</th>\n",
" <td>(🌠,)</td>\n",
" <td>(😅,)</td>\n",
" <td>&lt;USER&gt; &lt;USER&gt; 2 years? ✌</td>\n",
" </tr>\n",
" <tr>\n",
" <th>36882</th>\n",
" <td>(🕔,)</td>\n",
" <td>(😂,)</td>\n",
" <td>tell me why this is me everyday</td>\n",
" </tr>\n",
" <tr>\n",
" <th>65543</th>\n",
" <td>(🌍,)</td>\n",
" <td>(📌,)</td>\n",
" <td>please follow us ::Twitter ▶️ ▶️ ▶MARSHMALL...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>65893</th>\n",
" <td>(😂,)</td>\n",
" <td>(🔝,)</td>\n",
" <td>This</td>\n",
" </tr>\n",
" <tr>\n",
" <th>55496</th>\n",
" <td>(🎳,)</td>\n",
" <td>(😍,)</td>\n",
" <td>&lt;USER&gt; Im in love</td>\n",
" </tr>\n",
" <tr>\n",
" <th>61997</th>\n",
" <td>(🌍,)</td>\n",
" <td>(🌸,)</td>\n",
" <td>&lt;USER&gt; Miss you gemmthankyou sooo much❤❤</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15819</th>\n",
" <td>(🔹,)</td>\n",
" <td>(😂,)</td>\n",
" <td>Me as a parent</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21340</th>\n",
" <td>(🌑,)</td>\n",
" <td>(😂,)</td>\n",
" <td>Really betting my manager rn for tonights game</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26691</th>\n",
" <td>(🎳,)</td>\n",
" <td>(😩,)</td>\n",
" <td>Y ES IM A BAD BOY SO I LIKE BAD GIRL</td>\n",
" </tr>\n",
" <tr>\n",
" <th>57025</th>\n",
" <td>(🌷,)</td>\n",
" <td>(😃,)</td>\n",
" <td>&lt;USER&gt; Just downloaded to my fire stick over ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17967</th>\n",
" <td>(🐔,)</td>\n",
" <td>(😍,)</td>\n",
" <td>&lt;USER&gt; Love this ! Hollywood is the man</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68555</th>\n",
" <td>(🌑,)</td>\n",
" <td>(😉,)</td>\n",
" <td>&lt;USER&gt; Absolutely but if it had been a banana ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20784</th>\n",
" <td>(💁,)</td>\n",
" <td>(🐻,)</td>\n",
" <td>La Grasaaaaaaaaa Reverse Shatter Back Board S...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68300</th>\n",
" <td>(🥣,)</td>\n",
" <td>(😍,)</td>\n",
" <td>I go to New York next month ahhhhhh</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4659</th>\n",
" <td>(💍,)</td>\n",
" <td>(😭,)</td>\n",
" <td>&lt;USER&gt; Im trying to enjoy it as much as the f...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>66706</th>\n",
" <td>(🌕,)</td>\n",
" <td>(📞,)</td>\n",
" <td>: Salamander Resort &lt;HASHTAG&gt; 🍽️ For Taxi 70...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>47510</th>\n",
" <td>(🎄,)</td>\n",
" <td>(👉,)</td>\n",
" <td>For your actions there WILL be consequences. Y...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>55294</th>\n",
" <td>(😾,)</td>\n",
" <td>(😂,)</td>\n",
" <td>&lt;USER&gt; Omg my cousin charging 40</td>\n",
" </tr>\n",
" <tr>\n",
" <th>621</th>\n",
" <td>(🌍,)</td>\n",
" <td>(🤦,)</td>\n",
" <td>Zoey daycare lets her do whatever she want, I ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>31011</th>\n",
" <td>(😌,)</td>\n",
" <td>(😀,)</td>\n",
" <td>yeah! ✌️</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30659</th>\n",
" <td>(🐎,)</td>\n",
" <td>(💪,)</td>\n",
" <td>This was so much I mean SO MUCH over due for t...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>66284</th>\n",
" <td>(🤔,)</td>\n",
" <td>(🙂,)</td>\n",
" <td>Parent contact booking is now open! Please fol...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>66758</th>\n",
" <td>(🎄,)</td>\n",
" <td>(😥,)</td>\n",
" <td>&lt;USER&gt; OCONUS we dont have the Turkey Day buf...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13456</th>\n",
" <td>(🌠,)</td>\n",
" <td>(💕,)</td>\n",
" <td>Dems realtor business partners have lots of ni...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15057</th>\n",
" <td>(🥣,)</td>\n",
" <td>(😂,)</td>\n",
" <td>Ready for the dodgers fans excuses</td>\n",
" </tr>\n",
" <tr>\n",
" <th>188</th>\n",
" <td>(🎄,)</td>\n",
" <td>(🎉,)</td>\n",
" <td>&lt;USER&gt; Happy Birthday Angge</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5054</th>\n",
" <td>(🎄,)</td>\n",
" <td>(😂,)</td>\n",
" <td>&lt;USER&gt; &lt;USER&gt; Lawsuit</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18099</th>\n",
" <td>(👃,)</td>\n",
" <td>(😤,)</td>\n",
" <td>Finna roll this up no excuses</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17120</th>\n",
" <td>(🌍,)</td>\n",
" <td>(⚡,)</td>\n",
" <td>But its forever fuck em and keep it gutta </td>\n",
" </tr>\n",
" <tr>\n",
" <th>14552</th>\n",
" <td>(📖,)</td>\n",
" <td>(😍,)</td>\n",
" <td>I just need to hubby a hockey player up</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21819</th>\n",
" <td>(🎄,)</td>\n",
" <td>(😂,)</td>\n",
" <td>Niggas funny af</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18460</th>\n",
" <td>(♿,)</td>\n",
" <td>(💁,)</td>\n",
" <td>1. Dont EVER disrespect Thanksgiving cuz yo f...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>60291</th>\n",
" <td>(🚮,)</td>\n",
" <td>(💘,)</td>\n",
" <td>happy bday lexi &lt;USER&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22623</th>\n",
" <td>(🔖,)</td>\n",
" <td>(😩,)</td>\n",
" <td>Mr.Lazaro said “theres my girls” when he seen...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>87</th>\n",
" <td>(🌍,)</td>\n",
" <td>(🎈,)</td>\n",
" <td>Happy Birthday Blake!!!! I hope you have an am...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2884</th>\n",
" <td>(🏄,)</td>\n",
" <td>(😉,)</td>\n",
" <td>&lt;USER&gt; This would be a good time to do a Week ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30212</th>\n",
" <td>(🧘,)</td>\n",
" <td>(📌,)</td>\n",
" <td>&lt;USER&gt; Done, pls ❤️ y FAV</td>\n",
" </tr>\n",
" <tr>\n",
" <th>55813</th>\n",
" <td>(😾,)</td>\n",
" <td>(😍,)</td>\n",
" <td>There is just something about &lt;USER&gt; &lt;HASHTAG&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11657</th>\n",
" <td>(💚,)</td>\n",
" <td>(😴,)</td>\n",
" <td>&lt;USER&gt; you're brudda!</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18215</th>\n",
" <td>(🐹,)</td>\n",
" <td>(🤷,)</td>\n",
" <td>Not being depressed </td>\n",
" </tr>\n",
" <tr>\n",
" <th>48609</th>\n",
" <td>(🧘,)</td>\n",
" <td>(🤑,)</td>\n",
" <td>&lt;USER&gt; I ❤ you. My woman crush everyday as alw...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16079</th>\n",
" <td>(🥣,)</td>\n",
" <td>(⚓,)</td>\n",
" <td>I added a video to a &lt;USER&gt; playlist 🛳 The ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28380</th>\n",
" <td>(🥣,)</td>\n",
" <td>(😂,)</td>\n",
" <td>Dodgers</td>\n",
" </tr>\n",
" <tr>\n",
" <th>41212</th>\n",
" <td>(🌍,)</td>\n",
" <td>(🔴,)</td>\n",
" <td>[LIVE] on &lt;USER&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>67555</th>\n",
" <td>(🔗,)</td>\n",
" <td>(💞,)</td>\n",
" <td>• &lt;USER&gt; my precious Niya always checking up o...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>45490</th>\n",
" <td>(🕔,)</td>\n",
" <td>(🤷,)</td>\n",
" <td>If you wanna make things right it go both ways </td>\n",
" </tr>\n",
" <tr>\n",
" <th>54052</th>\n",
" <td>(🌍,)</td>\n",
" <td>(😢,)</td>\n",
" <td>Poor baby!!!</td>\n",
" </tr>\n",
" <tr>\n",
" <th>54517</th>\n",
" <td>(🐹,)</td>\n",
" <td>(😚,)</td>\n",
" <td>&lt;USER&gt; happy birthday, hope you have a good day</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24047</th>\n",
" <td>(🌷,)</td>\n",
" <td>(😌,)</td>\n",
" <td>Dont get mad when them haters stare let em lo...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>253</th>\n",
" <td>(🥄,)</td>\n",
" <td>(😎,)</td>\n",
" <td>Sag season right around the corner. 25 on the ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>64707</th>\n",
" <td>(🎸,)</td>\n",
" <td>(😇,)</td>\n",
" <td>&lt;USER&gt; Lets see his costume</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34279</th>\n",
" <td>(🌯,)</td>\n",
" <td>(😥,)</td>\n",
" <td>&lt;USER&gt; I AM NERVOUS!!</td>\n",
" </tr>\n",
" <tr>\n",
" <th>58342</th>\n",
" <td>(🤝,)</td>\n",
" <td>(🙌,)</td>\n",
" <td>&lt;USER&gt; This looks amazing</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16361</th>\n",
" <td>(🎄,)</td>\n",
" <td>(🙌,)</td>\n",
" <td>&lt;USER&gt; &lt;USER&gt; &lt;USER&gt; &lt;USER&gt; &lt;USER&gt; &lt;USER&gt; Shit...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>39069</th>\n",
" <td>(😂,)</td>\n",
" <td>(👇,)</td>\n",
" <td>THIS</td>\n",
" </tr>\n",
" <tr>\n",
" <th>59739</th>\n",
" <td>(🌷,)</td>\n",
" <td>(🐆,)</td>\n",
" <td>I've never consumed a reindeer.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>49140</th>\n",
" <td>(🌕,)</td>\n",
" <td>(🤝,)</td>\n",
" <td>Sales is the heart of business.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>47901</th>\n",
" <td>(😂,)</td>\n",
" <td>(😭,)</td>\n",
" <td>bruuuuhhh</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4241</th>\n",
" <td>(💲,)</td>\n",
" <td>(🎓,)</td>\n",
" <td>&lt;USER&gt; Congratulations ! youve graduated with...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24123</th>\n",
" <td>(➗,)</td>\n",
" <td>(👍,)</td>\n",
" <td>&lt;USER&gt; Your A Rock Star! How You Put Up With ...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>6874 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" predict teacher text\n",
"15278 (🌠,) (😅,) <USER> <USER> 2 years? ✌\n",
"36882 (🕔,) (😂,) tell me why this is me everyday \n",
"65543 (🌍,) (📌,) please follow us ::Twitter ▶️ ▶️ ▶MARSHMALL...\n",
"65893 (😂,) (🔝,) This \n",
"55496 (🎳,) (😍,) <USER> Im in love \n",
"61997 (🌍,) (🌸,) <USER> Miss you gemmthankyou sooo much❤❤\n",
"15819 (🔹,) (😂,) Me as a parent \n",
"21340 (🌑,) (😂,) Really betting my manager rn for tonights game \n",
"26691 (🎳,) (😩,) Y ES IM A BAD BOY SO I LIKE BAD GIRL \n",
"57025 (🌷,) (😃,) <USER> Just downloaded to my fire stick over ...\n",
"17967 (🐔,) (😍,) <USER> Love this ! Hollywood is the man \n",
"68555 (🌑,) (😉,) <USER> Absolutely but if it had been a banana ...\n",
"20784 (💁,) (🐻,) La Grasaaaaaaaaa Reverse Shatter Back Board S...\n",
"68300 (🥣,) (😍,) I go to New York next month ahhhhhh \n",
"4659 (💍,) (😭,) <USER> Im trying to enjoy it as much as the f...\n",
"66706 (🌕,) (📞,) : Salamander Resort <HASHTAG> 🍽️ For Taxi 70...\n",
"47510 (🎄,) (👉,) For your actions there WILL be consequences. Y...\n",
"55294 (😾,) (😂,) <USER> Omg my cousin charging 40 \n",
"621 (🌍,) (🤦,) Zoey daycare lets her do whatever she want, I ...\n",
"31011 (😌,) (😀,) yeah! ✌️ \n",
"30659 (🐎,) (💪,) This was so much I mean SO MUCH over due for t...\n",
"66284 (🤔,) (🙂,) Parent contact booking is now open! Please fol...\n",
"66758 (🎄,) (😥,) <USER> OCONUS we dont have the Turkey Day buf...\n",
"13456 (🌠,) (💕,) Dems realtor business partners have lots of ni...\n",
"15057 (🥣,) (😂,) Ready for the dodgers fans excuses \n",
"188 (🎄,) (🎉,) <USER> Happy Birthday Angge \n",
"5054 (🎄,) (😂,) <USER> <USER> Lawsuit \n",
"18099 (👃,) (😤,) Finna roll this up no excuses \n",
"17120 (🌍,) (⚡,) But its forever fuck em and keep it gutta \n",
"14552 (📖,) (😍,) I just need to hubby a hockey player up \n",
"... ... ... ...\n",
"21819 (🎄,) (😂,) Niggas funny af \n",
"18460 (♿,) (💁,) 1. Dont EVER disrespect Thanksgiving cuz yo f...\n",
"60291 (🚮,) (💘,) happy bday lexi <USER>\n",
"22623 (🔖,) (😩,) Mr.Lazaro said “theres my girls” when he seen...\n",
"87 (🌍,) (🎈,) Happy Birthday Blake!!!! I hope you have an am...\n",
"2884 (🏄,) (😉,) <USER> This would be a good time to do a Week ...\n",
"30212 (🧘,) (📌,) <USER> Done, pls ❤️ y FAV\n",
"55813 (😾,) (😍,) There is just something about <USER> <HASHTAG>\n",
"11657 (💚,) (😴,) <USER> you're brudda!\n",
"18215 (🐹,) (🤷,) Not being depressed \n",
"48609 (🧘,) (🤑,) <USER> I ❤ you. My woman crush everyday as alw...\n",
"16079 (🥣,) (⚓,) I added a video to a <USER> playlist 🛳 The ...\n",
"28380 (🥣,) (😂,) Dodgers \n",
"41212 (🌍,) (🔴,) [LIVE] on <USER> \n",
"67555 (🔗,) (💞,) • <USER> my precious Niya always checking up o...\n",
"45490 (🕔,) (🤷,) If you wanna make things right it go both ways \n",
"54052 (🌍,) (😢,) Poor baby!!! \n",
"54517 (🐹,) (😚,) <USER> happy birthday, hope you have a good day\n",
"24047 (🌷,) (😌,) Dont get mad when them haters stare let em lo...\n",
"253 (🥄,) (😎,) Sag season right around the corner. 25 on the ...\n",
"64707 (🎸,) (😇,) <USER> Lets see his costume \n",
"34279 (🌯,) (😥,) <USER> I AM NERVOUS!!\n",
"58342 (🤝,) (🙌,) <USER> This looks amazing \n",
"16361 (🎄,) (🙌,) <USER> <USER> <USER> <USER> <USER> <USER> Shit...\n",
"39069 (😂,) (👇,) THIS \n",
"59739 (🌷,) (🐆,) I've never consumed a reindeer. \n",
"49140 (🌕,) (🤝,) Sales is the heart of business. \n",
"47901 (😂,) (😭,) bruuuuhhh \n",
"4241 (💲,) (🎓,) <USER> Congratulations ! youve graduated with...\n",
"24123 (➗,) (👍,) <USER> Your A Rock Star! How You Put Up With ...\n",
"\n",
"[6874 rows x 3 columns]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"display(testlist)\n"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"testlist.to_csv('test.csv')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* a simple output widget for testing:"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ba20ba113dff4af0b14ea6a6e666e521",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Text</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Text(value='')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f3af634eb2e64822921b57848e032dcf",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>VBox</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"VBox(children=(Button(description='get smiley', icon='check', style=ButtonStyle(), tooltip='Click me'), Output()))"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"out = widgets.Output()\n",
"\n",
"t = widgets.Text()\n",
"b = widgets.Button(\n",
" description='get smiley',\n",
" disabled=False,\n",
" button_style='', # 'success', 'info', 'warning', 'danger' or ''\n",
" tooltip='Click me',\n",
" icon='check'\n",
")\n",
"\n",
"\n",
"\n",
"def handle_submit(sender):\n",
" with out:\n",
" clear_output()\n",
" with out:\n",
" pred = clf.predict(vectorizer.transform([t.value]))\n",
" \n",
" #binary_pred = np.zeros_like(pred)\n",
" #binary_pred[np.arange(len(pred)), pred.argmax(1)] = 1\n",
" \n",
" binary_pred = []\n",
" \n",
" s = np.argsort(pred[0])[-5:]\n",
" \n",
" for i in s:\n",
" b = np.zeros_like(pred[0])\n",
" b[i] = 1\n",
" binary_pred.append(b)\n",
" \n",
" binary_pred = np.array(binary_pred)\n",
" \n",
" display(Markdown(\"# \" + str((mlb_single if SINGLE_LABEL else mlb).inverse_transform(binary_pred))))\n",
"\n",
"b.on_click(handle_submit)\n",
" \n",
"display(t)\n",
"display(widgets.VBox([b, out])) "
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.9991493705341953\n",
"15\n"
]
}
],
"source": [
"import numpy as np\n",
"\n",
"y_trans = mlb.inverse_transform(yt1)\n",
"pred_trans = mlb.inverse_transform(yt1)\n",
"\n",
"# evaluate accuracy\n",
"pos = 0\n",
"neg = 0\n",
"all = 0\n",
"for entry in range(len(y_trans)):\n",
" if len(np.intersect1d(y_trans[entry], pred_trans[entry])) > 0:\n",
" pos += 1\n",
" else:\n",
" neg += 1\n",
" all += 1\n",
"print(pos/all)\n",
"print(neg)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}