Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Apache Spark 2.x Machine Learning Cookbook

You're reading from   Apache Spark 2.x Machine Learning Cookbook Over 100 recipes to simplify machine learning model implementations with Spark

Arrow left icon
Product type Paperback
Published in Sep 2017
Publisher Packt
ISBN-13 9781783551606
Length 666 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (5):
Arrow left icon
 Amirghodsi Amirghodsi
Author Profile Icon Amirghodsi
Amirghodsi
Mohammed Guller Mohammed Guller
Author Profile Icon Mohammed Guller
Mohammed Guller
Shuen Mei Shuen Mei
Author Profile Icon Shuen Mei
Shuen Mei
 Rajendran Rajendran
Author Profile Icon Rajendran
Rajendran
 Hall Hall
Author Profile Icon Hall
Hall
+1 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Title Page
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Practical Machine Learning with Spark Using Scala FREE CHAPTER 2. Just Enough Linear Algebra for Machine Learning with Spark 3. Spark's Three Data Musketeers for Machine Learning - Perfect Together 4. Common Recipes for Implementing a Robust Machine Learning System 5. Practical Machine Learning with Regression and Classification in Spark 2.0 - Part I 6. Practical Machine Learning with Regression and Classification in Spark 2.0 - Part II 7. Recommendation Engine that Scales with Spark 8. Unsupervised Clustering with Apache Spark 2.0 9. Optimization - Going Down the Hill with Gradient Descent 10. Building Machine Learning Systems with Decision Tree and Ensemble Models 11. Curse of High-Dimensionality in Big Data 12. Implementing Text Analytics with Spark 2.0 ML Library 13. Spark Streaming and Machine Learning Library

Two methods of ingesting and preparing a CSV file for processing in Spark


In this recipe, we explore reading, parsing, and preparing a CSV file for a typical ML program. A comma-separated values (CSV) file normally stores tabular data (numbers and text) in a plain text file. In a typical CSV file, each row is a data record, and most of the time, the first row is called the header row, which stores the field's identifier (more commonly referred to as a column name for the field). Each record of one or fields, separated by commas.

How to do it...

  1. The sample CSV data file is from movie ratings. The file can be retrieved at http://files.grouplens.org/datasets/movielens/ml-latest-small.zip.
  1. Once the file is extracted, we will use the ratings.csv file for our CSV program to load the data into Spark. The CSV files will look like the following:

userId

movieId

rating

timestamp

1

16

4

1217897793

1

24

1.5

1217895807

1

32

4

1217896246

1

47

4

1217896556

1

50

4

1217896523

1

110

4

1217896150

1

150

3

1217895940

1

161

4

1217897864

1

165

3

1217897135...

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 £13.99/month. Cancel anytime
Visually different images