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
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Big Data Analytics

You're reading from   Big Data Analytics Real time analytics using Apache Spark and Hadoop

Arrow left icon
Product type Paperback
Published in Sep 2016
Publisher Packt
ISBN-13 9781785884696
Length 326 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Venkat Ankam Venkat Ankam
Author Profile Icon Venkat Ankam
Venkat Ankam
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Big Data Analytics at a 10,000-Foot View 2. Getting Started with Apache Hadoop and Apache Spark FREE CHAPTER 3. Deep Dive into Apache Spark 4. Big Data Analytics with Spark SQL, DataFrames, and Datasets 5. Real-Time Analytics with Spark Streaming and Structured Streaming 6. Notebooks and Dataflows with Spark and Hadoop 7. Machine Learning with Spark and Hadoop 8. Building Recommendation Systems with Spark and Mahout 9. Graph Analytics with GraphX 10. Interactive Analytics with SparkR Index

Machine learning with SparkR

Spark version 1.5 added support for machine learning over DataFrames created in SparkR. SparkR currently supports the Generalized Linear Model, Accelerated Failure Time (AFT), Survival Regression Model, Naive Bayes Model, and K-Means algorithms in version 2.0.

Let's go through a couple of examples to understand how machine learning is implemented in SparkR.

Using the Naive Bayes model

Based on the Titanic survival dataset, let's analyze what sorts of people are likely to survive. The Titanic dataset is summarized according to economic status (class), sex, age, and survival. spark.naiveBayes() fits a Bernoulli Naive Bayes model against a Spark DataFrame. The steps to do so are as follows:

  1. Create a local DataFrame and convert it to a Spark DataFrame:
    > localDF <- as.data.frame(Titanic)
    > DF <- createDataFrame(localDF[localDF$Freq > 0, -5])
    
    > head(DF)
      Class    Sex   Age Survived
    1   3rd   Male Child       No
    2   3rd Female Child      ...
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