Reader small image

You're reading from  Machine Learning with Apache Spark Quick Start Guide

Product typeBook
Published inDec 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781789346565
Edition1st Edition
Languages
Right arrow
Author (1)
Jillur Quddus
Jillur Quddus
author image
Jillur Quddus

Jillur Quddus is a lead technical architect, polyglot software engineer and data scientist with over 10 years of hands-on experience in architecting and engineering distributed, scalable, high-performance, and secure solutions used to combat serious organized crime, cybercrime, and fraud. Jillur has extensive experience of working within central government, intelligence, law enforcement, and banking, and has worked across the world including in Japan, Singapore, Malaysia, Hong Kong, and New Zealand. Jillur is both the founder of Keisan, a UK-based company specializing in open source distributed technologies and machine learning, and the lead technical architect at Methods, the leading digital transformation partner for the UK public sector.
Read more about Jillur Quddus

Right arrow

Real-Time Machine Learning Using Apache Spark

In this chapter, we will extend our deployment of machine learning models beyond batch processing in order to learn from data, make predictions, and identify trends in real time! We will develop and deploy a real-time stream processing and machine learning application comprised of the following high-level technologies:

  • Apache Kafka producer application
  • Apache Kafka consumer application
  • Apache Spark's Structured Streaming engine
  • Apache Spark's machine learning library, MLlib

Distributed streaming platform

So far in this book, we have been performing batch processing—that is, we have been provided with bounded raw data files and processed that data as a group. As we saw in Chapter 1, The Big Data Ecosystem, stream processing differs from batch processing in the fact that data is processed as and when individual units, or streams, of data arrive. We also saw in Chapter 1, The Big Data Ecosystem, how Apache Kafka, as a distributed streaming platform, allows us to move real-time data between systems and applications in a fault-tolerant and reliable manner via a logical streaming architecture comprising of the following components:

  • Producers: Applications that generate and send messages
  • Consumers: Applications that subscribe to and consume messages
  • Topics: Streams of records belonging to a particular category and stored as a sequence of ordered...

Distributed stream processing engines

Apache Kafka allows us to move real-time data reliably between systems and applications. But we still need some sort of processing engine to process and transform that real-time data in order ultimately to derive value from it based on the use case in question. Fortunately, there are a number of stream processing engines available to allow us to do this, including—but not limited—to the following:

Though a detailed comparison of the available stream processing engines is beyond the scope of this book, you are encouraged to explore the preceding links...

Stream processing pipeline

In this section, we will develop an end-to-end stream processing pipeline that is capable of streaming data from a source system that generates continuous data, and thereafter able to publish those streams to an Apache Kafka distributed cluster. Our stream processing pipeline will then use Apache Spark to both consume data from Apache Kafka, using its Structured Streaming engine, and apply trained machine learning models to these streams in order to derive insights in real time using MLlib. The end-to-end stream processing pipeline that we will develop is illustrated in Figure 8.4:

Figure 8.4: Our end-to-end stream processing pipeline

Case study – real-time sentiment analysis

In the case...

Summary

In this chapter, we developed Apache Kafka producer and consumer applications and utilized Spark's Structured Streaming engine to process streaming data consumed from a Kafka topic. In our real-world case study, we designed, developed, and deployed an end-to-end stream processing pipeline that was capable of consuming real tweets being authored across the world and then classified their underlying sentiment using machine learning, all of which was done in real time.

In this book, we went on both a theoretical and a hands-on journey through some of the most important and exciting technologies and frameworks that underpin the data-intelligence-driven revolution being seen across industry today. We started out by describing a new breed of distributed and scalable technologies that allow us to store, process, and analyze huge volumes of structured, semi-structured, and...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Machine Learning with Apache Spark Quick Start Guide
Published in: Dec 2018Publisher: PacktISBN-13: 9781789346565
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.
undefined
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 $15.99/month. Cancel anytime

Author (1)

author image
Jillur Quddus

Jillur Quddus is a lead technical architect, polyglot software engineer and data scientist with over 10 years of hands-on experience in architecting and engineering distributed, scalable, high-performance, and secure solutions used to combat serious organized crime, cybercrime, and fraud. Jillur has extensive experience of working within central government, intelligence, law enforcement, and banking, and has worked across the world including in Japan, Singapore, Malaysia, Hong Kong, and New Zealand. Jillur is both the founder of Keisan, a UK-based company specializing in open source distributed technologies and machine learning, and the lead technical architect at Methods, the leading digital transformation partner for the UK public sector.
Read more about Jillur Quddus