Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Machine Learning with Spark 2.x

You're reading from   Mastering Machine Learning with Spark 2.x Harness the potential of machine learning, through spark

Arrow left icon
Product type Paperback
Published in Aug 2017
Publisher Packt
ISBN-13 9781785283451
Length 340 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (3):
Arrow left icon
Alex Tellez Alex Tellez
Author Profile Icon Alex Tellez
Alex Tellez
Michal Malohlava Michal Malohlava
Author Profile Icon Michal Malohlava
Michal Malohlava
Max Pumperla Max Pumperla
Author Profile Icon Max Pumperla
Max Pumperla
Arrow right icon
View More author details
Toc

Featurization - feature hashing

Now, it is time to transform string representation into a numeric one. We adopt a bag-of-words approach; however, we use a trick called feature hashing. Let's look in more detail at how Spark employs this powerful technique to help us construct and access our tokenized dataset efficiently. We use feature hashing as a time-efficient implementation of a bag-of-words, as explained earlier.

At its core, feature hashing is a fast and space-efficient method to deal with high-dimensional data-typical in working with text-by converting arbitrary features into indices within a vector or matrix. This is best described with an example text. Suppose we have the following two movie reviews:

  1. The movie Goodfellas was well worth the money spent. Brilliant acting!
  2. Goodfellas is a riveting movie with a great cast and a brilliant plot-a must see for all...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image