R/datasets.R

dataset_imdb

IMDB Movie reviews sentiment classification

Description

Dataset of 25,000 movies reviews from IMDB, labeled by sentiment (positive/negative). Reviews have been preprocessed, and each review is encoded as a sequence of word indexes (integers). For convenience, words are indexed by overall frequency in the dataset, so that for instance the integer “3” encodes the 3rd most frequent word in the data. This allows for quick filtering operations such as: “only consider the top 10,000 most common words, but eliminate the top 20 most common words”.

Usage

 
dataset_imdb( 
  path = "imdb.npz", 
  num_words = NULL, 
  skip_top = 0L, 
  maxlen = NULL, 
  seed = 113L, 
  start_char = 1L, 
  oov_char = 2L, 
  index_from = 3L 
) 
 
dataset_imdb_word_index(path = "imdb_word_index.json") 

Arguments

Arguments Description
path Where to cache the data (relative to ~/.keras/dataset).
num_words Max number of words to include. Words are ranked by how often they occur (in the training set) and only the most frequent words are kept
skip_top Skip the top N most frequently occuring words (which may not be informative).
maxlen sequences longer than this will be filtered out.
seed random seed for sample shuffling.
start_char The start of a sequence will be marked with this character. Set to 1 because 0 is usually the padding character.
oov_char Words that were cut out because of the num_words or skip_top limit will be replaced with this character.
index_from Index actual words with this index and higher.

Details

As a convention, “0” does not stand for a specific word, but instead is used to encode any unknown word.

Value

Lists of training and test data: train$x, train$y, test$x, test$y. The x data includes integer sequences. If the num_words argument was specific, the maximum possible index value is num_words-1. If the maxlen`` argument was specified, the largest possible sequence length ismaxlen. Theydata includes a set of integer labels (0 or 1). Thedataset_imdb_word_index()` function returns a list where the names are words and the values are integer.

See Also

Other datasets: dataset_boston_housing(), dataset_cifar100(), dataset_cifar10(), dataset_fashion_mnist(), dataset_mnist(), dataset_reuters()