Project - How to Build a Sentiment Classifier using Python and IMDB Reviews

4 / 11

Exploring the Data

  • Let us see how the data looks like.

Note:

  • datasets["train"] contains the train data. Similarly, datasets["test"] contains the test data.

  • datasets["train"].batch(2) batches 2 data samples at a time.

  • datasets["train"].batch(2).take(1) allows to take 1 batch at a time.

  • Each batch is of type Eager Temsor. We could convert it to numpy array using X_batch.numpy().

INSTRUCTIONS
  • We shall traverse through the batches and show the review(first 200 characters) and label of the first batch data samples:

    for X_batch, y_batch in datasets["train"].batch(2).take(1):
        for review, label in zip(X_batch.numpy(), y_batch.numpy()):
            print("Review:", review.decode("utf-8")[:200], "...")
            print("Label:", label, "= Positive" if label else "= Negative")
            print()
    
Get Hint See Answer


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...