{ "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": 2, "metadata": {}, "outputs": [], "source": [ "import sys\n", "sys.path.append(\"..\")\n", "\n", "from Tools.Emoji_Distance import sentiment_vector_to_emoji\n", "from Tools.Emoji_Distance import emoji_to_sentiment_vector\n", "\n", "def emoji2sent(emoji_arr):\n", " return np.array([emoji_to_sentiment_vector(e) for e in emoji_arr])\n", "\n", "def sent2emoji(sent_arr):\n", " return [sentiment_vector_to_emoji(s) for s in sent_arr]" ] }, { "cell_type": "code", "execution_count": 3, "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": 4, "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": 5, "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": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | EMOJI | \n", "HASHTAGS | \n", "LINKED_USER | \n", "datetime | \n", "id | \n", "lang | \n", "person | \n", "reply_to | \n", "text | \n", "
---|---|---|---|---|---|---|---|---|---|
0 | \n", "[๐ฅ, ๐] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:00 | \n", "925716304635547600 | \n", "en | \n", "31507978 | \n", "NaN | \n", "fashionbombdaily's photo <EMOJI><EMOJI>๐ผ | \n", "
1 | \n", "[๐คฆ] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:00 | \n", "925716304664911900 | \n", "en | \n", "231994649 | \n", "NaN | \n", "Itโs scary how on point my horoscope be <EMOJI... | \n", "
2 | \n", "[๐] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:03 | \n", "925716317214089200 | \n", "en | \n", "2592765104 | \n", "NaN | \n", "Woooaaaahhh <EMOJI> | \n", "
3 | \n", "[๐ท] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:04 | \n", "925716321416949800 | \n", "en | \n", "278737933 | \n", "NaN | \n", "<EMOJI> vivalcli: Portraits by Zhao Guojing an... | \n", "
4 | \n", "[๐ฉ, ๐ฉ] | \n", "[] | \n", "[@hiphopphiIes] | \n", "2017-11-01 13:29:06 | \n", "925716329801310200 | \n", "en | \n", "824586253634981900 | \n", "9.257162e+17 | \n", "<USER> i wanna know too<EMOJI><EMOJI> | \n", "
5 | \n", "[๐ญ, ๐] | \n", "[] | \n", "[@WizMommma] | \n", "2017-11-01 13:29:02 | \n", "925716313019965400 | \n", "en | \n", "1581953814 | \n", "9.257088e+17 | \n", "<USER> veda was yoda too <EMOJI><EMOJI> | \n", "
6 | \n", "[๐] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:05 | \n", "925716325607133200 | \n", "en | \n", "1001999683 | \n", "NaN | \n", "Iโm less stressed about turning 30 now <EMOJI>... | \n", "
7 | \n", "[๐ฏ] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:07 | \n", "925716334008082400 | \n", "en | \n", "745222369183043600 | \n", "NaN | \n", "Full charged. <EMOJI> | \n", "
8 | \n", "[๐] | \n", "[] | \n", "[@SeaDimon, @lsarsour] | \n", "2017-11-01 13:29:09 | \n", "925716342401052700 | \n", "en | \n", "798557155217539100 | \n", "9.257147e+17 | \n", "<USER> Thatโs part of the problem, (they) <USE... | \n", "
9 | \n", "[๐, ๐ฅ, ๐ข] | \n", "[] | \n", "[@Ian_khetye] | \n", "2017-11-01 13:29:10 | \n", "925716346570240000 | \n", "en | \n", "744396039126421500 | \n", "9.250629e+17 | \n", "<USER> got me emotional there<EMOJI><EMOJI><EM... | \n", "
10 | \n", "[๐ป] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:13 | \n", "925716359182520300 | \n", "en | \n", "721490010118205400 | \n", "8.965900e+17 | \n", "back to the yellow <EMOJI> | \n", "
11 | \n", "[๐, ๐บ, ๐] | \n", "[] | \n", "[@Dimafadma] | \n", "2017-11-01 13:29:15 | \n", "925716367558545400 | \n", "en | \n", "520536723 | \n", "9.257159e+17 | \n", "<USER> Happy month to you and your loved ones ... | \n", "
12 | \n", "[๐] | \n", "[#mortdale, #partofthefamily, #gorgeousboy] | \n", "[] | \n", "2017-11-01 13:29:16 | \n", "925716371735900200 | \n", "en | \n", "850852815941517300 | \n", "NaN | \n", "Maxx and Patricia. Family hangs at For Good He... | \n", "
13 | \n", "[๐ญ, ๐คฆ] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:20 | \n", "925716388513230800 | \n", "en | \n", "914145041588867100 | \n", "NaN | \n", "I need to STOP beating myself up with my thoug... | \n", "
14 | \n", "[๐, ๐] | \n", "[#7YearsOfKMH2] | \n", "[] | \n", "2017-11-01 13:29:20 | \n", "925716388525645800 | \n", "en | \n", "2425405622 | \n", "NaN | \n", "Cutest Son <EMOJI>Roll no. 31 <EMOJI> <HASHTAG> | \n", "
15 | \n", "[๐] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:22 | \n", "925716396931240000 | \n", "en | \n", "4614871873 | \n", "NaN | \n", "By the summer I should have everything up and ... | \n", "
16 | \n", "[๐, ๐ฅ] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:23 | \n", "925716401125331000 | \n", "en | \n", "2831608345 | \n", "NaN | \n", "I know my English is not that good but that do... | \n", "
17 | \n", "[๐] | \n", "[] | \n", "[@yungbabytate] | \n", "2017-11-01 13:29:23 | \n", "925716401133948900 | \n", "en | \n", "788571974633009200 | \n", "9.255778e+17 | \n", "<USER> I <EMOJI> u mama | \n", "
18 | \n", "[๐] | \n", "[] | \n", "[@cmckenney] | \n", "2017-11-01 13:29:23 | \n", "925716401125544000 | \n", "en | \n", "218307802 | \n", "9.257115e+17 | \n", "<USER> That picture was NOT taken this morning... | \n", "
19 | \n", "[๐ ] | \n", "[#footfetishnation] | \n", "[] | \n", "2017-11-01 13:29:25 | \n", "925716409489002500 | \n", "en | \n", "885261166146179100 | \n", "NaN | \n", "Welcome to <HASHTAG> <EMOJI> | \n", "
20 | \n", "[๐, ๐] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:25 | \n", "925716409497272300 | \n", "en | \n", "831437760833609700 | \n", "NaN | \n", "Awkward <EMOJI><EMOJI> | \n", "
21 | \n", "[๐ค, ๐บ] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:26 | \n", "925716413699854300 | \n", "en | \n", "231664542 | \n", "NaN | \n", "back at it with supernatural <EMOJI><EMOJI> | \n", "
22 | \n", "[๐ฏ] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:26 | \n", "925716413679009800 | \n", "en | \n", "3196847035 | \n", "NaN | \n", "One of the best things I've learned was to sto... | \n", "
23 | \n", "[๐ , ๐ฆ, ๐] | \n", "[] | \n", "[@ctrlpurp] | \n", "2017-11-01 13:29:29 | \n", "925716426278735900 | \n", "en | \n", "918492858352635900 | \n", "9.257161e+17 | \n", "<USER> Can I taste?<EMOJI><EMOJI><EMOJI> | \n", "
24 | \n", "[๐] | \n", "[] | \n", "[@saunders_court1] | \n", "2017-11-01 13:29:30 | \n", "925716430473039900 | \n", "en | \n", "3471187337 | \n", "9.257163e+17 | \n", "<USER> we miss you โน๏ธ<EMOJI> | \n", "
25 | \n", "[๐ค, ๐ค, ๐ค] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:31 | \n", "925716434667184100 | \n", "en | \n", "780060488600199200 | \n", "NaN | \n", "Actually my bias in WJSN are Eunseo & Bona... | \n", "
26 | \n", "[๐ด] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:32 | \n", "925716438853345300 | \n", "en | \n", "388380690 | \n", "NaN | \n", "I so cannot be bothered with the rest of the d... | \n", "
27 | \n", "[๐] | \n", "[] | \n", "[@xxxtentacion] | \n", "2017-11-01 13:29:35 | \n", "925716451457163300 | \n", "en | \n", "899320696869974000 | \n", "NaN | \n", "<USER> 2lit4life<EMOJI> | \n", "
28 | \n", "[๐, ๐] | \n", "[] | \n", "[] | \n", "2017-11-01 13:29:35 | \n", "925716451461357600 | \n", "en | \n", "784790670 | \n", "NaN | \n", "Iโm not stop saying that!<EMOJI><EMOJI> | \n", "
29 | \n", "[๐, ๐, ๐, ๐, ๐, ๐] | \n", "[] | \n", "[@justinerooney_] | \n", "2017-11-01 13:29:37 | \n", "925716459828936700 | \n", "en | \n", "3051266655 | \n", "NaN | \n", "<USER> HAPPY BIHDAY <EMOJI><EMOJI><EMOJI><EMOJ... | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
68703 | \n", "[๐] | \n", "[#halloweencostumes] | \n", "[] | \n", "2017-11-01 07:23:04 | \n", "925624214522036200 | \n", "en | \n", "1672876458 | \n", "NaN | \n", "<HASHTAG> this one falls under the weird crazy... | \n", "
68704 | \n", "[๐, ๐ฉ] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:05 | \n", "925624218682777600 | \n", "en | \n", "382473866 | \n", "NaN | \n", "I'm not allowed to have chocolates yet, then I... | \n", "
68705 | \n", "[๐] | \n", "[#MUFC] | \n", "[] | \n", "2017-11-01 07:23:06 | \n", "925624222889766900 | \n", "en | \n", "893145405457911800 | \n", "NaN | \n", "Manchester United manager Mourinho slams 'spec... | \n", "
68706 | \n", "[๐] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:07 | \n", "925624227088121900 | \n", "en | \n", "240378516 | \n", "NaN | \n", "<EMOJI> en Bushwhick | \n", "
68707 | \n", "[๐, ๐, ๐, ๐] | \n", "[#BurkeCentre] | \n", "[] | \n", "2017-11-01 07:23:18 | \n", "925624273237983200 | \n", "en | \n", "784620573209002000 | \n", "NaN | \n", ": <HASHTAG> <EMOJI> <EMOJI><EMOJI> For Taxi <E... | \n", "
68708 | \n", "[๐] | \n", "[] | \n", "[@mychosliaheart, @BarrettoJulia, @iamjoshuaga... | \n", "2017-11-01 07:23:18 | \n", "925624273212805100 | \n", "en | \n", "170998187 | \n", "9.254136e+17 | \n", "<USER> <USER> <USER> Look, Mammeh and Daddeh! ... | \n", "
68709 | \n", "[๐] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:24 | \n", "925624298395533300 | \n", "en | \n", "1348667816 | \n", "NaN | \n", "Life is so good with you <EMOJI> | \n", "
68710 | \n", "[๐, ๐, ๐] | \n", "[#portlandoregon, #portlandhalloween, #carrieโฆ] | \n", "[] | \n", "2017-11-01 07:23:24 | \n", "925624298378801200 | \n", "en | \n", "722481645765300200 | \n", "NaN | \n", "Happy Halloween! <EMOJI>๐ฝ<EMOJI><EMOJI> <HASHT... | \n", "
68711 | \n", "[๐] | \n", "[] | \n", "[@8limbsbondi...] | \n", "2017-11-01 07:23:26 | \n", "925624306779897900 | \n", "en | \n", "2443251500 | \n", "NaN | \n", "Some work on the ropes in todayโs boxing class... | \n", "
68712 | \n", "[๐ญ] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:27 | \n", "925624310974136300 | \n", "en | \n", "2406186390 | \n", "NaN | \n", "Scotty and Kristenโs halloween costumes <EMOJI> | \n", "
68713 | \n", "[๐] | \n", "[] | \n", "[@rfrandrea, @AdaaanAndyyy] | \n", "2017-11-01 07:23:30 | \n", "925624323557146600 | \n", "en | \n", "1039448149 | \n", "9.256150e+17 | \n", "<USER> <USER> May pre-month celebration sis <E... | \n", "
68714 | \n", "[๐ญ, ๐ญ, ๐] | \n", "[] | \n", "[@peachshua1230] | \n", "2017-11-01 07:23:31 | \n", "925624327755591700 | \n", "en | \n", "845085544589672400 | \n", "9.256009e+17 | \n", "<USER> Awww <EMOJI> Ajsksjdjd im smiling like ... | \n", "
68715 | \n", "[๐ซ, โ] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:34 | \n", "925624340342812700 | \n", "en | \n", "924752524871131100 | \n", "NaN | \n", "I hate when I send a text or snap n I'm so anx... | \n", "
68716 | \n", "[๐, ๐] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:34 | \n", "925624340355280900 | \n", "en | \n", "419493819 | \n", "NaN | \n", "The answer is no I have no plans and I never l... | \n", "
68717 | \n", "[๐ญ] | \n", "[] | \n", "[@BeachBoy_Gab] | \n", "2017-11-01 07:23:34 | \n", "925624340346937300 | \n", "en | \n", "2457745952 | \n", "9.256219e+17 | \n", "<USER> LMAOOO I'm so proud <EMOJI> | \n", "
68718 | \n", "[๐ข, ๐] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:34 | \n", "925624340338507800 | \n", "en | \n", "1955767531 | \n", "NaN | \n", "My cousin/little sister is leaving to San Fran... | \n", "
68719 | \n", "[๐] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:35 | \n", "925624344524361700 | \n", "en | \n", "796490344581898200 | \n", "NaN | \n", "Can't be alone w my thoughts tonight so just g... | \n", "
68720 | \n", "[๐, ๐, ๐, ๐, ๐] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:36 | \n", "925624348710285300 | \n", "en | \n", "907808317124177900 | \n", "NaN | \n", "<EMOJI><EMOJI><EMOJI><EMOJI><EMOJI> ambot!!! | \n", "
68721 | \n", "[๐, ๐, ๐] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:37 | \n", "925624352929910800 | \n", "en | \n", "262162415 | \n", "NaN | \n", "<EMOJI>๐ฝ<EMOJI>๐ฝ 1st of the month!!Happy 1st o... | \n", "
68722 | \n", "[๐ด] | \n", "[#WednesdayWisdom] | \n", "[] | \n", "2017-11-01 07:23:41 | \n", "925624369715515400 | \n", "en | \n", "574882525 | \n", "NaN | \n", "<HASHTAG> ... stay in bed <EMOJI> | \n", "
68723 | \n", "[๐, ๐, ๐, ๐] | \n", "[] | \n", "[@Louis_Tomlinson, @NiallOfficial] | \n", "2017-11-01 07:23:44 | \n", "925624382269124600 | \n", "en | \n", "556175173 | \n", "9.254038e+17 | \n", "<USER> <USER> THIS IS GOLD. GOLD. <EMOJI><EMOJ... | \n", "
68724 | \n", "[๐] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:45 | \n", "925624386455031800 | \n", "en | \n", "1610265588 | \n", "NaN | \n", "<EMOJI> thank you for the kind compliment | \n", "
68725 | \n", "[๐] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:45 | \n", "925624386454937600 | \n", "en | \n", "4760724450 | \n", "NaN | \n", "Enjoyed the silence <EMOJI> | \n", "
68726 | \n", "[โจ] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:46 | \n", "925624390657572900 | \n", "en | \n", "882858115636514800 | \n", "NaN | \n", "OS: Spiderman Homecoming <EMOJI> | \n", "
68727 | \n", "[๐คท] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:46 | \n", "925624390682849300 | \n", "en | \n", "188129628 | \n", "NaN | \n", "Go to hell <EMOJI>๐ฝโโ๏ธ | \n", "
68728 | \n", "[๐] | \n", "[] | \n", "[] | \n", "2017-11-01 07:23:46 | \n", "925624390666129400 | \n", "en | \n", "2473135939 | \n", "NaN | \n", "Thank you Yomi! <EMOJI> | \n", "
68729 | \n", "[๐] | \n", "[] | \n", "[@discopiggu] | \n", "2017-11-01 07:23:46 | \n", "925624390670106600 | \n", "en | \n", "2373584209 | \n", "9.256241e+17 | \n", "<USER> Lol. Just enjoy the stars. Music Kidhar... | \n", "
68730 | \n", "[๐] | \n", "[#NYCStrong] | \n", "[] | \n", "2017-11-01 07:23:50 | \n", "925624407459971100 | \n", "en | \n", "181689756 | \n", "NaN | \n", "Thoughts and prayers for NY<EMOJI>๐ป <HASHTAG> | \n", "
68731 | \n", "[๐] | \n", "[#GreatSuccess] | \n", "[@BrianyH] | \n", "2017-11-01 07:23:50 | \n", "925624407460057100 | \n", "en | \n", "60160788 | \n", "9.254610e+17 | \n", "<USER> I searched COCK, PENIS, SHLONG, WINKY, ... | \n", "
68732 | \n", "[๐, ๐ป, ๐ป, ๐, ๐, ๐, ๐, ๐, ๐] | \n", "[] | \n", "[@amitbarman520] | \n", "2017-11-01 07:23:53 | \n", "925624420022063100 | \n", "en | \n", "3792290725 | \n", "9.256215e+17 | \n", "<USER> Thank you so much<EMOJI><EMOJI><EMOJI><... | \n", "
68733 rows ร 9 columns
\n", "\n", " | predict | \n", "predicted_sentiment | \n", "teacher | \n", "teacher_sentiment | \n", "text | \n", "
---|---|---|---|---|---|
7618 | \n", "๐ฌ | \n", "[0.45662233233451843, 0.27109310030937195, 0.2... | \n", "๐ | \n", "[0.21660649819494585, 0.5913357400722021, 0.19... | \n", "There's fucking snow outside | \n", "
6910 | \n", "๐ฑ | \n", "[0.454468309879303, 0.27005136013031006, 0.275... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "<USER> You look so animated bro! *Rimshot*, Ge... | \n", "
35783 | \n", "๐ฌ | \n", "[0.4557249844074249, 0.271492600440979, 0.2727... | \n", "๐ญ | \n", "[0.34310532030401736, 0.4364820846905538, 0.22... | \n", "<USER> Jon ordered it from a restaurant | \n", "
15623 | \n", "๐ฌ | \n", "[0.4551065266132355, 0.27315083146095276, 0.27... | \n", "๐ | \n", "[0.47186147186147187, 0.2922077922077922, 0.23... | \n", "I just want to move back in with my mom | \n", "
12023 | \n", "๐ฑ | \n", "[0.44956669211387634, 0.2718639373779297, 0.27... | \n", "๐ญ | \n", "[0.34310532030401736, 0.4364820846905538, 0.22... | \n", "guys lets vote!!! | \n", "
15763 | \n", "๐ฑ | \n", "[0.4546020030975342, 0.27004513144493103, 0.27... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "Bruhhhh this man need a show ASAP!!! | \n", "
57240 | \n", "๐ฑ | \n", "[0.4514758884906769, 0.2734237313270569, 0.275... | \n", "๐ | \n", "[0.5981432360742706, 0.10477453580901856, 0.29... | \n", "AND THE RICH SIT IN A LOW PLACE | \n", "
2418 | \n", "๐ฌ | \n", "[0.4555293321609497, 0.2700120508670807, 0.274... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "Time to go to bed | \n", "
66384 | \n", "๐ฌ | \n", "[0.4541899561882019, 0.27133306860923767, 0.27... | \n", "๐ | \n", "[0.7296744771190439, 0.05173769460607014, 0.21... | \n", "May sound like a hillbilly, but girls that can... | \n", "
44639 | \n", "๐ฌ | \n", "[0.45672306418418884, 0.2679496109485626, 0.27... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "<USER> <USER> <USER> IM DYING | \n", "
54463 | \n", "๐ฑ | \n", "[0.45094504952430725, 0.2715355157852173, 0.27... | \n", "๐ | \n", "[0.6613545816733067, 0.10092961487383798, 0.23... | \n", "Black forest hot chocolate is coming back to C... | \n", "
38407 | \n", "๐ฑ | \n", "[0.45006927847862244, 0.2722932994365692, 0.27... | \n", "๐ | \n", "[0.5981432360742706, 0.10477453580901856, 0.29... | \n", "5 days till my 21st. | \n", "
31342 | \n", "๐ฌ | \n", "[0.45655250549316406, 0.26978597044944763, 0.2... | \n", "๐ | \n", "[0.5586552217453505, 0.13662374821173104, 0.30... | \n", "<USER> I'm just going to leave my Twitter acct... | \n", "
41255 | \n", "๐ฑ | \n", "[0.45397621393203735, 0.27026963233947754, 0.2... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "Oh god im so happy | \n", "
19686 | \n", "๐ฑ | \n", "[0.4501204788684845, 0.27288398146629333, 0.27... | \n", "๐ญ | \n", "[0.34310532030401736, 0.4364820846905538, 0.22... | \n", "In my head | \n", "
67193 | \n", "๐ฑ | \n", "[0.45182353258132935, 0.2724774479866028, 0.27... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "<USER> Jo, chilllllllll. This kid is mentally... | \n", "
40650 | \n", "๐ฑ | \n", "[0.45002350211143494, 0.2710316777229309, 0.27... | \n", "๐ | \n", "[0.6666666666666666, 0.06666666666666667, 0.26... | \n", "Iโm ready sis | \n", "
64416 | \n", "๐ฑ | \n", "[0.45193251967430115, 0.2698008418083191, 0.27... | \n", "๐ | \n", "[0.7040175768989329, 0.059322033898305086, 0.2... | \n", "Sometimes we need to know how to respect our p... | \n", "
19525 | \n", "๐ฑ | \n", "[0.45155930519104004, 0.27194666862487793, 0.2... | \n", "๐ | \n", "[0.5964912280701754, 0.08771929824561403, 0.31... | \n", "Right? | \n", "
39024 | \n", "๐ฑ | \n", "[0.4556638300418854, 0.26780301332473755, 0.27... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "<USER> priceless love how <USER> got back at ... | \n", "
35342 | \n", "๐ฑ | \n", "[0.452972412109375, 0.27151480317115784, 0.275... | \n", "๐ซ | \n", "[0.3404710920770878, 0.4860813704496788, 0.173... | \n", "<USER> Right | \n", "
9715 | \n", "๐ฑ | \n", "[0.4522416293621063, 0.2719023823738098, 0.275... | \n", "๐ | \n", "[0.6666666666666666, 0.06666666666666667, 0.26... | \n", "Opo pang i will! | \n", "
40490 | \n", "๐ฌ | \n", "[0.4545004665851593, 0.27230802178382874, 0.27... | \n", "๐ฎ | \n", "[0.45555555555555555, 0.17777777777777778, 0.3... | \n", "<USER> WOW whomever was tasked with vetting a... | \n", "
22064 | \n", "๐ฌ | \n", "[0.4601033926010132, 0.2683771550655365, 0.271... | \n", "๐ | \n", "[0.7296744771190439, 0.05173769460607014, 0.21... | \n", "Thank you <USER> ! | \n", "
53563 | \n", "๐ฑ | \n", "[0.45222631096839905, 0.2727421224117279, 0.27... | \n", "๐ | \n", "[0.5586552217453505, 0.13662374821173104, 0.30... | \n", "Dat daurin Dan kwali from behind is the real ... | \n", "
67332 | \n", "๐ฌ | \n", "[0.45455402135849, 0.27052536606788635, 0.2749... | \n", "๐ช | \n", "[0.3506224066390041, 0.4315352697095436, 0.217... | \n", "I miss my baby so much โฅ๏ธ | \n", "
15404 | \n", "๐ฑ | \n", "[0.45141908526420593, 0.2713443338871002, 0.27... | \n", "๐ | \n", "[0.20294117647058824, 0.6029411764705882, 0.19... | \n", "alright i'm gonna go take a shower, let me kno... | \n", "
30130 | \n", "๐ฌ | \n", "[0.4556472599506378, 0.2695685029029846, 0.274... | \n", "๐ณ | \n", "[0.34515366430260047, 0.32742316784869974, 0.3... | \n", "<USER> and neither are buying her music | \n", "
37242 | \n", "๐ฌ | \n", "[0.4568144977092743, 0.27149033546447754, 0.27... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "<USER> I saw that too as well! I feel to have ... | \n", "
30533 | \n", "๐ฌ | \n", "[0.45350709557533264, 0.27462711930274963, 0.2... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "I had a mental break down but Iโm back like hey | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
16955 | \n", "๐ฑ | \n", "[0.45130616426467896, 0.2745077311992645, 0.27... | \n", "๐ | \n", "[0.4983755685510071, 0.08057179987004548, 0.42... | \n", "Bless up Esquivel finally update aeries | \n", "
36805 | \n", "๐ฌ | \n", "[0.4585663378238678, 0.26974013447761536, 0.27... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "<USER> <USER> <USER> Look just like my Mizuno ... | \n", "
56326 | \n", "๐ฑ | \n", "[0.45519477128982544, 0.2686183452606201, 0.27... | \n", "๐ข | \n", "[0.39118825100133514, 0.38451268357810414, 0.2... | \n", "This felt like it happened yesterday. <HASHTAG> | \n", "
40306 | \n", "๐ฑ | \n", "[0.449861079454422, 0.2748417556285858, 0.2752... | \n", "๐ | \n", "[0.7296744771190439, 0.05173769460607014, 0.21... | \n", "Our Guest photo this week highlights the beaut... | \n", "
51333 | \n", "๐ฑ | \n", "[0.4518674910068512, 0.2723572850227356, 0.275... | \n", "๐ | \n", "[0.6240601503759399, 0.13984962406015036, 0.23... | \n", "I need to see what โthe stranger thingsโ is ab... | \n", "
42339 | \n", "๐ฌ | \n", "[0.4573005437850952, 0.2696344256401062, 0.273... | \n", "๐ | \n", "[0.31784232365145226, 0.46390041493775935, 0.2... | \n", "<USER> Plz can u make me a pc I donโt have eno... | \n", "
7644 | \n", "๐ฑ | \n", "[0.4539974331855774, 0.2710561156272888, 0.274... | \n", "๐ง | \n", "[0.32608695652173914, 0.391304347826087, 0.282... | \n", "<USER> this is insulting | \n", "
13953 | \n", "๐ฑ | \n", "[0.4520905911922455, 0.27237412333488464, 0.27... | \n", "๐ | \n", "[0.16296296296296298, 0.5555555555555556, 0.28... | \n", "I know this might sound crazy but I rather Don... | \n", "
26460 | \n", "๐ฑ | \n", "[0.4516184329986572, 0.2706548869609833, 0.277... | \n", "๐ | \n", "[0.6909090909090909, 0.08181818181818182, 0.22... | \n", "Just a couple of cute pugs hanging out | \n", "
31571 | \n", "๐ฑ | \n", "[0.4516292214393616, 0.2722293734550476, 0.276... | \n", "๐ | \n", "[0.21660649819494585, 0.5913357400722021, 0.19... | \n", "<USER> She knows nothing will happen to her.. ... | \n", "
9536 | \n", "๐ฑ | \n", "[0.45403042435646057, 0.27084800601005554, 0.2... | \n", "๐ญ | \n", "[0.34310532030401736, 0.4364820846905538, 0.22... | \n", "<USER> happy raisin | \n", "
19571 | \n", "๐ฑ | \n", "[0.45092839002609253, 0.273369699716568, 0.275... | \n", "๐ก | \n", "[0.35978835978835977, 0.533068783068783, 0.107... | \n", "I'm so disappointed | \n", "
35934 | \n", "๐ฑ | \n", "[0.45402011275291443, 0.2693026065826416, 0.27... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "<USER> <USER> Nailed it. | \n", "
4605 | \n", "๐ฌ | \n", "[0.45629507303237915, 0.2681595981121063, 0.27... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "<USER> oh itโs more than a thing! | \n", "
1913 | \n", "๐ฌ | \n", "[0.45600560307502747, 0.26834917068481445, 0.2... | \n", "๐ญ | \n", "[0.34310532030401736, 0.4364820846905538, 0.22... | \n", "<USER> stop it | \n", "
11827 | \n", "๐ฌ | \n", "[0.45951539278030396, 0.26939070224761963, 0.2... | \n", "๐ | \n", "[0.5586552217453505, 0.13662374821173104, 0.30... | \n", "Have an awesome <HASHTAG> โค๏ธ <HASHTAG> | \n", "
15181 | \n", "๐ฌ | \n", "[0.4616319239139557, 0.2665380537509918, 0.271... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "<USER> when I see elbows ? | \n", "
32869 | \n", "๐ฌ | \n", "[0.45471736788749695, 0.27229392528533936, 0.2... | \n", "๐น | \n", "[0.4406779661016949, 0.2983050847457627, 0.261... | \n", "Damn Jani back at it again with the BB-8 costu... | \n", "
40784 | \n", "๐ฌ | \n", "[0.45305681228637695, 0.2729623019695282, 0.27... | \n", "๐ป | \n", "[0.6906474820143885, 0.0671462829736211, 0.242... | \n", "I think a big part of the reason Nick Wilde is... | \n", "
18611 | \n", "๐ฑ | \n", "[0.4504826068878174, 0.27414649724960327, 0.27... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "My 12 year old brother on Altuve- โheโs like t... | \n", "
28341 | \n", "๐ฑ | \n", "[0.45293256640434265, 0.27156686782836914, 0.2... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "<USER> Bruh like how she know the exact number? | \n", "
41368 | \n", "๐ฑ | \n", "[0.4524029791355133, 0.27189141511917114, 0.27... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "They starting early | \n", "
35554 | \n", "๐ฌ | \n", "[0.45386624336242676, 0.2720849812030792, 0.27... | \n", "๐ฉ | \n", "[0.22289823008849557, 0.5912610619469026, 0.18... | \n", "Please come through <USER> | \n", "
27968 | \n", "๐ฌ | \n", "[0.4601033926010132, 0.2683771550655365, 0.271... | \n", "๐ | \n", "[0.7296744771190439, 0.05173769460607014, 0.21... | \n", "<USER> Thank you | \n", "
36772 | \n", "๐ฑ | \n", "[0.45253145694732666, 0.2714029550552368, 0.27... | \n", "๐ณ | \n", "[0.34515366430260047, 0.32742316784869974, 0.3... | \n", "Imagine if the Vikings had a top 10 QB | \n", "
7568 | \n", "๐ฑ | \n", "[0.4514819085597992, 0.27036288380622864, 0.27... | \n", "๐ญ | \n", "[0.34310532030401736, 0.4364820846905538, 0.22... | \n", "Le costume de cupcakke....... | \n", "
62837 | \n", "๐ฌ | \n", "[0.4553525149822235, 0.27044105529785156, 0.27... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "<USER> aM FKXNSK SCREAMING ODM | \n", "
34105 | \n", "๐ฑ | \n", "[0.4522460997104645, 0.27333661913871765, 0.27... | \n", "๐ | \n", "[0.6666666666666666, 0.06666666666666667, 0.26... | \n", "My birthday tomorrow | \n", "
59069 | \n", "๐ฌ | \n", "[0.45729154348373413, 0.26964816451072693, 0.2... | \n", "๐ | \n", "[0.5634451019066403, 0.0992767915844839, 0.337... | \n", "im just tryna change your life | \n", "
47088 | \n", "๐ฑ | \n", "[0.4503130614757538, 0.27487510442733765, 0.27... | \n", "๐ | \n", "[0.46813021474490496, 0.24716181096977158, 0.2... | \n", "Do I look like Iโm off 79th . Foh | \n", "
3337 rows ร 5 columns
\n", "Failed to display Jupyter Widget of type Text
.
\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 Jupyter\n", " Widgets Documentation for setup instructions.\n", "
\n", "\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "
\n" ], "text/plain": [ "Text(value='')" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "d34382a5e13c4be396303afc6b138c2a", "version_major": 2, "version_minor": 0 }, "text/html": [ "Failed to display Jupyter Widget of type VBox
.
\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 Jupyter\n", " Widgets Documentation for setup instructions.\n", "
\n", "\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "
\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", " display(Markdown(\"# \" + str(sent2emoji(pred))))\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": [ "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 }