Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nvti committed May 12, 2020
1 parent 2b729bd commit 52403e0
Showing 1 changed file with 142 additions and 24 deletions.
166 changes: 142 additions & 24 deletions Assignments/Assignment 1/exploring_word_vectors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -978,15 +978,35 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 42,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"[('ends', 0.6128067970275879),\n",
" ('leaf', 0.6027014255523682),\n",
" ('stems', 0.5998532772064209),\n",
" ('takes', 0.5902855396270752),\n",
" ('leaving', 0.5761634111404419),\n",
" ('grows', 0.5663397312164307),\n",
" ('flowers', 0.5600922107696533),\n",
" ('turns', 0.5536050796508789),\n",
" ('leave', 0.5496848225593567),\n",
" ('goes', 0.5434924960136414)]"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
" # ------------------\n",
" # Write your implementation here.\n",
"# ------------------\n",
"# Write your implementation here.\n",
"\n",
"\n",
" # ------------------"
"wv_from_bin.most_similar(\"leaves\")\n",
"# ------------------"
]
},
{
Expand All @@ -1013,15 +1033,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 44,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.19722837209701538\n",
"0.7167813181877136\n"
]
}
],
"source": [
" # ------------------\n",
" # Write your implementation here.\n",
"\n",
"\n",
" # ------------------"
"# ------------------\n",
"# Write your implementation here.\n",
"print(wv_from_bin.distance('men', 'women'))\n",
"print(wv_from_bin.distance('men', 'king'))\n",
"# ------------------"
]
},
{
Expand All @@ -1047,9 +1076,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 45,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('queen', 0.6978678703308105),\n",
" ('princess', 0.6081745028495789),\n",
" ('monarch', 0.5889754891395569),\n",
" ('throne', 0.5775108933448792),\n",
" ('prince', 0.5750998258590698),\n",
" ('elizabeth', 0.5463595986366272),\n",
" ('daughter', 0.5399125814437866),\n",
" ('kingdom', 0.5318052172660828),\n",
" ('mother', 0.5168544054031372),\n",
" ('crown', 0.5164473056793213)]\n"
]
}
],
"source": [
"# Run this cell to answer the analogy -- man : king :: woman : x\n",
"pprint.pprint(wv_from_bin.most_similar(positive=['woman', 'king'], negative=['man']))"
Expand All @@ -1067,13 +1113,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 46,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('cold', 0.6264682412147522),\n",
" ('cool', 0.5971968770027161),\n",
" ('warm', 0.5749486088752747),\n",
" ('heat', 0.5509929060935974),\n",
" ('wet', 0.5442032814025879),\n",
" ('temperatures', 0.5357182025909424),\n",
" ('dry', 0.5311398506164551),\n",
" ('weather', 0.5237288475036621),\n",
" ('cooler', 0.5152636170387268),\n",
" ('hotter', 0.501091718673706)]\n"
]
}
],
"source": [
" # ------------------\n",
" # Write your implementation here.\n",
"\n",
"pprint.pprint(wv_from_bin.most_similar(positive=['winter', 'hot'], negative=['summer']))\n",
"\n",
" # ------------------"
]
Expand Down Expand Up @@ -1126,9 +1189,37 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 47,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('employee', 0.6375863552093506),\n",
" ('workers', 0.6068919897079468),\n",
" ('nurse', 0.5837947130203247),\n",
" ('pregnant', 0.5363885760307312),\n",
" ('mother', 0.5321309566497803),\n",
" ('employer', 0.5127025842666626),\n",
" ('teacher', 0.5099577307701111),\n",
" ('child', 0.5096741914749146),\n",
" ('homemaker', 0.5019455552101135),\n",
" ('nurses', 0.4970571994781494)]\n",
"\n",
"[('workers', 0.611325740814209),\n",
" ('employee', 0.5983108878135681),\n",
" ('working', 0.5615329742431641),\n",
" ('laborer', 0.5442320108413696),\n",
" ('unemployed', 0.5368517637252808),\n",
" ('job', 0.5278826951980591),\n",
" ('work', 0.5223963260650635),\n",
" ('mechanic', 0.5088937282562256),\n",
" ('worked', 0.5054520964622498),\n",
" ('factory', 0.4940453767776489)]\n"
]
}
],
"source": [
"# Run this cell\n",
"# Here `positive` indicates the list of words to be similar to and `negative` indicates the list of words to be\n",
Expand Down Expand Up @@ -1156,14 +1247,41 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 49,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('waved', 0.7440091371536255),\n",
" ('flags', 0.6568725109100342),\n",
" ('cheering', 0.6446677446365356),\n",
" ('banners', 0.6004939079284668),\n",
" ('chanting', 0.5811529159545898),\n",
" ('placards', 0.5701406002044678),\n",
" ('shouting', 0.5681235790252686),\n",
" ('slogans', 0.5568947196006775),\n",
" ('chanted', 0.5365853905677795),\n",
" ('shouted', 0.5337547659873962)]\n",
"[('waved', 0.7243529558181763),\n",
" ('cheering', 0.6555410623550415),\n",
" ('banners', 0.6392576098442078),\n",
" ('flags', 0.6310420632362366),\n",
" ('chanting', 0.610493004322052),\n",
" ('placards', 0.5842955708503723),\n",
" ('brandishing', 0.5838682651519775),\n",
" ('marched', 0.5790764689445496),\n",
" ('shouting', 0.5765238404273987),\n",
" ('chanted', 0.5760204792022705)]\n"
]
}
],
"source": [
" # ------------------\n",
" # Write your implementation here.\n",
"\n",
"\n",
"pprint.pprint(wv_from_bin.most_similar(positive=['white', 'waving'], negative=['black']))\n",
"pprint.pprint(wv_from_bin.most_similar(positive=['black', 'waving'], negative=['white']))\n",
" # ------------------"
]
},
Expand Down

0 comments on commit 52403e0

Please sign in to comment.