in [ ]generate averaged word vector features from word vec model avg_wv_train_features averaged_word vec_vectorizer(corpus=tokenized_trainmodel= v_modelnum_features= avg_wv_test_features averaged_word vec_vectorizer(corpus=tokenized_testmodel= v_modelnum_features= the glove modelwhich stands for global vectorsis an unsupervised model for obtaining word vector representations created at stanford universitythis model is trained on various corpora like wikipediacommon crawland twitter and corresponding pre-trained word vectors are available that can be used for our analysis needs you can refer to the original paper by jeffrey penningtonrichard socherand christopher manning called gloveglobal vectors for word representationfor more details the spacy library provided -dimensional word vectors trained on the common crawl corpus using the glove model they provide simple standard interface to get feature vectors of size for each word as well as the averaged feature vector of complete text document the following snippet leverages spacy to get the glove embeddings for our two datasets do note that you can also build your own glove model by leveraging other pre-trained models or by building model on your own corpus by using the resources available at in [ ]feature engineering with glove model train_nlp [tn nlp(itemfor item in norm_train_reviewstrain_glove_features np array([item vector for item in train_nlp]test_nlp [tn nlp(itemfor item in norm_test_reviewstest_glove_features np array([item vector for item in test_nlp]you can check the feature vector dimensions for our datasets based on each of the previous models using the following code in [ ]print('word vec model:train features shape:'avg_wv_train_features shapetest features shape:'avg_wv_test_features shapeprint('glove model:train features shape:'train_glove_features shapetest features shape:'test_glove_features shapeword vec model:train features shape( test features shape( glove model:train features shape( test features shape( we can see from the preceding output that as expected the word vec model features are of size and the glove features are of size we can now proceed to step of our classification system workflow where we will build and train deep neural network on these features we have already briefly covered the various aspects and architectures with regard to deep neural networks in under the section "deep learningwe will be using fully-connected four layer deep neural network (multi-layer perceptron or deep annfor our model we do not count the input layer usually in any deep architecturehence our model will consist of three hidden layers of neurons or units and one output layer with two units that will be used to either predict positive or negative sentiment based on the input layer features figure - depicts our deep neural network model for sentiment classification