import gensim.downloader as api import numpy as np import matplotlib.pyplot as plt from sklearn.decomposition import PCA print("Loading model... (This may take a while)") model = api.load("word2vec-google-news-300") print("Model Loaded") tech_words = [ "computer", "algorithm", "software", "hardware", "AI", "cloud", "database", "network", "programming", "internet" ] word_vectors = np.array([model[word] for word in tech_words]) pca = PCA(n_components=2) reduced_vectors = pca.fit_transform(word_vectors) plt.figure(figsize=(8, 6)) for word, (x, y) in zip(tech_words, reduced_vectors): plt.scatter(x, y) plt.text(x + 0.02, y + 0.02, word, fontsize=12) plt.title("2D Visualization of Technology Word Embeddings") plt.xlabel("PCA Component 1") plt.ylabel("PCA Component 2") plt.grid() plt.show() def find_similar_words(word): try: similar_words = model.most_similar(word, topn=5) print(f"\n5 words similar to '{word}':") for w, score in similar_words: print(f"{w}: {score:.4f}") except KeyError: print(f"'{word}' not found in the vocabulary.") find_similar_words("AI")