<jupyter_start><jupyter_text>Training word2vec **Importing libraries**<jupyter_code>from gensim.models import Word2Vec,KeyedVectors
from gensim.models.word2vec import LineSentence
from sklearn.metrics.pairwise import cosine_similarity
from numpy import dot
from numpy.linalg import norm
import warnings
warnings.filterwarnings('ignore')
import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"]="4"<jupyter_output><empty_output><jupyter_text>**Text to train**<jupyter_code>documents = [
     ['La','naranja','piña','y','manzana','son','frutas'],
     ['Los','jugos','de','naranja',',','piña','y','manzana','son','exquisitos'],
     ['El','jugo','de','naranja','o','zumo','de','naranja','es','un','jugo','de','frutas','en','forma','de','líquido','obtenido','de','exprimir','el','interior','de','las','naranjas'],
     ['Uno','de','los','usos','culinarios','primordiales','es','como','refresco','aunque','es','muy','empleado','en','muchos','desayunos','del','mundo'],
     ['En','Venezuela','se','conoce','como','jugo','de','naranja','a','la','naranjada',',','bebida','compuesta','de','dicho','zumo','en','una','concentración','de','60%','en','agua','y','azúcar'],
     ['El','jugo','o','zumo','de','manzana','es','el','líquido','extraído','de','la','manzana','(','Malus','domestica',')'],
     ['Se','trata','de','un','jugo','que','se','suele','manufacturar',',','envasar','y','comercializar'],
     ['El','jugo','o','zumo','de','piña',',','también','conocido','como','jugo','de','ananá',',','es','el','líquido','extraído','de','la','pulpa','de','la','piña',',','una','fruta','tropical'],
     ['El','jugo','de','piña','es','84%','de','agua',',','16%','de','carbohidratos','y','contiene','grasas','y','proteínas','insignificantes'],
]<jupyter_output><empty_output><jupyter_text>**Skip-gram**<jupyter_code>params = {
        'sentences':documents,
        'size': 50,
        'window': 5,
        'min_count': 1,
        'iter': 100,
        'sg': 1,
        'workers': 4
    }

word2vec = Word2Vec(**params)
word2vec.wv.vocab
word2vec.most_similar(positive=['zumo'], topn=5)<jupyter_output>/home/juanluis/anaconda3/envs/jupyter/lib/python3.7/site-packages/ipykernel_launcher.py:1: DeprecationWarning: Call to deprecated `most_similar` (Method will be removed in 4.0.0, use self.wv.most_similar() instead).
  """Entry point for launching an IPython kernel.<jupyter_text>**Documents without stopwords**<jupyter_code>documents = [
     ['naranja','piña','manzana','son','frutas'],
     ['jugos','naranja','piña','manzana','son','exquisitos'],
     ['jugo','naranja','zumo','naranja','es','jugo','frutas','forma','líquido','obtenido','exprimir','interior','naranjas'],
     ['usos','culinarios','primordiales','es','refresco','empleado','desayunos','mundo'],
     ['Venezuela','se','conoce','jugo','naranja','naranjada','bebida','compuesta','zumo','concentración','agua','azúcar'],
     ['jugo','zumo','manzana','es','líquido','extraído','manzana','Malus','domestica'],
     ['trata','jugo','suele','manufacturar','envasar','comercializar'],
     ['jugo','zumo','piña','también','conocido','jugo','ananá','es','líquido','extraído','pulpa','piña','fruta','tropical'],
     ['jugo','piña','es','agua','carbohidratos','contiene','grasas','proteínas','insignificantes'],
]
params = {
        'sentences':documents,
        'size': 50,
        'window': 5,
        'min_count': 1,
        'iter': 100,
        'sg': 1,
        'workers': 4
    }

word2vec = Word2Vec(**params)
word2vec.wv.vocab
word2vec.most_similar(positive=['zumo'], topn=5)<jupyter_output>/home/juanluis/anaconda3/envs/jupyter/lib/python3.7/site-packages/ipykernel_launcher.py:1: DeprecationWarning: Call to deprecated `most_similar` (Method will be removed in 4.0.0, use self.wv.most_similar() instead).
  """Entry point for launching an IPython kernel.
{'fraction_non_alphanumeric': 0.26443057722308894, 'fraction_numerical': 0.013520540821632865, 'mean_word_length': 8.314769975786925, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '587297', 'license': 'MIT', 'n_tokens_mistral': 1530, 'n_tokens_neox': 1455, 'n_words': 132, 'path': '2_Word_Embedding/word2vec(training).ipynb', 'repo_name': 'PonchoCeniceros/Escuela_Aprendizaje_Profundo_2020', 'size': '3846'}