Gensim: A Python Library For NLP and Word Embeddings.: Import As Import As From Import From Import From Import
Gensim: A Python Library For NLP and Word Embeddings.: Import As Import As From Import From Import From Import
Select
10 words from a specific domain (e.g., sports, technology) and visualize their embeddings. Analyze
clusters and relationships.
Generate contextually rich outputs using embeddings. Write a program to generate 5 semantically
similar words for a given input
Soln:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
from sklearn.manifold import TSNE
from gensim.models import KeyedVectors
Output:
Output: Words similar to 'football': [('soccer', 0.8732221722602844),
('basketball', 0.8555637001991272), ('league', 0.815336287021637),
('rugby', 0.8007532954216003), ('hockey', 0.7833694815635681)]
Output: