29
1 Confidential Kafka Streams + Deep Learning TensorFlow and H2O Applied to Real Time Streaming Applications Kai Waehner Technology Evangelist [email protected] LinkedIn @KaiWaehner www.kai-waehner.de

Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

Embed Size (px)

Citation preview

Page 1: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

1Confidential

Kafka Streams + Deep Learning TensorFlow and H2O Applied to Real Time Streaming Applications

Kai WaehnerTechnology Evangelist

[email protected]

LinkedIn

@KaiWaehner

www.kai-waehner.de

Page 2: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

2Apache Kafka and Deep Learning – Kai Waehner

Agenda

1) Deep Learning and Real Time World2) Deep Learning and the Apache Kafka Ecosystem3) Building Neural Networks with TensorFlow and H2O4) Deployment of Neural Networks with Kafka Streams

Page 3: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

3Apache Kafka and Deep Learning – Kai Waehner

Agenda

1) Deep Learning and Real World Applications2) Deep Learning and the Apache Kafka Ecosystem3) Building Neural Networks with TensorFlow and H2O4) Deployment of Neural Networks with Kafka Streams

Page 4: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

4Apache Kafka and Deep Learning – Kai Waehner

Machine Learning

... allows computers to find hidden insights without being explicitly programmed where to look.

Machine Learning• Decision Trees• Naïve Bayes• Clustering• Neural Networks• etc.

Deep Learning• CNN• RNN• Autoencoder• etc.

Page 5: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

5Apache Kafka and Deep Learning – Kai Waehner

Real World Examples of Deep Learning

Language Translation

https://recombu.com/mobile/article/google-instant-voice-translation-the-end-of-franglais_M11397.htmlhttp://wellroundedfashion.com/2015/01/13/trendy-tech-camouflage-from-facial-detection/http://www.washington.edu/news/2017/07/11/lip-syncing-obama-new-tools-turn-audio-clips-into-realistic-video/https://www.technologyreview.com/s/602796/starcraft-will-become-the-next-big-playground-for-ai/

Speech and Video Generation

Picture Analysis (Face, Location, Items, …)

Intelligent Decision Making

Page 6: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

6Apache Kafka and Deep Learning – Kai Waehner

Deep Learning to Analyze and Act on Critical Business Moments

Seconds Minutes Hours

Price Optimization

Predictive Maintenance

Fraud Detection

Cross Selling

Transportation Rerouting

Customer Service

Inventory Management

Windows of Opportunity

Page 7: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

7Apache Kafka and Deep Learning – Kai Waehner

Live Demo

Deep Learning in Actionhttp://playground.tensorflow.org/

Page 8: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

8Apache Kafka and Deep Learning – Kai Waehner

Agenda

1) Deep Learning and Real World Applications2) Deep Learning and the Apache Kafka Ecosystem3) Building Neural Networks with TensorFlow and H2O4) Deployment of Neural Networks with Kafka Streams

Page 9: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

9Apache Kafka and Deep Learning – Kai Waehner

Apache Kafka Ecosystem and Deep Learning

Kafka Streams

Kafka Connect

Rest Proxy

Schema Registry

Go / .NET / Python Kafka Producer

KSQL

Kafka Streams

Page 10: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

STREAMING PLATFORM

BIG DATA ANALYTICS

Oracle DB

CoaP IoT

Kafka Java Client

…..

HP Vertica

KAFKA

H2O.ai, TensorFlow

Batch

Real Time

ConfluentREST Proxy

MQTT IoT

iPhone App

KafkaGo Client

CK OA NF NK EA C

T

HIVE

Grafana

Kafka

Java EE Web App

Spark

CK OA NF NK EA C

T

Confluent Schema Registry

Kafka Streams

H2O.ai

Mesos

Kafka Streams

TensorFlow

Kubernetes

Avro

Avro

1) Data Producer2) Analytics Platform3) Streaming Platform4) Data Consumer

Page 11: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

11Apache Kafka and Deep Learning – Kai Waehner

Agenda

1) Deep Learning and Real World Applications2) Deep Learning and the Apache Kafka Ecosystem3) Building Neural Networks with TensorFlow and H2O4) Deployment of Neural Networks with Kafka Streams

Page 12: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

12Apache Kafka and Deep Learning – Kai Waehner

Languages, Frameworks and Tools for Deep Learning

There is no Allrounder!

Portable Format for Analytics (PFA)

Page 13: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

13Confidential

Deep Learning with H2O.ai

H2O Engine

R / Python /Scala / Flow UI

Java Code

Page 14: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

14Confidential

H2O Deep Water (TensorFlow, MXNet, …)

https://h2o-release.s3.amazonaws.com/h2o/rel-vapnik/1/docs-website/h2o-docs/booklets/DeepWaterBooklet.pdf

Deep Water(H2O + TensorFlow) Pre-Defined Networks

+User-Defined Networks

Page 15: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

15Apache Kafka and Deep Learning – Kai Waehner

Live Demo

Use Case: Airline Flight Delay Prediction

Machine Learning Algorithm:Deep Learningusing Neural Networks

Technology:H2O.ai, TensorFlow

Page 16: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

16Apache Kafka and Deep Learning – Kai Waehner

Agenda

1) Deep Learning and Real World Applications2) Deep Learning and the Apache Kafka Ecosystem3) Building Neural Networks with TensorFlow and H2O4) Deployment of Neural Networks with Kafka Streams

Page 17: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

17Apache Kafka and Deep Learning – Kai Waehner

Stream Processing

Data at Rest Data in Motion

Page 18: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

18Apache Kafka and Deep Learning – Kai Waehner

Stream Processing Pipeline

APIs

Adapters / Channels

Integration

Messaging

Stream Ingest

Transformation

Aggregation

Enrichment

Filtering

StreamPreprocessing

Process Management

Analytics (Real Time)

Applications& APIs

Analytics / DW Reporting

StreamOutcomes

• Contextual Rules

• Windowing

• Patterns

• Analytics

• Machine Learning

• …

Stream Analytics

Index / SearchNormalization

Applying an Analytic Modelis just a piece of the puzzle!

Page 19: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

19Apache Kafka and Deep Learning – Kai Waehner

Kafka Streams (shipped with Apache Kafka)

Map, filter, aggregate,

apply analytic model,

„any business logic“

Input Stream(Kafka Topic)

Kafka Cluster

Output Stream(Kafka Topic)

Kafka Cluster

Stream ProcessingMicroservice

(Kafka Streams)

Deployed AnywhereJava App, Docker,

Kubernetes, Mesos,“you-name-it”

Page 20: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

20Apache Kafka and Deep Learning – Kai Waehner

When to use Kafka Streams for Stream Processing?

Page 21: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

21Apache Kafka and Deep Learning – Kai Waehner

A complete streaming microservices, ready for production at large-scale

WordCount

App configuration

Define processing(here: WordCount)

Start processing

Page 22: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

22Apache Kafka and Deep Learning – Kai Waehner

Use Case: Airline Flight Delay Prediction

Machine Learning Algorithm:Neural Network built with H2O and TensorFlow

Streaming Platform:Apache Kafka and Kafka Streams

Live Demo

Page 23: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

23Apache Kafka and Deep Learning – Kai Waehner

H2O.ai Model + Kafka Streams

Filter

Map

1) Create H2O DL model

2) Configure Kafka Streams Application

3) Apply H2O DL model to Streaming Data

4) Start Kafka Streams App

Page 24: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

24Apache Kafka and Deep Learning – Kai Waehner

Github Examples: Kafka + Deep Learning

https://github.com/kaiwaehner/kafka-streams-machine-learning-examples

1) git clone … 2) mvn clean package … 3) look at implementations and unit tests

Page 25: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

25Apache Kafka and Deep Learning – Kai Waehner

Online Model Training with Apache Kafka and Kafka Streams

How to improve models?

1. Manual Update

2. Automated Batch

3. Real Time

Your choice… All possible with Kafka!

Page 26: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

26Apache Kafka and Deep Learning – Kai Waehner

Caveats for Online Model Training

• Processes and infrastructure not ready

• Validation needed before production

• Slows down the system

• Only a few ML implementations à Build your own!

• Many use cases do not need it

à Do it only when really needed!

Page 27: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

27Apache Kafka and Deep Learning – Kai Waehner

Key Take-Aways

à Data Scientist and Developers have to work together continuously (org + tech!)

à Mission critical, scalable production deployment is key for success of Machine Learning projects

à Apache Kafka Ecosystem for Batch and Real Time Machine Learning (Training, Inference, Monitoring)

Page 28: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

28Apache Kafka and Deep Learning – Kai Waehner

Confluent KSQL à www.confluent.io/product/ksqlUse SQL-like queries to write stream processing applications with Kafka Streams

Leverage Kafka and Kafka Streams from anywhere without coding• Streaming ETL• Anomaly Detection• Real Time Monitoring• etc.

SELECT STREAMCEIL(timestamp TO HOUR) AS timeWindow, productId, COUNT(*) AS hourlyOrders, SUM(units) AS units

FROM Orders GROUP BY CEIL(timestamp TO HOUR), productId;

timeWindow | productId | hourlyOrders | units------------+-----------+--------------+-------

08:00:00 | 10 | 2 | 508:00:00 | 20 | 1 | 809:00:00 | 10 | 4 | 2209:00:00 | 40 | 1 | 45

... | ... | ... | ...

à … maybe also use it to apply analytic models via user defined functions? J

Page 29: Kafka Streams + Deep Learning - RainFocus Streams + Deep Learning ... MQTT IoT iPhone App Kafka Go Client C K O A N F N K E A C T H I V E ... Apache Kafka and Deep Learning –Kai

29Apache Kafka and Deep Learning – Kai Waehner

Kai WaehnerTechnology Evangelist

[email protected]@KaiWaehnerwww.kai-waehner.deLinkedIn

Questions? Feedback?Please contact me!