Skip to Content
Hands-On Machine Learning for Algorithmic Trading
book

Hands-On Machine Learning for Algorithmic Trading

by Stefan Jansen
December 2018
Beginner to intermediate
684 pages
21h 9m
English
Packt Publishing
Content preview from Hands-On Machine Learning for Algorithmic Trading

Model training

The gensim.models.Word2vec class implements the SG and CBOW architectures introduced previously. The Word2vec notebook contains additional implementation detail.

To facilitate memory-efficient text ingestion, the LineSentence class creates a generator from individual sentences contained in the provided text file:

sentence_path = Path('data', 'ngrams', f'ngrams_2.txt')sentences = LineSentence(sentence_path)

The Word2vec class offers the configuration options previously introduced:

model = Word2vec(sentences,                 sg=1,    # 1=skip-gram; otherwise CBOW                 hs=0,    # hier. softmax if 1, neg. sampling if 0                 size=300,      # Vector dimensionality                 window=3,      # Max dist. btw target and context word                 min_count=50,  # Ignore words with lower frequency                 negative ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Machine Learning for Algorithmic Trading - Second Edition

Machine Learning for Algorithmic Trading - Second Edition

Stefan Jansen

Publisher Resources

ISBN: 9781789346411Supplemental Content