February 2018
Beginner to intermediate
258 pages
5h 47m
English
Alternatively, and perhaps more interestingly, we can use a trained model to predict sentiment. We can train our model in a larger corpus and then simply apply it online to the new examples that come.
First, let's load our model and the vector embedding that we trained before for the movie reviews:
wv <- read.csv("./data/wv.csv")model <- load_model_hdf5("glove_nn.hdf5")
As before, we join the vector representations with the data in tidy form:
df <- wv%>% inner_join(text_df)
And take the average of those vectors per Tweet as the embedded representation of our Tweet:
df <- df %>% group_by(tweet_id) %>% summarize_all(mean) %>% select(1:51) preds <- model %>% predict(as.matrix(df[,2:51]))hist(preds[,1])
As we structured ...
Read now
Unlock full access