simple twitter approach

This commit is contained in:
Jonas Weinz 2018-06-05 15:51:58 +02:00
parent b6ed452fc6
commit 26c3c2abf1
2 changed files with 18486 additions and 8 deletions

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
@ -11,7 +11,13 @@
"import ipywidgets as widgets\n",
"import os\n",
"import glob\n",
"import json"
"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"
]
},
{
@ -31,7 +37,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@ -47,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@ -70,7 +76,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 5,
"metadata": {},
"outputs": [
{
@ -912,7 +918,7 @@
"[176332 rows x 7 columns]"
]
},
"execution_count": 16,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@ -931,7 +937,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@ -950,10 +956,11 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# defining blacklist for modifier emojis:\n",
"emoji_blacklist = set([\n",
" chr(0x1F3FB),\n",
" chr(0x1F3FC),\n",
@ -964,6 +971,813 @@
" chr(0x2640)\n",
"])"
]
},
{
"cell_type": "code",
"execution_count": 21,
"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": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# making a set of the emoji list:\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* trying a multi label vectorizer"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"mlb = MultiLabelBinarizer()\n",
"\n",
"labels = mlb.fit_transform(emojis)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* generating train and test set:"
]
},
{
"cell_type": "code",
"execution_count": 30,
"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": 31,
"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": 40,
"metadata": {},
"outputs": [],
"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"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [],
"source": [
"def train():\n",
" clf = OVRC(DTC())\n",
"\n",
" clf.fit(vec_train[:10000], y1[:10000])\n",
" \n",
" return clf"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 889 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 897 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 898 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 901 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 902 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 903 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 907 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 908 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 909 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 910 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 911 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 913 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 914 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 915 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 918 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 919 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 924 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 925 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 926 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 927 is present in all training examples.\n",
" str(classes[c]))\n",
"/home/jonas/.local/lib/python3.6/site-packages/sklearn/multiclass.py:76: UserWarning: Label not 928 is present in all training examples.\n",
" str(classes[c]))\n"
]
}
],
"source": [
"clf = train()"
]
},
{
"cell_type": "code",
"execution_count": 51,
"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>57624</th>\n",
" <td>(💥, 😡)</td>\n",
" <td>(💥, 😡)</td>\n",
" <td>@RealRoseTaylor1: IMO A terrorist doesnt hav...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>58180</th>\n",
" <td>()</td>\n",
" <td>(😒,)</td>\n",
" <td>@mog7546: NOT BREAKING NEWS - #KELLY's STUPID...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>122719</th>\n",
" <td>(😂, 🤦)</td>\n",
" <td>(😂, 🤦)</td>\n",
" <td>@SpecialMonroe: Im more of like a “ yes nigg...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>132425</th>\n",
" <td>()</td>\n",
" <td>(🤷,)</td>\n",
" <td>@xo_sweetttnesss Basically </td>\n",
" </tr>\n",
" <tr>\n",
" <th>95629</th>\n",
" <td>(😂,)</td>\n",
" <td>(😂,)</td>\n",
" <td>@JVino_: Never should of gave niggas technolo...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>144805</th>\n",
" <td>(😂,)</td>\n",
" <td>(🤷,)</td>\n",
" <td>@_Erickaaaaaaa: People mad iffy Im not aroun...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50997</th>\n",
" <td>(💕, 🛫)</td>\n",
" <td>(💕, 🛫)</td>\n",
" <td>@MURASAKI_9394: &amp;lt;preview&amp;gt; 171101 ICN@mt...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>52294</th>\n",
" <td>()</td>\n",
" <td>(😍, 😣)</td>\n",
" <td>@JaDinePhils: Rogue x Gambit x Deadpool No cu...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>57600</th>\n",
" <td>(⚾, 😬)</td>\n",
" <td>(💙,)</td>\n",
" <td>@CailenHanzlik: So hyped watching my former t...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12709</th>\n",
" <td>(😂,)</td>\n",
" <td>(💀,)</td>\n",
" <td>@C_eazyy @RuthlessLuke_ LMAO DED let a nigga s...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>159921</th>\n",
" <td>(😍,)</td>\n",
" <td>(👎,)</td>\n",
" <td>@ShawnHayes_Real @Mr_Ghostly @CR_Shelton @Rojo...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1297</th>\n",
" <td>(💀, 😂)</td>\n",
" <td>(💀, 😂)</td>\n",
" <td>@Ieansquad: he really solved the equation I c...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>124445</th>\n",
" <td>()</td>\n",
" <td>(😩,)</td>\n",
" <td>It is really breaking my heart. Imma stick by ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>150159</th>\n",
" <td>()</td>\n",
" <td>(🐰,)</td>\n",
" <td>@jikookarchive: : aw sexy~: (jimin your cleav...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>170959</th>\n",
" <td>(✅, 🔥)</td>\n",
" <td>(✅, 🍋, 🔥)</td>\n",
" <td>@Harrys1DEmpire: 1: Like this2: Follow all th...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>46992</th>\n",
" <td>(🎬, 💋, 🔗)</td>\n",
" <td>(🎬, 💋, 🔗)</td>\n",
" <td>@ONGSEONGWU_TH: [] #WANNAONE X Innisfree | On...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>130772</th>\n",
" <td>(🎃,)</td>\n",
" <td>(🐺,)</td>\n",
" <td>@lbtreiman: Well i certainly didn't get 'em a...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>63733</th>\n",
" <td>()</td>\n",
" <td>(🎃,)</td>\n",
" <td>@gamngbizzle: Follow everyone who retweets t...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22026</th>\n",
" <td>()</td>\n",
" <td>(💕, 📷)</td>\n",
" <td>@fshion_me: Love it【@perlinek】Coupon code: zo...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>109588</th>\n",
" <td>(😍, 😳)</td>\n",
" <td>(😍,)</td>\n",
" <td>@SoCuteBabies: Those eyes</td>\n",
" </tr>\n",
" <tr>\n",
" <th>167358</th>\n",
" <td>(🎃,)</td>\n",
" <td>(👻, 😈)</td>\n",
" <td>@Lepetit626: Happy Halloween from the cutest ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>132276</th>\n",
" <td>()</td>\n",
" <td>(💀,)</td>\n",
" <td>@marceoooo shuttup</td>\n",
" </tr>\n",
" <tr>\n",
" <th>150897</th>\n",
" <td>(😱, 🙈, 🙉)</td>\n",
" <td>(🔥, 😈)</td>\n",
" <td>@instaWANKtube: Drilling babe@mistersex17 @hq...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15211</th>\n",
" <td>(🎃,)</td>\n",
" <td>(🎃,)</td>\n",
" <td>@G_Eazy: Hopped out of the millennium falcon ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>58157</th>\n",
" <td>(⌛, 💊)</td>\n",
" <td>(⌛, 💊)</td>\n",
" <td>@NBCNewsNight: Stranger Things Neuro Upside D...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>87036</th>\n",
" <td>(🔥,)</td>\n",
" <td>(😂,)</td>\n",
" <td>I ran a lot harder back then, as well.I join v...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68909</th>\n",
" <td>()</td>\n",
" <td>(🚗,)</td>\n",
" <td>@Holy_Boost: SUMMER BOOST case GA! -Like+ ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>70063</th>\n",
" <td>()</td>\n",
" <td>(😭,)</td>\n",
" <td>I love you so much meliflua ❤️</td>\n",
" </tr>\n",
" <tr>\n",
" <th>53508</th>\n",
" <td>()</td>\n",
" <td>(💥,)</td>\n",
" <td>@SMMmarkeing786: Get FREE CBD OIL Trial Bott...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>91590</th>\n",
" <td>(👀,)</td>\n",
" <td>(👀,)</td>\n",
" <td>@dezidoesit: Shea Moisture did not come to pl...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>82637</th>\n",
" <td>()</td>\n",
" <td>()</td>\n",
" <td>@KissaSins: Follow me on Instagram!!</td>\n",
" </tr>\n",
" <tr>\n",
" <th>151805</th>\n",
" <td>(👀,)</td>\n",
" <td>(👀,)</td>\n",
" <td>@dezidoesit: Shea Moisture did not come to pl...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25914</th>\n",
" <td>()</td>\n",
" <td>(🔘,)</td>\n",
" <td>@Heartless600904: He knows how badly he hurt ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>91602</th>\n",
" <td>()</td>\n",
" <td>(😡,)</td>\n",
" <td>@1776Stonewall @Frederick99m That's when I kne...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16911</th>\n",
" <td>()</td>\n",
" <td>(😩,)</td>\n",
" <td>Not even out of bed yet and Im ready to get o...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>94798</th>\n",
" <td>()</td>\n",
" <td>(🙃,)</td>\n",
" <td>nobody gets how lonely and hungry i get</td>\n",
" </tr>\n",
" <tr>\n",
" <th>112317</th>\n",
" <td>(💪,)</td>\n",
" <td>(🤗,)</td>\n",
" <td>@BIGAC_: new month, new money, new opportunit...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>72241</th>\n",
" <td>()</td>\n",
" <td>(😎,)</td>\n",
" <td>@ZeeTamil: Happy birthday @iamsrk #ZeeTamil #...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>160551</th>\n",
" <td>(✨, 💪)</td>\n",
" <td>(😭,)</td>\n",
" <td>@WORLDSTARNOW: Drake looks like he entering h...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>151889</th>\n",
" <td>(👅, 😻)</td>\n",
" <td>(😍,)</td>\n",
" <td>@GenderReveaIs: The moment of truth, hoop sty...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>64998</th>\n",
" <td>(🐶, 💓)</td>\n",
" <td>(🐶, 💓)</td>\n",
" <td>@LA_Loving: Babys first Halloween</td>\n",
" </tr>\n",
" <tr>\n",
" <th>138015</th>\n",
" <td>()</td>\n",
" <td>(😂,)</td>\n",
" <td>@MikeChosen1: When you got a girl who doesn't...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84447</th>\n",
" <td>()</td>\n",
" <td>(💕,)</td>\n",
" <td>@LiamPayne @pinkskiesljp @BestSimy @LiamPayne ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>125899</th>\n",
" <td>()</td>\n",
" <td>(🙏,)</td>\n",
" <td>@Oh_Ashlaay We just have to pray to the baseba...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>47898</th>\n",
" <td>(😂,)</td>\n",
" <td>(😂,)</td>\n",
" <td>@JVino_: Never should of gave niggas technolo...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7597</th>\n",
" <td>()</td>\n",
" <td>(😂,)</td>\n",
" <td>@junkiejunkrat Were doing goooooood. But fuck...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>173305</th>\n",
" <td>()</td>\n",
" <td>(🌈, 💛)</td>\n",
" <td>Ohh nice.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>133827</th>\n",
" <td>(💙,)</td>\n",
" <td>(💙,)</td>\n",
" <td>@JenBluesnake: This is lovely. Unsworth's app...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>157487</th>\n",
" <td>()</td>\n",
" <td>(💻,)</td>\n",
" <td>@yesyours: : Vehicle Magnet #VehicleMagnet 🖨</td>\n",
" </tr>\n",
" <tr>\n",
" <th>142977</th>\n",
" <td>(🌸, 💓)</td>\n",
" <td>(🌸, 💓)</td>\n",
" <td>@namkook_daily: they are so cosy and soft ☁</td>\n",
" </tr>\n",
" <tr>\n",
" <th>47506</th>\n",
" <td>(😭,)</td>\n",
" <td>(💙, 🔥)</td>\n",
" <td>@Juli_SJ13: ••••••2017 SAVED ••••••#BlackSuit</td>\n",
" </tr>\n",
" <tr>\n",
" <th>164518</th>\n",
" <td>()</td>\n",
" <td>(😜,)</td>\n",
" <td>@marcogumabao: I hope you like your eggs SUNN...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>96549</th>\n",
" <td>(🐶, 💓)</td>\n",
" <td>(🐶, 💓)</td>\n",
" <td>@LA_Loving: Babys first Halloween</td>\n",
" </tr>\n",
" <tr>\n",
" <th>69134</th>\n",
" <td>()</td>\n",
" <td>(😞, 😡)</td>\n",
" <td>Reading this @AshcroftBen with many mixed emot...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>116753</th>\n",
" <td>(💪,)</td>\n",
" <td>(🍋,)</td>\n",
" <td>@Caradelevingne: ❤️ NO_ONE EVER REALLY DIES ❤...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>125133</th>\n",
" <td>(😑,)</td>\n",
" <td>(🖤, 😉)</td>\n",
" <td>@DannyTu3250187: @Kriszti7504 @filipina_krueg...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5081</th>\n",
" <td>(😔,)</td>\n",
" <td>(😘,)</td>\n",
" <td>@brysoxox: rt or gay</td>\n",
" </tr>\n",
" <tr>\n",
" <th>62088</th>\n",
" <td>()</td>\n",
" <td>(💔,)</td>\n",
" <td>Why do say that hondas are for fboys??</td>\n",
" </tr>\n",
" <tr>\n",
" <th>32769</th>\n",
" <td>(😂, 😘, 🙏)</td>\n",
" <td>(😁,)</td>\n",
" <td>@menggalurks: Live na ba ang EB today? #ALDU...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>92385</th>\n",
" <td>(😍,)</td>\n",
" <td>(💔,)</td>\n",
" <td>OML, WHAT HAPPENED?!!</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>17634 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" predict teacher \\\n",
"57624 (💥, 😡) (💥, 😡) \n",
"58180 () (😒,) \n",
"122719 (😂, 🤦) (😂, 🤦) \n",
"132425 () (🤷,) \n",
"95629 (😂,) (😂,) \n",
"144805 (😂,) (🤷,) \n",
"50997 (💕, 🛫) (💕, 🛫) \n",
"52294 () (😍, 😣) \n",
"57600 (⚾, 😬) (💙,) \n",
"12709 (😂,) (💀,) \n",
"159921 (😍,) (👎,) \n",
"1297 (💀, 😂) (💀, 😂) \n",
"124445 () (😩,) \n",
"150159 () (🐰,) \n",
"170959 (✅, 🔥) (✅, 🍋, 🔥) \n",
"46992 (🎬, 💋, 🔗) (🎬, 💋, 🔗) \n",
"130772 (🎃,) (🐺,) \n",
"63733 () (🎃,) \n",
"22026 () (💕, 📷) \n",
"109588 (😍, 😳) (😍,) \n",
"167358 (🎃,) (👻, 😈) \n",
"132276 () (💀,) \n",
"150897 (😱, 🙈, 🙉) (🔥, 😈) \n",
"15211 (🎃,) (🎃,) \n",
"58157 (⌛, 💊) (⌛, 💊) \n",
"87036 (🔥,) (😂,) \n",
"68909 () (🚗,) \n",
"70063 () (😭,) \n",
"53508 () (💥,) \n",
"91590 (👀,) (👀,) \n",
"... ... ... \n",
"82637 () () \n",
"151805 (👀,) (👀,) \n",
"25914 () (🔘,) \n",
"91602 () (😡,) \n",
"16911 () (😩,) \n",
"94798 () (🙃,) \n",
"112317 (💪,) (🤗,) \n",
"72241 () (😎,) \n",
"160551 (✨, 💪) (😭,) \n",
"151889 (👅, 😻) (😍,) \n",
"64998 (🐶, 💓) (🐶, 💓) \n",
"138015 () (😂,) \n",
"84447 () (💕,) \n",
"125899 () (🙏,) \n",
"47898 (😂,) (😂,) \n",
"7597 () (😂,) \n",
"173305 () (🌈, 💛) \n",
"133827 (💙,) (💙,) \n",
"157487 () (💻,) \n",
"142977 (🌸, 💓) (🌸, 💓) \n",
"47506 (😭,) (💙, 🔥) \n",
"164518 () (😜,) \n",
"96549 (🐶, 💓) (🐶, 💓) \n",
"69134 () (😞, 😡) \n",
"116753 (💪,) (🍋,) \n",
"125133 (😑,) (🖤, 😉) \n",
"5081 (😔,) (😘,) \n",
"62088 () (💔,) \n",
"32769 (😂, 😘, 🙏) (😁,) \n",
"92385 (😍,) (💔,) \n",
"\n",
" text \n",
"57624 @RealRoseTaylor1: IMO A terrorist doesnt hav... \n",
"58180 @mog7546: NOT BREAKING NEWS - #KELLY's STUPID... \n",
"122719 @SpecialMonroe: Im more of like a “ yes nigg... \n",
"132425 @xo_sweetttnesss Basically \n",
"95629 @JVino_: Never should of gave niggas technolo... \n",
"144805 @_Erickaaaaaaa: People mad iffy Im not aroun... \n",
"50997 @MURASAKI_9394: &lt;preview&gt; 171101 ICN@mt... \n",
"52294 @JaDinePhils: Rogue x Gambit x Deadpool No cu... \n",
"57600 @CailenHanzlik: So hyped watching my former t... \n",
"12709 @C_eazyy @RuthlessLuke_ LMAO DED let a nigga s... \n",
"159921 @ShawnHayes_Real @Mr_Ghostly @CR_Shelton @Rojo... \n",
"1297 @Ieansquad: he really solved the equation I c... \n",
"124445 It is really breaking my heart. Imma stick by ... \n",
"150159 @jikookarchive: : aw sexy~: (jimin your cleav... \n",
"170959 @Harrys1DEmpire: 1: Like this2: Follow all th... \n",
"46992 @ONGSEONGWU_TH: [] #WANNAONE X Innisfree | On... \n",
"130772 @lbtreiman: Well i certainly didn't get 'em a... \n",
"63733 @gamngbizzle: Follow everyone who retweets t... \n",
"22026 @fshion_me: Love it【@perlinek】Coupon code: zo... \n",
"109588 @SoCuteBabies: Those eyes \n",
"167358 @Lepetit626: Happy Halloween from the cutest ... \n",
"132276 @marceoooo shuttup \n",
"150897 @instaWANKtube: Drilling babe@mistersex17 @hq... \n",
"15211 @G_Eazy: Hopped out of the millennium falcon ... \n",
"58157 @NBCNewsNight: Stranger Things Neuro Upside D... \n",
"87036 I ran a lot harder back then, as well.I join v... \n",
"68909 @Holy_Boost: SUMMER BOOST case GA! -Like+ ... \n",
"70063 I love you so much meliflua ❤️ \n",
"53508 @SMMmarkeing786: Get FREE CBD OIL Trial Bott... \n",
"91590 @dezidoesit: Shea Moisture did not come to pl... \n",
"... ... \n",
"82637 @KissaSins: Follow me on Instagram!! \n",
"151805 @dezidoesit: Shea Moisture did not come to pl... \n",
"25914 @Heartless600904: He knows how badly he hurt ... \n",
"91602 @1776Stonewall @Frederick99m That's when I kne... \n",
"16911 Not even out of bed yet and Im ready to get o... \n",
"94798 nobody gets how lonely and hungry i get \n",
"112317 @BIGAC_: new month, new money, new opportunit... \n",
"72241 @ZeeTamil: Happy birthday @iamsrk #ZeeTamil #... \n",
"160551 @WORLDSTARNOW: Drake looks like he entering h... \n",
"151889 @GenderReveaIs: The moment of truth, hoop sty... \n",
"64998 @LA_Loving: Babys first Halloween \n",
"138015 @MikeChosen1: When you got a girl who doesn't... \n",
"84447 @LiamPayne @pinkskiesljp @BestSimy @LiamPayne ... \n",
"125899 @Oh_Ashlaay We just have to pray to the baseba... \n",
"47898 @JVino_: Never should of gave niggas technolo... \n",
"7597 @junkiejunkrat Were doing goooooood. But fuck... \n",
"173305 Ohh nice. \n",
"133827 @JenBluesnake: This is lovely. Unsworth's app... \n",
"157487 @yesyours: : Vehicle Magnet #VehicleMagnet 🖨 \n",
"142977 @namkook_daily: they are so cosy and soft ☁ \n",
"47506 @Juli_SJ13: ••••••2017 SAVED ••••••#BlackSuit \n",
"164518 @marcogumabao: I hope you like your eggs SUNN... \n",
"96549 @LA_Loving: Babys first Halloween \n",
"69134 Reading this @AshcroftBen with many mixed emot... \n",
"116753 @Caradelevingne: ❤️ NO_ONE EVER REALLY DIES ❤... \n",
"125133 @DannyTu3250187: @Kriszti7504 @filipina_krueg... \n",
"5081 @brysoxox: rt or gay \n",
"62088 Why do say that hondas are for fboys?? \n",
"32769 @menggalurks: Live na ba ang EB today? #ALDU... \n",
"92385 OML, WHAT HAPPENED?!! \n",
"\n",
"[17634 rows x 3 columns]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pred = clf.predict(vectorizer.transform(Xt1))\n",
"\n",
"# build a dataframe to visualize test results:\n",
"testlist = pd.DataFrame({'text': Xt1, 'teacher': mlb.inverse_transform(yt1), 'predict': mlb.inverse_transform(pred)})\n",
"\n",
"display(testlist)"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [],
"source": [
"testlist.to_csv('test.csv')"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1e6d156f9beb42ada3790d977beb2b7c",
"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": "b76a73c0fa7946f28fe91e18240484a4",
"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",
" display(Markdown(\"# \" + str(mlb.inverse_transform(clf.predict(vectorizer.transform([t.value])))[0])))\n",
"\n",
"b.on_click(handle_submit)\n",
" \n",
"display(t)\n",
"display(widgets.VBox([b, out])) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {

File diff suppressed because it is too large Load Diff