February 2018
Beginner to intermediate
258 pages
5h 47m
English
We are ready to create the word embedding using GloVe. First, let's initialize an instance of the GlobalVectors class:
glove <- GlobalVectors$new(word_vectors_size = 50, vocabulary = vocab, x_max = 10)
We now apply the fit_transform method (scikit learn users might be familiar with it):
wv_main <- glove$fit_transform(tcm, n_iter = 10, convergence_tol = 0.01)
And once this is done, we have our vectorizer ready. We now need to parse our text:
text <- unlist(imdb$review)length(text)# 25000text_df <- data_frame(line = 1:25000, text = text)
And apply the unnest_tokens functions from tidytext to turn our data in a tidy format:
text_df <- text_df %>% unnest_tokens(word, text)head(text_df)
This gives a familiar output: ...
Read now
Unlock full access