code/chapter_14.py
def load_data(limit=0, split=0.8):
    """Load data from the IMDB dataset."""
    # Partition off part of the train data for evaluation
    train_data, _ = thinc.extra.datasets.imdb()
    random.shuffle(train_data)
    train_data = train_data[-limit:]
    texts, labels = zip(*train_data)
    cats = [{'POSITIVE': bool(y)} for y in labels]
    split = int(len(train_data) * split)
    return (texts[:split], cats[:split]), (texts[split:], cats[split:])
Load data from the IMDB dataset.
Load data from the IMDB dataset.
Load data from the IMDB dataset .
def load_data(limit=0, split=0.8):
    train_data, _ = thinc.extra.datasets.imdb()
    random.shuffle(train_data)
    train_data = train_data[-limit:]
    texts, labels = zip(*train_data)
    cats = [{'POSITIVE': bool(y)} for y in labels]
    split = int(len(train_data) * split)
    return (texts[:split], cats[:split]), (texts[split:], cats[split:])
def load_data ( limit = 0 , split = 0.8 ) : train_data , _ = thinc . extra . datasets . imdb ( ) random . shuffle ( train_data ) train_data = train_data [ - limit : ] texts , labels = zip ( * train_data ) cats = [ { 'POSITIVE' : bool ( y ) } for y in labels ] split = int ( len ( train_data ) * split ) return ( texts [ : split ] , cats [ : split ] ) , ( texts [ split : ] , cats [ split : ] )
Load data from the IMDB dataset.
Load data from the IMDB dataset .
"""Load data from the IMDB dataset.""" # Partition off part of the train data for evaluation
limit
split