{ "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", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
EMOJIHASHTAGSLINKED_USERdatetimeidlangpersonreply_totext
0[๐Ÿ”ฅ, ๐Ÿ‘][][]2017-11-01 13:29:00925716304635547600en31507978NaNfashionbombdaily's photo <EMOJI><EMOJI>๐Ÿผ
1[๐Ÿคฆ][][]2017-11-01 13:29:00925716304664911900en231994649NaNItโ€™s scary how on point my horoscope be <EMOJI...
2[๐Ÿ˜„][][]2017-11-01 13:29:03925716317214089200en2592765104NaNWoooaaaahhh <EMOJI>
3[๐Ÿ“ท][][]2017-11-01 13:29:04925716321416949800en278737933NaN<EMOJI> vivalcli: Portraits by Zhao Guojing an...
4[๐Ÿ˜ฉ, ๐Ÿ˜ฉ][][@hiphopphiIes]2017-11-01 13:29:06925716329801310200en8245862536349819009.257162e+17<USER> i wanna know too<EMOJI><EMOJI>
5[๐Ÿ˜ญ, ๐Ÿ’“][][@WizMommma]2017-11-01 13:29:02925716313019965400en15819538149.257088e+17<USER> veda was yoda too <EMOJI><EMOJI>
6[๐Ÿ˜‚][][]2017-11-01 13:29:05925716325607133200en1001999683NaNIโ€™m less stressed about turning 30 now <EMOJI>...
7[๐Ÿ’ฏ][][]2017-11-01 13:29:07925716334008082400en745222369183043600NaNFull charged. <EMOJI>
8[๐Ÿ™„][][@SeaDimon, @lsarsour]2017-11-01 13:29:09925716342401052700en7985571552175391009.257147e+17<USER> Thatโ€™s part of the problem, (they) <USE...
9[๐Ÿ˜Ÿ, ๐Ÿ˜ฅ, ๐Ÿ˜ข][][@Ian_khetye]2017-11-01 13:29:10925716346570240000en7443960391264215009.250629e+17<USER> got me emotional there<EMOJI><EMOJI><EM...
10[๐ŸŒป][][]2017-11-01 13:29:13925716359182520300en7214900101182054008.965900e+17back to the yellow <EMOJI>
11[๐Ÿ, ๐ŸŒบ, ๐Ÿ‚][][@Dimafadma]2017-11-01 13:29:15925716367558545400en5205367239.257159e+17<USER> Happy month to you and your loved ones ...
12[๐Ÿƒ][#mortdale, #partofthefamily, #gorgeousboy][]2017-11-01 13:29:16925716371735900200en850852815941517300NaNMaxx and Patricia. Family hangs at For Good He...
13[๐Ÿ’ญ, ๐Ÿคฆ][][]2017-11-01 13:29:20925716388513230800en914145041588867100NaNI need to STOP beating myself up with my thoug...
14[๐Ÿ˜, ๐Ÿ˜˜][#7YearsOfKMH2][]2017-11-01 13:29:20925716388525645800en2425405622NaNCutest Son <EMOJI>Roll no. 31 <EMOJI> <HASHTAG>
15[๐Ÿ˜œ][][]2017-11-01 13:29:22925716396931240000en4614871873NaNBy the summer I should have everything up and ...
16[๐Ÿ˜‚, ๐Ÿ”ฅ][][]2017-11-01 13:29:23925716401125331000en2831608345NaNI know my English is not that good but that do...
17[๐Ÿ’•][][@yungbabytate]2017-11-01 13:29:23925716401133948900en7885719746330092009.255778e+17<USER> I <EMOJI> u mama
18[๐Ÿ˜‰][][@cmckenney]2017-11-01 13:29:23925716401125544000en2183078029.257115e+17<USER> That picture was NOT taken this morning...
19[๐Ÿ‘…][#footfetishnation][]2017-11-01 13:29:25925716409489002500en885261166146179100NaNWelcome to <HASHTAG> <EMOJI>
20[๐Ÿ‘Œ, ๐Ÿ™‚][][]2017-11-01 13:29:25925716409497272300en831437760833609700NaNAwkward <EMOJI><EMOJI>
21[๐Ÿค—, ๐Ÿ“บ][][]2017-11-01 13:29:26925716413699854300en231664542NaNback at it with supernatural <EMOJI><EMOJI>
22[๐Ÿ’ฏ][][]2017-11-01 13:29:26925716413679009800en3196847035NaNOne of the best things I've learned was to sto...
23[๐Ÿ‘…, ๐Ÿ’ฆ, ๐Ÿ‘][][@ctrlpurp]2017-11-01 13:29:29925716426278735900en9184928583526359009.257161e+17<USER> Can I taste?<EMOJI><EMOJI><EMOJI>
24[๐Ÿ’”][][@saunders_court1]2017-11-01 13:29:30925716430473039900en34711873379.257163e+17<USER> we miss you โ˜น๏ธ<EMOJI>
25[๐Ÿค, ๐Ÿค, ๐Ÿค][][]2017-11-01 13:29:31925716434667184100en780060488600199200NaNActually my bias in WJSN are Eunseo &amp; Bona...
26[๐Ÿ˜ด][][]2017-11-01 13:29:32925716438853345300en388380690NaNI so cannot be bothered with the rest of the d...
27[๐Ÿ˜‚][][@xxxtentacion]2017-11-01 13:29:35925716451457163300en899320696869974000NaN<USER> 2lit4life<EMOJI>
28[๐Ÿ˜‚, ๐Ÿ™„][][]2017-11-01 13:29:35925716451461357600en784790670NaNIโ€™m not stop saying that!<EMOJI><EMOJI>
29[๐ŸŽ‰, ๐ŸŽ‚, ๐ŸŽˆ, ๐ŸŽŠ, ๐ŸŽ, ๐Ÿ’œ][][@justinerooney_]2017-11-01 13:29:37925716459828936700en3051266655NaN<USER> HAPPY BIHDAY <EMOJI><EMOJI><EMOJI><EMOJ...
..............................
68703[๐Ÿ˜•][#halloweencostumes][]2017-11-01 07:23:04925624214522036200en1672876458NaN<HASHTAG> this one falls under the weird crazy...
68704[๐Ÿ˜‚, ๐Ÿ˜ฉ][][]2017-11-01 07:23:05925624218682777600en382473866NaNI'm not allowed to have chocolates yet, then I...
68705[๐Ÿ˜‚][#MUFC][]2017-11-01 07:23:06925624222889766900en893145405457911800NaNManchester United manager Mourinho slams 'spec...
68706[๐Ÿ’–][][]2017-11-01 07:23:07925624227088121900en240378516NaN<EMOJI> en Bushwhick
68707[๐ŸŒ†, ๐Ÿ‘‰, ๐Ÿš–, ๐Ÿ“ž][#BurkeCentre][]2017-11-01 07:23:18925624273237983200en784620573209002000NaN: <HASHTAG> <EMOJI> <EMOJI><EMOJI> For Taxi <E...
68708[๐Ÿ˜][][@mychosliaheart, @BarrettoJulia, @iamjoshuaga...2017-11-01 07:23:18925624273212805100en1709981879.254136e+17<USER> <USER> <USER> Look, Mammeh and Daddeh! ...
68709[๐Ÿ˜‹][][]2017-11-01 07:23:24925624298395533300en1348667816NaNLife is so good with you <EMOJI>
68710[๐Ÿ‘Œ, ๐ŸŽƒ, ๐Ÿ˜˜][#portlandoregon, #portlandhalloween, #carrieโ€ฆ][]2017-11-01 07:23:24925624298378801200en722481645765300200NaNHappy Halloween! <EMOJI>๐Ÿฝ<EMOJI><EMOJI> <HASHT...
68711[๐Ÿ‘][][@8limbsbondi...]2017-11-01 07:23:26925624306779897900en2443251500NaNSome work on the ropes in todayโ€™s boxing class...
68712[๐Ÿ˜ญ][][]2017-11-01 07:23:27925624310974136300en2406186390NaNScotty and Kristenโ€™s halloween costumes <EMOJI>
68713[๐Ÿ˜‚][][@rfrandrea, @AdaaanAndyyy]2017-11-01 07:23:30925624323557146600en10394481499.256150e+17<USER> <USER> May pre-month celebration sis <E...
68714[๐Ÿ˜ญ, ๐Ÿ˜ญ, ๐Ÿ’˜][][@peachshua1230]2017-11-01 07:23:31925624327755591700en8450855445896724009.256009e+17<USER> Awww <EMOJI> Ajsksjdjd im smiling like ...
68715[๐Ÿ˜ซ, โœ‹][][]2017-11-01 07:23:34925624340342812700en924752524871131100NaNI hate when I send a text or snap n I'm so anx...
68716[๐Ÿ˜‚, ๐Ÿ™][][]2017-11-01 07:23:34925624340355280900en419493819NaNThe answer is no I have no plans and I never l...
68717[๐Ÿ˜ญ][][@BeachBoy_Gab]2017-11-01 07:23:34925624340346937300en24577459529.256219e+17<USER> LMAOOO I'm so proud <EMOJI>
68718[๐Ÿ˜ข, ๐Ÿ’”][][]2017-11-01 07:23:34925624340338507800en1955767531NaNMy cousin/little sister is leaving to San Fran...
68719[๐Ÿ™ƒ][][]2017-11-01 07:23:35925624344524361700en796490344581898200NaNCan't be alone w my thoughts tonight so just g...
68720[๐Ÿ˜‚, ๐Ÿ˜‚, ๐Ÿ˜‚, ๐Ÿ˜‚, ๐Ÿ˜‚][][]2017-11-01 07:23:36925624348710285300en907808317124177900NaN<EMOJI><EMOJI><EMOJI><EMOJI><EMOJI> ambot!!!
68721[๐Ÿ‘Œ, ๐Ÿ‘Š, ๐Ÿ™Œ][][]2017-11-01 07:23:37925624352929910800en262162415NaN<EMOJI>๐Ÿฝ<EMOJI>๐Ÿฝ 1st of the month!!Happy 1st o...
68722[๐Ÿ˜ด][#WednesdayWisdom][]2017-11-01 07:23:41925624369715515400en574882525NaN<HASHTAG> ... stay in bed <EMOJI>
68723[๐Ÿ˜‚, ๐Ÿ˜‚, ๐Ÿ˜‚, ๐Ÿ˜‚][][@Louis_Tomlinson, @NiallOfficial]2017-11-01 07:23:44925624382269124600en5561751739.254038e+17<USER> <USER> THIS IS GOLD. GOLD. <EMOJI><EMOJ...
68724[๐Ÿ˜€][][]2017-11-01 07:23:45925624386455031800en1610265588NaN<EMOJI> thank you for the kind compliment
68725[๐Ÿ˜Ž][][]2017-11-01 07:23:45925624386454937600en4760724450NaNEnjoyed the silence <EMOJI>
68726[โœจ][][]2017-11-01 07:23:46925624390657572900en882858115636514800NaNOS: Spiderman Homecoming <EMOJI>
68727[๐Ÿคท][][]2017-11-01 07:23:46925624390682849300en188129628NaNGo to hell <EMOJI>๐Ÿฝโ€โ™€๏ธ
68728[๐Ÿ˜˜][][]2017-11-01 07:23:46925624390666129400en2473135939NaNThank you Yomi! <EMOJI>
68729[๐Ÿ˜‚][][@discopiggu]2017-11-01 07:23:46925624390670106600en23735842099.256241e+17<USER> Lol. Just enjoy the stars. Music Kidhar...
68730[๐Ÿ™][#NYCStrong][]2017-11-01 07:23:50925624407459971100en181689756NaNThoughts and prayers for NY<EMOJI>๐Ÿป <HASHTAG>
68731[๐Ÿ’][#GreatSuccess][@BrianyH]2017-11-01 07:23:50925624407460057100en601607889.254610e+17<USER> I searched COCK, PENIS, SHLONG, WINKY, ...
68732[๐Ÿƒ, ๐ŸŒป, ๐ŸŒป, ๐Ÿƒ, ๐Ÿƒ, ๐Ÿ’, ๐Ÿ’, ๐Ÿƒ, ๐Ÿ™‹][][@amitbarman520]2017-11-01 07:23:53925624420022063100en37922907259.256215e+17<USER> Thank you so much<EMOJI><EMOJI><EMOJI><...
\n", "

68733 rows ร— 9 columns

\n", "
" ], "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 ๐Ÿผ \n", "1 Itโ€™s scary how on point my horoscope be \n", "3 vivalcli: Portraits by Zhao Guojing an... \n", "4 i wanna know too \n", "5 veda was yoda too \n", "6 Iโ€™m less stressed about turning 30 now ... \n", "7 Full charged. \n", "8 Thatโ€™s part of the problem, (they) got me emotional there \n", "11 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 Roll no. 31 \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 I u mama \n", "18 That picture was NOT taken this morning... \n", "19 Welcome to \n", "20 Awkward \n", "21 back at it with supernatural \n", "22 One of the best things I've learned was to sto... \n", "23 Can I taste? \n", "24 we miss you โ˜น๏ธ \n", "25 Actually my bias in WJSN are Eunseo & Bona... \n", "26 I so cannot be bothered with the rest of the d... \n", "27 2lit4life \n", "28 Iโ€™m not stop saying that! \n", "29 HAPPY BIHDAY 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 en Bushwhick \n", "68707 : For Taxi Look, Mammeh and Daddeh! ... \n", "68709 Life is so good with you \n", "68710 Happy Halloween! ๐Ÿฝ \n", "68713 May pre-month celebration sis Awww 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 LMAOOO I'm so proud \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 ambot!!! \n", "68721 ๐Ÿฝ๐Ÿฝ 1st of the month!!Happy 1st o... \n", "68722 ... stay in bed \n", "68723 THIS IS GOLD. GOLD. thank you for the kind compliment \n", "68725 Enjoyed the silence \n", "68726 OS: Spiderman Homecoming \n", "68727 Go to hell ๐Ÿฝโ€โ™€๏ธ \n", "68728 Thank you Yomi! \n", "68729 Lol. Just enjoy the stars. Music Kidhar... \n", "68730 Thoughts and prayers for NY๐Ÿป \n", "68731 I searched COCK, PENIS, SHLONG, WINKY, ... \n", "68732 Thank you so much<... \n", "\n", "[68733 rows x 9 columns]" ] }, "execution_count": 6, "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": 7, "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 `` (just for the beginning)\n", " * removing remaining useless emojis, like skin modifier etc." ] }, { "cell_type": "code", "execution_count": 8, "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": 9, "metadata": {}, "outputs": [], "source": [ "# filtering them and the EMOJI keyword out:\n", "plain_text = plain_text.str.replace(\"(||)\",\"\").str.replace(\"[\" + \"\".join(list(emoji_blacklist)) + \"]\",\"\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* defining different criterias for choosing a single emoji (currently `latest` is used)" ] }, { "cell_type": "code", "execution_count": 10, "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": "markdown", "metadata": {}, "source": [ "* convert all emojis to a sentiment vector" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "labels = emoji2sent([latest(e) for e in emojis])\n" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "68733" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(labels)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "wrong_labels = np.isnan(np.linalg.norm(labels, axis=1))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* remove all data we have no label for" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "labels = labels[np.invert(wrong_labels)]\n", "plain_text = plain_text[np.invert(wrong_labels)]\n", "emojis = emojis[np.invert(wrong_labels)]" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "33368 33368 33368\n" ] } ], "source": [ "print(len(labels), len(emojis), len(plain_text))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* generate weights:" ] }, { "cell_type": "code", "execution_count": 16, "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": [ "* most used emojis in Dataset" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "import operator" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[('๐Ÿ˜‚', 10182), ('๐Ÿ˜ญ', 3893), ('๐Ÿ˜', 2866), ('๐Ÿ˜ฉ', 1647), ('๐Ÿ˜Š', 1450)]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "['๐Ÿ˜‚', '๐Ÿ˜ญ', '๐Ÿ˜', '๐Ÿ˜ฉ', '๐Ÿ˜Š']" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "sorted_emoji_count = list(reversed(sorted(emoji_count.items(), key=operator.itemgetter(1))))\n", "display(sorted_emoji_count[:5])\n", "\n", "top_emojis = [x[0] for x in sorted_emoji_count[:5]]\n", "display(top_emojis)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* only learn the most used ones:" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "17815 17815 17815\n" ] } ], "source": [ "in_top = [sentiment_vector_to_emoji(x) in top_emojis for x in labels]\n", "labels = labels[in_top]\n", "plain_text = plain_text[in_top]\n", "emojis = emojis[in_top]\n", "print(len(labels), len(emojis), len(plain_text))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* generating train and test set:" ] }, { "cell_type": "code", "execution_count": 20, "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": 21, "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 sent2emoji(y1)])" ] }, { "cell_type": "code", "execution_count": 22, "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": 23, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "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": 25, "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, epochs=n_iter)#, sample_weight=y1_weights[:max_size])\n", " \n", " return clf" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Train on 800 samples, validate on 200 samples\n", "Epoch 1/100\n", "800/800 [==============================] - 1s 690us/step - loss: 1.0883 - acc: 0.6925 - val_loss: 1.0760 - val_acc: 0.7400\n", "Epoch 2/100\n", "800/800 [==============================] - 0s 527us/step - loss: 1.0732 - acc: 0.7150 - val_loss: 1.0628 - val_acc: 0.7400\n", "Epoch 3/100\n", "800/800 [==============================] - 0s 528us/step - loss: 1.0651 - acc: 0.7150 - val_loss: 1.0556 - val_acc: 0.7400\n", "Epoch 4/100\n", "800/800 [==============================] - 0s 534us/step - loss: 1.0610 - acc: 0.7150 - val_loss: 1.0515 - val_acc: 0.7400\n", "Epoch 5/100\n", "800/800 [==============================] - 0s 534us/step - loss: 1.0589 - acc: 0.7150 - val_loss: 1.0493 - val_acc: 0.7400\n", "Epoch 6/100\n", "800/800 [==============================] - 0s 511us/step - loss: 1.0579 - acc: 0.7150 - val_loss: 1.0481 - val_acc: 0.7400\n", "Epoch 7/100\n", "800/800 [==============================] - 0s 546us/step - loss: 1.0573 - acc: 0.7150 - val_loss: 1.0473 - val_acc: 0.7400\n", "Epoch 8/100\n", "800/800 [==============================] - 0s 545us/step - loss: 1.0571 - acc: 0.7150 - val_loss: 1.0469 - val_acc: 0.7400\n", "Epoch 9/100\n", "800/800 [==============================] - 0s 522us/step - loss: 1.0570 - acc: 0.7150 - val_loss: 1.0467 - val_acc: 0.7400\n", "Epoch 10/100\n", "800/800 [==============================] - 0s 529us/step - loss: 1.0569 - acc: 0.7150 - val_loss: 1.0466 - val_acc: 0.7400\n", "Epoch 11/100\n", "800/800 [==============================] - 0s 551us/step - loss: 1.0568 - acc: 0.7150 - val_loss: 1.0465 - val_acc: 0.7400\n", "Epoch 12/100\n", "800/800 [==============================] - 0s 529us/step - loss: 1.0568 - acc: 0.7150 - val_loss: 1.0464 - val_acc: 0.7400\n", "Epoch 13/100\n", "800/800 [==============================] - 0s 546us/step - loss: 1.0568 - acc: 0.7150 - val_loss: 1.0464 - val_acc: 0.7400\n", "Epoch 14/100\n", "800/800 [==============================] - 0s 609us/step - loss: 1.0567 - acc: 0.7150 - val_loss: 1.0464 - val_acc: 0.7400\n", "Epoch 15/100\n", "800/800 [==============================] - 0s 610us/step - loss: 1.0567 - acc: 0.7150 - val_loss: 1.0463 - val_acc: 0.7400\n", "Epoch 16/100\n", "800/800 [==============================] - 0s 540us/step - loss: 1.0567 - acc: 0.7150 - val_loss: 1.0464 - val_acc: 0.7400\n", "Epoch 17/100\n", "800/800 [==============================] - 0s 518us/step - loss: 1.0567 - acc: 0.7150 - val_loss: 1.0463 - val_acc: 0.7400\n", "Epoch 18/100\n", "800/800 [==============================] - 0s 547us/step - loss: 1.0567 - acc: 0.7150 - val_loss: 1.0463 - val_acc: 0.7400\n", "Epoch 19/100\n", "800/800 [==============================] - 0s 543us/step - loss: 1.0566 - acc: 0.7150 - val_loss: 1.0463 - val_acc: 0.7400\n", "Epoch 20/100\n", "800/800 [==============================] - 0s 550us/step - loss: 1.0566 - acc: 0.7150 - val_loss: 1.0463 - val_acc: 0.7400\n", "Epoch 21/100\n", "800/800 [==============================] - 0s 551us/step - loss: 1.0566 - acc: 0.7150 - val_loss: 1.0463 - val_acc: 0.7400\n", "Epoch 22/100\n", "800/800 [==============================] - 0s 552us/step - loss: 1.0566 - acc: 0.7150 - val_loss: 1.0463 - val_acc: 0.7400\n", "Epoch 23/100\n", "800/800 [==============================] - 0s 620us/step - loss: 1.0566 - acc: 0.7150 - val_loss: 1.0463 - val_acc: 0.7400\n", "Epoch 24/100\n", "800/800 [==============================] - 0s 587us/step - loss: 1.0566 - acc: 0.7150 - val_loss: 1.0463 - val_acc: 0.7400\n", "Epoch 25/100\n", "800/800 [==============================] - 0s 608us/step - loss: 1.0565 - acc: 0.7150 - val_loss: 1.0464 - val_acc: 0.7400\n", "Epoch 26/100\n", "800/800 [==============================] - 0s 538us/step - loss: 1.0565 - acc: 0.7150 - val_loss: 1.0463 - val_acc: 0.7400\n", "Epoch 27/100\n", "800/800 [==============================] - 0s 545us/step - loss: 1.0565 - acc: 0.7150 - val_loss: 1.0464 - val_acc: 0.7400\n", "Epoch 28/100\n", "800/800 [==============================] - 0s 567us/step - loss: 1.0565 - acc: 0.7150 - val_loss: 1.0464 - val_acc: 0.7400\n", "Epoch 29/100\n", "256/800 [========>.....................] - ETA: 0s - loss: 1.0609 - acc: 0.6992" ] }, { "ename": "KeyboardInterrupt", "evalue": "", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mclf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtrain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmax_size\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1000\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mlayers\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m200\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'relu'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m200\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'relu'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m200\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'linear'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0my1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'softmax'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mn_iter\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m100\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m\u001b[0m in \u001b[0;36mtrain\u001b[0;34m(max_size, layers, random_state, ovrc, n_iter)\u001b[0m\n\u001b[1;32m 21\u001b[0m \u001b[0mclf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mOVRC\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmodel\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0movrc\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 22\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 23\u001b[0;31m \u001b[0mclf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvec_train\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0mmax_size\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mA\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0mmax_size\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalidation_split\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0.2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mepochs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mn_iter\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;31m#, sample_weight=y1_weights[:max_size])\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 24\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mclf\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/.local/lib/python3.6/site-packages/keras/engine/training.py\u001b[0m in \u001b[0;36mfit\u001b[0;34m(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)\u001b[0m\n\u001b[1;32m 1040\u001b[0m \u001b[0minitial_epoch\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0minitial_epoch\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1041\u001b[0m \u001b[0msteps_per_epoch\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msteps_per_epoch\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1042\u001b[0;31m validation_steps=validation_steps)\n\u001b[0m\u001b[1;32m 1043\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1044\u001b[0m def evaluate(self, x=None, y=None,\n", "\u001b[0;32m~/.local/lib/python3.6/site-packages/keras/engine/training_arrays.py\u001b[0m in \u001b[0;36mfit_loop\u001b[0;34m(model, f, ins, out_labels, batch_size, epochs, verbose, callbacks, val_f, val_ins, shuffle, callback_metrics, initial_epoch, steps_per_epoch, validation_steps)\u001b[0m\n\u001b[1;32m 197\u001b[0m \u001b[0mins_batch\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mins_batch\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtoarray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 198\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 199\u001b[0;31m \u001b[0mouts\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mins_batch\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 200\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mouts\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 201\u001b[0m \u001b[0mouts\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mouts\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/.local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, inputs)\u001b[0m\n\u001b[1;32m 2659\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_legacy_call\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minputs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2660\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2661\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_call\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minputs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2662\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2663\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mpy_any\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mis_tensor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mx\u001b[0m \u001b[0;32min\u001b[0m \u001b[0minputs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/.local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py\u001b[0m in \u001b[0;36m_call\u001b[0;34m(self, inputs)\u001b[0m\n\u001b[1;32m 2629\u001b[0m \u001b[0msymbol_vals\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2630\u001b[0m session)\n\u001b[0;32m-> 2631\u001b[0;31m \u001b[0mfetched\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_callable_fn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0marray_vals\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2632\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mfetched\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0moutputs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2633\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args)\u001b[0m\n\u001b[1;32m 1449\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_session\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_created_with_new_api\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1450\u001b[0m return tf_session.TF_SessionRunCallable(\n\u001b[0;32m-> 1451\u001b[0;31m self._session._session, self._handle, args, status, None)\n\u001b[0m\u001b[1;32m 1452\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1453\u001b[0m return tf_session.TF_DeprecatedSessionRunCallable(\n", "\u001b[0;31mKeyboardInterrupt\u001b[0m: " ] } ], "source": [ "clf = train(max_size=1000,layers=[(200, 'relu'),(200, 'relu'),(200, 'linear'),(y1[0].shape[0],'softmax')], n_iter=100)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* make a prediction and store it in a csv file:" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "pred = clf.predict(vectorizer.transform(Xt1))" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "8.1356275e-06\n", "0.02568319204819897\n" ] } ], "source": [ "print(np.linalg.norm(np.var(pred, axis=0)))\n", "print(np.linalg.norm(np.var(labels)))\n" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "# build a dataframe to visualize test results:\n", "testlist = pd.DataFrame({'text': Xt1, \n", " 'teacher': sent2emoji(yt1),\n", " 'teacher_sentiment': yt1.tolist(),\n", " 'predict': sent2emoji(pred),\n", " 'predicted_sentiment': pred.tolist()})" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
textteacherteacher_sentimentpredictpredicted_sentiment
7618There's fucking snow outside๐Ÿ˜’[0.21660649819494585, 0.5913357400722021, 0.19...๐Ÿ˜ฌ[0.46037721633911133, 0.2677566707134247, 0.27...
6910You look so animated bro! *Rimshot*, Get it? ...๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.4636985957622528, 0.26727861166000366, 0.26...
35783Jon ordered it from a restaurant๐Ÿ˜ญ[0.34310532030401736, 0.4364820846905538, 0.22...๐Ÿ˜ฌ[0.4635818898677826, 0.2673886716365814, 0.269...
15623I just want to move back in with my mom๐Ÿ˜…[0.47186147186147187, 0.2922077922077922, 0.23...๐Ÿ˜ฌ[0.46267321705818176, 0.2673114538192749, 0.27...
12023guys lets vote!!!๐Ÿ˜ญ[0.34310532030401736, 0.4364820846905538, 0.22...๐Ÿ˜ฌ[0.4621191620826721, 0.26737213134765625, 0.27...
15763Bruhhhh this man need a show ASAP!!!๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.46237292885780334, 0.2675153613090515, 0.27...
57240AND THE RICH SIT IN A LOW PLACE๐Ÿ˜Ž[0.5981432360742706, 0.10477453580901856, 0.29...๐Ÿ˜ฌ[0.4622046649456024, 0.2677682340145111, 0.270...
2418Time to go to bed๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.4639696180820465, 0.26709380745887756, 0.26...
66384May sound like a hillbilly, but girls that can...๐Ÿ˜[0.7296744771190439, 0.05173769460607014, 0.21...๐Ÿ˜ฌ[0.4639129638671875, 0.26741719245910645, 0.26...
44639IM DYING๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.46023082733154297, 0.27063173055648804, 0.2...
54463Black forest hot chocolate is coming back to C...๐Ÿ™Œ[0.6613545816733067, 0.10092961487383798, 0.23...๐Ÿ˜ฌ[0.46065258979797363, 0.2685313820838928, 0.27...
384075 days till my 21st.๐Ÿ˜Ž[0.5981432360742706, 0.10477453580901856, 0.29...๐Ÿ˜ฌ[0.4624767005443573, 0.2678660750389099, 0.269...
31342I'm just going to leave my Twitter acct open ...๐Ÿ˜„[0.5586552217453505, 0.13662374821173104, 0.30...๐Ÿ˜ฌ[0.4628538191318512, 0.2673165500164032, 0.269...
41255Oh god im so happy๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.4628150463104248, 0.26765838265419006, 0.26...
19686In my head๐Ÿ˜ญ[0.34310532030401736, 0.4364820846905538, 0.22...๐Ÿ˜ฌ[0.4624774158000946, 0.26805710792541504, 0.26...
67193Jo, chilllllllll. This kid is mentally beati...๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.4607327878475189, 0.26832473278045654, 0.27...
40650Iโ€™m ready sis๐Ÿ˜‡[0.6666666666666666, 0.06666666666666667, 0.26...๐Ÿ˜ฌ[0.4610658884048462, 0.26784956455230713, 0.27...
64416Sometimes we need to know how to respect our p...๐Ÿ˜Š[0.7040175768989329, 0.059322033898305086, 0.2...๐Ÿ˜ฌ[0.46121352910995483, 0.27051451802253723, 0.2...
19525Right?๐Ÿ™†[0.5964912280701754, 0.08771929824561403, 0.31...๐Ÿ˜ฌ[0.46745917201042175, 0.265864759683609, 0.266...
39024priceless love how got back at you๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.4606868028640747, 0.267996221780777, 0.2713...
35342Right๐Ÿ˜ซ[0.3404710920770878, 0.4860813704496788, 0.173...๐Ÿ˜ฌ[0.46745917201042175, 0.265864759683609, 0.266...
9715Opo pang i will!๐Ÿ˜‡[0.6666666666666666, 0.06666666666666667, 0.26...๐Ÿ˜ฌ[0.45438939332962036, 0.2717699408531189, 0.27...
40490WOW whomever was tasked with vetting applica...๐Ÿ˜ฎ[0.45555555555555555, 0.17777777777777778, 0.3...๐Ÿ˜ฌ[0.46492910385131836, 0.2654315233230591, 0.26...
22064Thank you !๐Ÿ˜[0.7296744771190439, 0.05173769460607014, 0.21...๐Ÿ˜ฌ[0.46712905168533325, 0.26472848653793335, 0.2...
53563Dat daurin Dan kwali from behind is the real ...๐Ÿ˜„[0.5586552217453505, 0.13662374821173104, 0.30...๐Ÿ˜ฌ[0.4643474817276001, 0.2679416835308075, 0.267...
67332I miss my baby so much โ™ฅ๏ธ๐Ÿ˜ช[0.3506224066390041, 0.4315352697095436, 0.217...๐Ÿ˜ฌ[0.4613974094390869, 0.2683691382408142, 0.270...
15404alright i'm gonna go take a shower, let me kno...๐Ÿ˜•[0.20294117647058824, 0.6029411764705882, 0.19...๐Ÿ˜ฌ[0.46027225255966187, 0.2696966826915741, 0.27...
30130and neither are buying her music๐Ÿ˜ณ[0.34515366430260047, 0.32742316784869974, 0.3...๐Ÿ˜ฌ[0.46355295181274414, 0.26728588342666626, 0.2...
37242I saw that too as well! I feel to have it dur...๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.46367916464805603, 0.26611489057540894, 0.2...
30533I had a mental break down but Iโ€™m back like hey๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.4640607535839081, 0.26755788922309875, 0.26...
..................
16955Bless up Esquivel finally update aeries๐Ÿ™[0.4983755685510071, 0.08057179987004548, 0.42...๐Ÿ˜ฌ[0.46489447355270386, 0.26702189445495605, 0.2...
36805Look just like my Mizuno I had in โ€˜88๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.4630420207977295, 0.26803845167160034, 0.26...
56326This felt like it happened yesterday.๐Ÿ˜ข[0.39118825100133514, 0.38451268357810414, 0.2...๐Ÿ˜ฌ[0.4617263972759247, 0.26921841502189636, 0.26...
40306Our Guest photo this week highlights the beaut...๐Ÿ˜[0.7296744771190439, 0.05173769460607014, 0.21...๐Ÿ˜ฌ[0.46200209856033325, 0.26775091886520386, 0.2...
51333I need to see what โ€œthe stranger thingsโ€ is ab...๐Ÿ˜Œ[0.6240601503759399, 0.13984962406015036, 0.23...๐Ÿ˜ฌ[0.46260306239128113, 0.26784563064575195, 0.2...
42339Plz can u make me a pc I donโ€™t have enough mo...๐Ÿ˜”[0.31784232365145226, 0.46390041493775935, 0.2...๐Ÿ˜ฌ[0.4600381553173065, 0.26839619874954224, 0.27...
7644this is insulting๐Ÿ˜ง[0.32608695652173914, 0.391304347826087, 0.282...๐Ÿ˜ฌ[0.4657018482685089, 0.2653878927230835, 0.268...
13953I know this might sound crazy but I rather Don...๐Ÿ˜[0.16296296296296298, 0.5555555555555556, 0.28...๐Ÿ˜ฌ[0.4625128209590912, 0.26891759037971497, 0.26...
26460Just a couple of cute pugs hanging out๐Ÿ˜›[0.6909090909090909, 0.08181818181818182, 0.22...๐Ÿ˜ฌ[0.46720531582832336, 0.26648813486099243, 0.2...
31571She knows nothing will happen to her.. welcom...๐Ÿ˜’[0.21660649819494585, 0.5913357400722021, 0.19...๐Ÿ˜ฌ[0.4603578746318817, 0.2692199945449829, 0.270...
9536happy raisin๐Ÿ˜ญ[0.34310532030401736, 0.4364820846905538, 0.22...๐Ÿ˜ฌ[0.4630625247955322, 0.26809123158454895, 0.26...
19571I'm so disappointed๐Ÿ˜ก[0.35978835978835977, 0.533068783068783, 0.107...๐Ÿ˜ฌ[0.4639342725276947, 0.26599037647247314, 0.27...
35934Nailed it.๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.46198946237564087, 0.26730334758758545, 0.2...
4605oh itโ€™s more than a thing!๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.46141430735588074, 0.268981009721756, 0.269...
1913stop it๐Ÿ˜ญ[0.34310532030401736, 0.4364820846905538, 0.22...๐Ÿ˜ฌ[0.4630756378173828, 0.2665313482284546, 0.270...
11827Have an awesome โค๏ธ๐Ÿ˜„[0.5586552217453505, 0.13662374821173104, 0.30...๐Ÿ˜ฌ[0.46398892998695374, 0.26717185974121094, 0.2...
15181when I see elbows ?๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.45438939332962036, 0.2717699408531189, 0.27...
32869Damn Jani back at it again with the BB-8 costu...๐Ÿ˜น[0.4406779661016949, 0.2983050847457627, 0.261...๐Ÿ˜ฌ[0.4616232216358185, 0.2673903703689575, 0.270...
40784I think a big part of the reason Nick Wilde is...๐Ÿ˜ป[0.6906474820143885, 0.0671462829736211, 0.242...๐Ÿ˜ฌ[0.46204957365989685, 0.26713815331459045, 0.2...
18611My 12 year old brother on Altuve- โ€œheโ€™s like t...๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.4634704887866974, 0.2669770121574402, 0.269...
28341Bruh like how she know the exact number?๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.46148979663848877, 0.26869532465934753, 0.2...
41368They starting early๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.4605691730976105, 0.26995062828063965, 0.26...
35554Please come through๐Ÿ˜ฉ[0.22289823008849557, 0.5912610619469026, 0.18...๐Ÿ˜ฌ[0.46297168731689453, 0.2675779163837433, 0.26...
27968Thank you๐Ÿ˜[0.7296744771190439, 0.05173769460607014, 0.21...๐Ÿ˜ฌ[0.46712905168533325, 0.26472848653793335, 0.2...
36772Imagine if the Vikings had a top 10 QB๐Ÿ˜ณ[0.34515366430260047, 0.32742316784869974, 0.3...๐Ÿ˜ฌ[0.4609829783439636, 0.26704034209251404, 0.27...
7568Le costume de cupcakke.......๐Ÿ˜ญ[0.34310532030401736, 0.4364820846905538, 0.22...๐Ÿ˜ฌ[0.46219775080680847, 0.26761168241500854, 0.2...
62837aM FKXNSK SCREAMING ODM๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.46401336789131165, 0.2654089033603668, 0.27...
34105My birthday tomorrow๐Ÿ˜‡[0.6666666666666666, 0.06666666666666667, 0.26...๐Ÿ˜ฌ[0.4665740728378296, 0.26650139689445496, 0.26...
59069im just tryna change your life๐Ÿ˜‰[0.5634451019066403, 0.0992767915844839, 0.337...๐Ÿ˜ฌ[0.4622177183628082, 0.268806129693985, 0.2689...
47088Do I look like Iโ€™m off 79th . Foh๐Ÿ˜‚[0.46813021474490496, 0.24716181096977158, 0.2...๐Ÿ˜ฌ[0.46383899450302124, 0.26802247762680054, 0.2...
\n", "

3337 rows ร— 5 columns

\n", "
" ], "text/plain": [ " text teacher \\\n", "7618 There's fucking snow outside ๐Ÿ˜’ \n", "6910 You look so animated bro! *Rimshot*, Get it? ... ๐Ÿ˜‚ \n", "35783 Jon ordered it from a restaurant ๐Ÿ˜ญ \n", "15623 I just want to move back in with my mom ๐Ÿ˜… \n", "12023 guys lets vote!!! ๐Ÿ˜ญ \n", "15763 Bruhhhh this man need a show ASAP!!! ๐Ÿ˜‚ \n", "57240 AND THE RICH SIT IN A LOW PLACE ๐Ÿ˜Ž \n", "2418 Time to go to bed ๐Ÿ˜‚ \n", "66384 May sound like a hillbilly, but girls that can... ๐Ÿ˜ \n", "44639 IM DYING ๐Ÿ˜‚ \n", "54463 Black forest hot chocolate is coming back to C... ๐Ÿ™Œ \n", "38407 5 days till my 21st. ๐Ÿ˜Ž \n", "31342 I'm just going to leave my Twitter acct open ... ๐Ÿ˜„ \n", "41255 Oh god im so happy ๐Ÿ˜‚ \n", "19686 In my head ๐Ÿ˜ญ \n", "67193 Jo, chilllllllll. This kid is mentally beati... ๐Ÿ˜‚ \n", "40650 Iโ€™m ready sis ๐Ÿ˜‡ \n", "64416 Sometimes we need to know how to respect our p... ๐Ÿ˜Š \n", "19525 Right? ๐Ÿ™† \n", "39024 priceless love how got back at you ๐Ÿ˜‚ \n", "35342 Right ๐Ÿ˜ซ \n", "9715 Opo pang i will! ๐Ÿ˜‡ \n", "40490 WOW whomever was tasked with vetting applica... ๐Ÿ˜ฎ \n", "22064 Thank you ! ๐Ÿ˜ \n", "53563 Dat daurin Dan kwali from behind is the real ... ๐Ÿ˜„ \n", "67332 I miss my baby so much โ™ฅ๏ธ ๐Ÿ˜ช \n", "15404 alright i'm gonna go take a shower, let me kno... ๐Ÿ˜• \n", "30130 and neither are buying her music ๐Ÿ˜ณ \n", "37242 I saw that too as well! I feel to have it dur... ๐Ÿ˜‚ \n", "30533 I had a mental break down but Iโ€™m back like hey ๐Ÿ˜‚ \n", "... ... ... \n", "16955 Bless up Esquivel finally update aeries ๐Ÿ™ \n", "36805 Look just like my Mizuno I had in โ€˜88 ๐Ÿ˜‚ \n", "56326 This felt like it happened yesterday. ๐Ÿ˜ข \n", "40306 Our Guest photo this week highlights the beaut... ๐Ÿ˜ \n", "51333 I need to see what โ€œthe stranger thingsโ€ is ab... ๐Ÿ˜Œ \n", "42339 Plz can u make me a pc I donโ€™t have enough mo... ๐Ÿ˜” \n", "7644 this is insulting ๐Ÿ˜ง \n", "13953 I know this might sound crazy but I rather Don... ๐Ÿ˜ \n", "26460 Just a couple of cute pugs hanging out ๐Ÿ˜› \n", "31571 She knows nothing will happen to her.. welcom... ๐Ÿ˜’ \n", "9536 happy raisin ๐Ÿ˜ญ \n", "19571 I'm so disappointed ๐Ÿ˜ก \n", "35934 Nailed it. ๐Ÿ˜‚ \n", "4605 oh itโ€™s more than a thing! ๐Ÿ˜‚ \n", "1913 stop it ๐Ÿ˜ญ \n", "11827 Have an awesome โค๏ธ ๐Ÿ˜„ \n", "15181 when I see elbows ? ๐Ÿ˜‚ \n", "32869 Damn Jani back at it again with the BB-8 costu... ๐Ÿ˜น \n", "40784 I think a big part of the reason Nick Wilde is... ๐Ÿ˜ป \n", "18611 My 12 year old brother on Altuve- โ€œheโ€™s like t... ๐Ÿ˜‚ \n", "28341 Bruh like how she know the exact number? ๐Ÿ˜‚ \n", "41368 They starting early ๐Ÿ˜‚ \n", "35554 Please come through ๐Ÿ˜ฉ \n", "27968 Thank you ๐Ÿ˜ \n", "36772 Imagine if the Vikings had a top 10 QB ๐Ÿ˜ณ \n", "7568 Le costume de cupcakke....... ๐Ÿ˜ญ \n", "62837 aM FKXNSK SCREAMING ODM ๐Ÿ˜‚ \n", "34105 My birthday tomorrow ๐Ÿ˜‡ \n", "59069 im just tryna change your life ๐Ÿ˜‰ \n", "47088 Do I look like Iโ€™m off 79th . Foh ๐Ÿ˜‚ \n", "\n", " teacher_sentiment predict \\\n", "7618 [0.21660649819494585, 0.5913357400722021, 0.19... ๐Ÿ˜ฌ \n", "6910 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "35783 [0.34310532030401736, 0.4364820846905538, 0.22... ๐Ÿ˜ฌ \n", "15623 [0.47186147186147187, 0.2922077922077922, 0.23... ๐Ÿ˜ฌ \n", "12023 [0.34310532030401736, 0.4364820846905538, 0.22... ๐Ÿ˜ฌ \n", "15763 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "57240 [0.5981432360742706, 0.10477453580901856, 0.29... ๐Ÿ˜ฌ \n", "2418 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "66384 [0.7296744771190439, 0.05173769460607014, 0.21... ๐Ÿ˜ฌ \n", "44639 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "54463 [0.6613545816733067, 0.10092961487383798, 0.23... ๐Ÿ˜ฌ \n", "38407 [0.5981432360742706, 0.10477453580901856, 0.29... ๐Ÿ˜ฌ \n", "31342 [0.5586552217453505, 0.13662374821173104, 0.30... ๐Ÿ˜ฌ \n", "41255 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "19686 [0.34310532030401736, 0.4364820846905538, 0.22... ๐Ÿ˜ฌ \n", "67193 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "40650 [0.6666666666666666, 0.06666666666666667, 0.26... ๐Ÿ˜ฌ \n", "64416 [0.7040175768989329, 0.059322033898305086, 0.2... ๐Ÿ˜ฌ \n", "19525 [0.5964912280701754, 0.08771929824561403, 0.31... ๐Ÿ˜ฌ \n", "39024 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "35342 [0.3404710920770878, 0.4860813704496788, 0.173... ๐Ÿ˜ฌ \n", "9715 [0.6666666666666666, 0.06666666666666667, 0.26... ๐Ÿ˜ฌ \n", "40490 [0.45555555555555555, 0.17777777777777778, 0.3... ๐Ÿ˜ฌ \n", "22064 [0.7296744771190439, 0.05173769460607014, 0.21... ๐Ÿ˜ฌ \n", "53563 [0.5586552217453505, 0.13662374821173104, 0.30... ๐Ÿ˜ฌ \n", "67332 [0.3506224066390041, 0.4315352697095436, 0.217... ๐Ÿ˜ฌ \n", "15404 [0.20294117647058824, 0.6029411764705882, 0.19... ๐Ÿ˜ฌ \n", "30130 [0.34515366430260047, 0.32742316784869974, 0.3... ๐Ÿ˜ฌ \n", "37242 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "30533 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "... ... ... \n", "16955 [0.4983755685510071, 0.08057179987004548, 0.42... ๐Ÿ˜ฌ \n", "36805 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "56326 [0.39118825100133514, 0.38451268357810414, 0.2... ๐Ÿ˜ฌ \n", "40306 [0.7296744771190439, 0.05173769460607014, 0.21... ๐Ÿ˜ฌ \n", "51333 [0.6240601503759399, 0.13984962406015036, 0.23... ๐Ÿ˜ฌ \n", "42339 [0.31784232365145226, 0.46390041493775935, 0.2... ๐Ÿ˜ฌ \n", "7644 [0.32608695652173914, 0.391304347826087, 0.282... ๐Ÿ˜ฌ \n", "13953 [0.16296296296296298, 0.5555555555555556, 0.28... ๐Ÿ˜ฌ \n", "26460 [0.6909090909090909, 0.08181818181818182, 0.22... ๐Ÿ˜ฌ \n", "31571 [0.21660649819494585, 0.5913357400722021, 0.19... ๐Ÿ˜ฌ \n", "9536 [0.34310532030401736, 0.4364820846905538, 0.22... ๐Ÿ˜ฌ \n", "19571 [0.35978835978835977, 0.533068783068783, 0.107... ๐Ÿ˜ฌ \n", "35934 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "4605 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "1913 [0.34310532030401736, 0.4364820846905538, 0.22... ๐Ÿ˜ฌ \n", "11827 [0.5586552217453505, 0.13662374821173104, 0.30... ๐Ÿ˜ฌ \n", "15181 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "32869 [0.4406779661016949, 0.2983050847457627, 0.261... ๐Ÿ˜ฌ \n", "40784 [0.6906474820143885, 0.0671462829736211, 0.242... ๐Ÿ˜ฌ \n", "18611 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "28341 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "41368 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "35554 [0.22289823008849557, 0.5912610619469026, 0.18... ๐Ÿ˜ฌ \n", "27968 [0.7296744771190439, 0.05173769460607014, 0.21... ๐Ÿ˜ฌ \n", "36772 [0.34515366430260047, 0.32742316784869974, 0.3... ๐Ÿ˜ฌ \n", "7568 [0.34310532030401736, 0.4364820846905538, 0.22... ๐Ÿ˜ฌ \n", "62837 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "34105 [0.6666666666666666, 0.06666666666666667, 0.26... ๐Ÿ˜ฌ \n", "59069 [0.5634451019066403, 0.0992767915844839, 0.337... ๐Ÿ˜ฌ \n", "47088 [0.46813021474490496, 0.24716181096977158, 0.2... ๐Ÿ˜ฌ \n", "\n", " predicted_sentiment \n", "7618 [0.46037721633911133, 0.2677566707134247, 0.27... \n", "6910 [0.4636985957622528, 0.26727861166000366, 0.26... \n", "35783 [0.4635818898677826, 0.2673886716365814, 0.269... \n", "15623 [0.46267321705818176, 0.2673114538192749, 0.27... \n", "12023 [0.4621191620826721, 0.26737213134765625, 0.27... \n", "15763 [0.46237292885780334, 0.2675153613090515, 0.27... \n", "57240 [0.4622046649456024, 0.2677682340145111, 0.270... \n", "2418 [0.4639696180820465, 0.26709380745887756, 0.26... \n", "66384 [0.4639129638671875, 0.26741719245910645, 0.26... \n", "44639 [0.46023082733154297, 0.27063173055648804, 0.2... \n", "54463 [0.46065258979797363, 0.2685313820838928, 0.27... \n", "38407 [0.4624767005443573, 0.2678660750389099, 0.269... \n", "31342 [0.4628538191318512, 0.2673165500164032, 0.269... \n", "41255 [0.4628150463104248, 0.26765838265419006, 0.26... \n", "19686 [0.4624774158000946, 0.26805710792541504, 0.26... \n", "67193 [0.4607327878475189, 0.26832473278045654, 0.27... \n", "40650 [0.4610658884048462, 0.26784956455230713, 0.27... \n", "64416 [0.46121352910995483, 0.27051451802253723, 0.2... \n", "19525 [0.46745917201042175, 0.265864759683609, 0.266... \n", "39024 [0.4606868028640747, 0.267996221780777, 0.2713... \n", "35342 [0.46745917201042175, 0.265864759683609, 0.266... \n", "9715 [0.45438939332962036, 0.2717699408531189, 0.27... \n", "40490 [0.46492910385131836, 0.2654315233230591, 0.26... \n", "22064 [0.46712905168533325, 0.26472848653793335, 0.2... \n", "53563 [0.4643474817276001, 0.2679416835308075, 0.267... \n", "67332 [0.4613974094390869, 0.2683691382408142, 0.270... \n", "15404 [0.46027225255966187, 0.2696966826915741, 0.27... \n", "30130 [0.46355295181274414, 0.26728588342666626, 0.2... \n", "37242 [0.46367916464805603, 0.26611489057540894, 0.2... \n", "30533 [0.4640607535839081, 0.26755788922309875, 0.26... \n", "... ... \n", "16955 [0.46489447355270386, 0.26702189445495605, 0.2... \n", "36805 [0.4630420207977295, 0.26803845167160034, 0.26... \n", "56326 [0.4617263972759247, 0.26921841502189636, 0.26... \n", "40306 [0.46200209856033325, 0.26775091886520386, 0.2... \n", "51333 [0.46260306239128113, 0.26784563064575195, 0.2... \n", "42339 [0.4600381553173065, 0.26839619874954224, 0.27... \n", "7644 [0.4657018482685089, 0.2653878927230835, 0.268... \n", "13953 [0.4625128209590912, 0.26891759037971497, 0.26... \n", "26460 [0.46720531582832336, 0.26648813486099243, 0.2... \n", "31571 [0.4603578746318817, 0.2692199945449829, 0.270... \n", "9536 [0.4630625247955322, 0.26809123158454895, 0.26... \n", "19571 [0.4639342725276947, 0.26599037647247314, 0.27... \n", "35934 [0.46198946237564087, 0.26730334758758545, 0.2... \n", "4605 [0.46141430735588074, 0.268981009721756, 0.269... \n", "1913 [0.4630756378173828, 0.2665313482284546, 0.270... \n", "11827 [0.46398892998695374, 0.26717185974121094, 0.2... \n", "15181 [0.45438939332962036, 0.2717699408531189, 0.27... \n", "32869 [0.4616232216358185, 0.2673903703689575, 0.270... \n", "40784 [0.46204957365989685, 0.26713815331459045, 0.2... \n", "18611 [0.4634704887866974, 0.2669770121574402, 0.269... \n", "28341 [0.46148979663848877, 0.26869532465934753, 0.2... \n", "41368 [0.4605691730976105, 0.26995062828063965, 0.26... \n", "35554 [0.46297168731689453, 0.2675779163837433, 0.26... \n", "27968 [0.46712905168533325, 0.26472848653793335, 0.2... \n", "36772 [0.4609829783439636, 0.26704034209251404, 0.27... \n", "7568 [0.46219775080680847, 0.26761168241500854, 0.2... \n", "62837 [0.46401336789131165, 0.2654089033603668, 0.27... \n", "34105 [0.4665740728378296, 0.26650139689445496, 0.26... \n", "59069 [0.4622177183628082, 0.268806129693985, 0.2689... \n", "47088 [0.46383899450302124, 0.26802247762680054, 0.2... \n", "\n", "[3337 rows x 5 columns]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display(testlist)\n" ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [], "source": [ "testlist.to_csv('test.csv')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* a simple output widget for testing:" ] }, { "cell_type": "code", "execution_count": 63, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "865c37ebeb2443a589ccbaf220456457", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type Text.

\n", "

\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", "

\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 }