Creating a sentiment analyzer
The model we are going to create will be a binary classifier for sentiments (1=Positive/0=Negative) from the IMDb sentiments dataset. This is a dataset for binary sentiment classification that contains a set of 25,000 sentiment labeled movie reviews for training and 25,000 for testing:

Figure 7.1 – Example of sentiment analysis being used on two samples
Similar to the Reuters example from Chapter 4, Image Classification and Regression Using AutoKeras, each review is encoded as a list of word indexes (integers). For convenience, words are indexed by their overall frequency in the dataset. So, for instance, the integer 3 encodes the third most frequent word in the data.
The notebook that contains the complete source code can be found at https://github.com/PacktPublishing/Automated-Machine-Learning-with-AutoKeras/blob/main/Chapter07/Chapter7_IMDB_sentiment_analysis.ipynb.
Now, let's have a look at the relevant...