SlideShare a Scribd company logo
1 of 40
Real Time Machine Learning
Visualization with Spark
Chester Chen
Director of Engineering
Alpine Data
May 3, 2016
COMPANY CONFIDENTIAL2
Who am I ?
• Director of Engineering at Alpine Data
• Founder and Organizer of SF Big Analytics Meetup (4000+ members)
• Previous Employment:
– Symantec, AltaVista, Ascent Media, ClearStory Systems, WebWare.
• Experience with Spark
– Exposed to Spark since Spark 0.6
– Architect for Alpine Spark Integration on Spark 1.1, 1.3 and 1.5.x
• Hadoop Distribution
– CDH, HDP and MapR
COMPANY CONFIDENTIAL3
Alpine Data at a Glance
Enterprise Scale Predictive Analytics with deep experience in Machine Learning, Data Science, and
Distributed Data Architectures
Industry Innovations and IP
Broad patents awarded for in-cluster and in-database machine learning - 2012
First web-based solution for end-to-end Predictive analytics - 2012
Created Industry first integrated Analytics Services Platform - 2013
First Predictive Analytics solution to be certified on Spark - 2014
Launched Touchpoints, Industry first predictive applications service layer- 2015
Global Brand Names in Financial Services, Telco/Media, Healthcare, Manufacturing, Public Sector and Retail
Visionary in the Gartner Magic Quadrant for Advanced Analytics
Key Partners:
COMPANY CONFIDENTIAL4
Lightning-fast cluster computing
Real Time ML Visualization with Spark
-- What is Spark
http://spark.apache.org/
COMPANY CONFIDENTIAL5
Iris data set, K-Means clustering with K=3
Cluster 2
Cluster 1
Cluster 0
Centroids
Sepal width vs Petal length
COMPANY CONFIDENTIAL6
Iris data set, K-Means clustering with K=3
distance
COMPANY CONFIDENTIAL7
What is K-Means ?
• Given a set of observations (x1, x2, …, xn), where each observation is a d-
dimensional real vector,
• k-means clustering aims to partition the n observations into k (≤ n) sets
S = {S1, S2, …, Sk}
• The clusters are determined by minimizing the inter-cluster sum of
squares (ICSS) (sum of distance functions of each point in the cluster to
the K center). In other words, the objective is to find
• where μi is the mean of points in Si.
• https://en.wikipedia.org/wiki/K-means_clustering
COMPANY CONFIDENTIAL8
Visualization Cost
35
35.5
36
36.5
37
37.5
38
38.5
0 5 10 15 20 25
Cost vs Iteration
Cost
COMPANY CONFIDENTIAL9
Real Time ML Visualization – Why ?
• Use Cases
– Use visualization to determine whether to end the training early
• Need a way to visualize the training process including the
convergence, clustering or residual plots, etc.
• Need a way to stop the training and save current model
• Need a way to disable or enable the visualization
COMPANY CONFIDENTIAL10
Real Time ML Visualization with Spark
DEMO
COMPANY CONFIDENTIAL11
How to Enable Real Time ML Visualization ?
• A callback interface for Spark Machine Learning Algorithm to send messages
– Algorithms decide when and what message to send
– Algorithms don’t care how the message is delivered
• A task channel to handle the message delivery from Spark Driver to Spark Client
– It doesn’t care about the content of the message or who sent the message
• The message is delivered from Spark Client to Browser
– We use HTML5 Server-Sent Events ( SSE) and HTTP Chunked Response (PUSH)
– Pull is possible, but requires a message Queue
• Visualization using JavaScript Frameworks Plot.ly and D3
COMPANY CONFIDENTIAL12
Spark Job in Yarn-Cluster mode
Spark
Client
Hadoop Cluster
Yarn-Container
Spark Driver
Spark Job
Spark Context
Spark ML
algorithm
Command Line
Rest API
Servlet
Application Host
COMPANY CONFIDENTIAL13
Spark Job in Yarn-Cluster mode
Spark
Client
Hadoop Cluster
Command Line
Rest API
Servlet
Application Host
Spark Job
App Context Spark ML
Algorithms
ML Listener
Message
Logger
COMPANY CONFIDENTIAL14
Spark
Client
Hadoop ClusterApplication Host
Spark Job
App Context Spark ML
Algorithms
ML Listener
Message
Logger
Spark Job in Yarn-Cluster mode
Web/
Rest
API
Server
Akka
Browser
COMPANY CONFIDENTIAL15
Enable Real Time ML Visualization
SSE
Plotly
D3
Browser
Rest
API
Server
Web Server
Spark
Client
Hadoop Cluster
Spark Job
App Context
Message
Logger
Task Channel
Spark ML
Algorithms
ML Listener
Akka
Chunked
Response
Akka
COMPANY CONFIDENTIAL16
Enable Real Time ML Visualization
SSE
Plotly
D3
Browser
Rest
API
Server
Web Server
Spark
Client
Hadoop Cluster
Spark Job
App Context
Message
Logger
Task Channel
Spark ML
Algorithms
ML Listener
Akka
Chunked
Response
Akka
COMPANY CONFIDENTIAL17
Machine Learning Listeners
COMPANY CONFIDENTIAL18
Callback Interface: ML Listener
trait MLListener {
def onMessage(message: => Any)
}
COMPANY CONFIDENTIAL19
Callback Interface: MLListenerSupport
trait MLListenerSupport {
// rest of code
def sendMessage(message: => Any): Unit = {
if (enableListener) {
listeners.foreach(l => l.onMessage(message))
}
}
COMPANY CONFIDENTIAL20
KMeansEx: KMeans with MLListener
class KMeansExt private (…) extends Serializable
with Logging
with MLListenerSupport {
...
}
COMPANY CONFIDENTIAL21
KMeansEx: KMeans with MLListener
case class KMeansCoreStats (iteration: Int, centers: Array[Vector], cost: Double )
private def runAlgorithm(data: RDD[VectorWithNorm]): KMeansModel = {
...
while (!stopIteration &&
iteration < maxIterations && !activeRuns.isEmpty) {
...
if (listenerEnabled()) {
sendMessage(KMeansCoreStats(…))
}
...
}
}
COMPANY CONFIDENTIAL22
KMeans ML Listener
class KMeansListener(columnNames: List[String],
data : RDD[Vector],
logger : MessageLogger) extends MLListener{
var sampleDataOpt : Option[Array[Vector]]= None
message match {
case coreStats :KMeansCoreStats =>
if (sampleDataOpt.isEmpty)
sampleDataOpt = Some(data.takeSample(withReplacement = false, num=100))
//use the KMeans model of the current iteration to predict sample cluster indexes
val kMeansModel = new KMeansModel(coreStats.centers)
val cluster=sampleDataOpt.get.map(vector => (vector.toArray, kMeansModel.predict(vector)))
//construct message consists of sample, cost, iteration and centroids
//use logger to send the message out
}
COMPANY CONFIDENTIAL23
KMeans Spark Job Setup
val kMeans = new KMeansExt().setK(numClusters)
.setEpsilon(epsilon)
.setMaxIterations(maxIterations)
.enableListener(enableVisualization)
.addListener(
new KMeansListener(...))
appCtxOpt.foreach(_.addTaskObserver(new MLTaskObserver(kMeans,logger)))
kMeans.run(vectors)
COMPANY CONFIDENTIAL24
ML Task Observer
• Receives command from User to update running Spark Job
• Once receives UpdateTask Command from notify call, it preforms
the necessary update operation
trait TaskObserver {
def notify (task: UpdateTaskCmd)
}
class MLTaskObserver(support: MLListenerSupport, logger: MessageLogger )
extends TaskObserver {
//implement notify
}
COMPANY CONFIDENTIAL25
Logistic Regression MLListener
class LogisticRegression(…) extends MLListenerSupport {
def train(data: RDD[(Double, Vector)]): LogisticRegressionModel= {
// initialization code
val (rawWeights, loss) = OWLQN.runOWLQN( …)
generateLORModel(…)
}
}
COMPANY CONFIDENTIAL26
Logistic Regression MLListener
object OWLQN extends Logging {
def runOWLQN(/*args*/,mlSupport:Option[MLListenerSupport]):(Vector,
Array[Double]) = {
val costFun=new CostFun(data, mlSupport, IterationState(), /*other
args */)
val states : Iterator[lbfgs.State] =
lbfgs.iterations(
new CachedDiffFunction(costFun), initialWeights.toBreeze.toDenseVector
)
…
}
COMPANY CONFIDENTIAL27
Logistic Regression MLListener
In Cost function :
override def calculate(weights: BDV[Double]): (Double, BDV[Double]) = {
val shouldStop = mlSupport.exists(_.stopIteration)
if (!shouldStop) {
…
mlSupport.filter(_.listenerEnabled()).map { s=>
s.sendMessage( (iState.iteration, w, loss))
}
…
}
else {
…
}
}
COMPANY CONFIDENTIAL28
Task Communication Channel
COMPANY CONFIDENTIAL29
Task Channel : Akka Messaging
Spark
Application Application
Context
Actor System
Messager
Actor
Task
Channel
Actor
SparkContext Spark tasks
Akka
Akka
COMPANY CONFIDENTIAL30
Task Channel : Akka messaging
SSE
Plotly
D3
Browser
Rest
API
Server
Web Server
Spark
Client
Hadoop Cluster
Spark Job
App Context
Message
Logger
Task Channel
Spark ML
Algorithms
ML Listener
Akka
Chunked
Response
Akka
COMPANY CONFIDENTIAL31
Push To The Browser
COMPANY CONFIDENTIAL32
HTTP Chunked Response and SSE
SSE
Plotly
D3
Browser
Rest
API
Server
Web Server
Spark
Client
Hadoop Cluster
Spark Job
App Context
Message
Logger
Task Channel
Spark ML
Algorithms
ML Listener
Akka
Chunked
Response
Akka
COMPANY CONFIDENTIAL33
HTML5 Server-Sent Events (SSE)
• Server-sent Events (SSE) is one-way messaging
– An event is when a web page automatically get update from Server
• Register an event source (JavaScript)
var source = new EventSource(url);
• The Callback onMessage(data)
source.onmessage = function(message){...}
• Data Format:
data: { n
data: “key” : “value”, nn
data: } nn
COMPANY CONFIDENTIAL34
HTTP Chunked Response
• Spray Rest Server supports Chunked Response
val responseStart =
HttpResponse(entity = HttpEntity(`text/event-stream`, s"data: Startn"))
requestCtx.responder ! ChunkedResponseStart(responseStart).withAck(Messages.Ack)
val nextChunk = MessageChunk(s"data: $r nn")
requestCtx.responder ! nextChunk.withAck(Messages.Ack)
requestCtx.responder ! MessageChunk(s"data: Finished nn")
requestCtx.responder ! ChunkedMessageEnd
COMPANY CONFIDENTIAL35
Push vs. Pull
Push
• Pros
– The data is streamed (pushed) to browser via chunked response
– There is no need for data queue, but the data can be lost if not consumed
– Multiple pages can be pushed at the same time, which allows multiple
visualization views
• Cons
– For slow network, slow browser and fast data iterations, the data might all
show-up in browser at once, rather showing a nice iteration-by-iteration
display
– If you control the data chunked response by Network Acknowledgement,
the visualization may not show-up at all as the data is not pushed due to
slow network acknowledgement
COMPANY CONFIDENTIAL36
Push vs. Pull
Pull
• Pros
– Message does not get lost, since it can be temporarily stored in the
message queue
– The visualization will render in an even pace
• Cons
– Need to periodically send server request for update,
– We will need a message queue before the message is consumed
– Hard to support multiple pages rendering with simple message
queue
COMPANY CONFIDENTIAL37
Visualization: Plot.ly + D3
Cost vs. IterationCost vs. Iteration
ArrTime vs. DistanceArrTime vs. DepTime
Alpine Workflow
COMPANY CONFIDENTIAL38
Use Plot.ly to render graph
function showCost(dataParsed) {
var costTrace = { … };
var data = [ costTrace ];
var costLayout = {
xaxis: {…},
yaxis: {…},
title: …
};
Plotly.newPlot('cost', data, costLayout);
}
COMPANY CONFIDENTIAL39
Real Time ML Visualization: Summary
• Training machine learning model involves a lot of experimentation,
we need a way to visualize the training process.
• We presented a system to enable real time machine learning
visualization with Spark:
– Gives visibility into the training of a model
– Allows us monitor the convergence of the algorithms during training
– Can stop the iterations when convergence is good enough.
COMPANY CONFIDENTIAL40
Thank You
Chester Chen
chesterxgchen@yahoo.com
LinkedIn
https://www.linkedin.com/in/chester-chen-3205992
SlideShare
http://www.slideshare.net/ChesterChen/presentations
demo video
https://youtu.be/DkbYNYQhrao

More Related Content

Viewers also liked

Банковский лидпровайдер BID Lead
Банковский лидпровайдер BID Lead Банковский лидпровайдер BID Lead
Банковский лидпровайдер BID Lead HopInTop
 
Revista o pregoeiro dez.11 pág.17
Revista o pregoeiro   dez.11 pág.17Revista o pregoeiro   dez.11 pág.17
Revista o pregoeiro dez.11 pág.17Adriel Bono
 
Présentation Onecoin en français
Présentation Onecoin en françaisPrésentation Onecoin en français
Présentation Onecoin en françaisyannick37
 
Principios de la economia en realcion con el problema
Principios de la economia en realcion con el problemaPrincipios de la economia en realcion con el problema
Principios de la economia en realcion con el problemaEunice Jesros
 
Reactive Reatime Big Data with Open Source Lambda Architecture - TechCampVN 2014
Reactive Reatime Big Data with Open Source Lambda Architecture - TechCampVN 2014Reactive Reatime Big Data with Open Source Lambda Architecture - TechCampVN 2014
Reactive Reatime Big Data with Open Source Lambda Architecture - TechCampVN 2014Trieu Nguyen
 
SF Big Analytics: Introduction to Succinct by UC Berkeley AmpLab
SF Big Analytics: Introduction to Succinct by UC Berkeley AmpLabSF Big Analytics: Introduction to Succinct by UC Berkeley AmpLab
SF Big Analytics: Introduction to Succinct by UC Berkeley AmpLabChester Chen
 
Migration from Redshift to Spark
Migration from Redshift to SparkMigration from Redshift to Spark
Migration from Redshift to SparkSky Yin
 
In-Memory Computing Webcast. Market Predictions 2017
In-Memory Computing Webcast. Market Predictions 2017In-Memory Computing Webcast. Market Predictions 2017
In-Memory Computing Webcast. Market Predictions 2017SingleStore
 
Propuesta de programacion anual de la asignatura ccesa007
Propuesta de programacion anual de la asignatura ccesa007Propuesta de programacion anual de la asignatura ccesa007
Propuesta de programacion anual de la asignatura ccesa007Demetrio Ccesa Rayme
 

Viewers also liked (18)

Банковский лидпровайдер BID Lead
Банковский лидпровайдер BID Lead Банковский лидпровайдер BID Lead
Банковский лидпровайдер BID Lead
 
Crestal vs basal implants
Crestal vs basal implantsCrestal vs basal implants
Crestal vs basal implants
 
Talentlinjen i Horsens
Talentlinjen i Horsens Talentlinjen i Horsens
Talentlinjen i Horsens
 
trabajar en GNS3
trabajar en GNS3trabajar en GNS3
trabajar en GNS3
 
Revista o pregoeiro dez.11 pág.17
Revista o pregoeiro   dez.11 pág.17Revista o pregoeiro   dez.11 pág.17
Revista o pregoeiro dez.11 pág.17
 
Présentation Onecoin en français
Présentation Onecoin en françaisPrésentation Onecoin en français
Présentation Onecoin en français
 
Principios de la economia en realcion con el problema
Principios de la economia en realcion con el problemaPrincipios de la economia en realcion con el problema
Principios de la economia en realcion con el problema
 
Matt Hallead - Lean Projects Overview
Matt Hallead - Lean Projects OverviewMatt Hallead - Lean Projects Overview
Matt Hallead - Lean Projects Overview
 
Reactive Reatime Big Data with Open Source Lambda Architecture - TechCampVN 2014
Reactive Reatime Big Data with Open Source Lambda Architecture - TechCampVN 2014Reactive Reatime Big Data with Open Source Lambda Architecture - TechCampVN 2014
Reactive Reatime Big Data with Open Source Lambda Architecture - TechCampVN 2014
 
Blue-mixer
Blue-mixerBlue-mixer
Blue-mixer
 
Blue-mixer
Blue-mixerBlue-mixer
Blue-mixer
 
SF Big Analytics: Introduction to Succinct by UC Berkeley AmpLab
SF Big Analytics: Introduction to Succinct by UC Berkeley AmpLabSF Big Analytics: Introduction to Succinct by UC Berkeley AmpLab
SF Big Analytics: Introduction to Succinct by UC Berkeley AmpLab
 
ASRS Vehicle
ASRS VehicleASRS Vehicle
ASRS Vehicle
 
Migration from Redshift to Spark
Migration from Redshift to SparkMigration from Redshift to Spark
Migration from Redshift to Spark
 
Manual en Español De Software Flexsim
Manual en Español De Software FlexsimManual en Español De Software Flexsim
Manual en Español De Software Flexsim
 
In-Memory Computing Webcast. Market Predictions 2017
In-Memory Computing Webcast. Market Predictions 2017In-Memory Computing Webcast. Market Predictions 2017
In-Memory Computing Webcast. Market Predictions 2017
 
Propuesta de programacion anual de la asignatura ccesa007
Propuesta de programacion anual de la asignatura ccesa007Propuesta de programacion anual de la asignatura ccesa007
Propuesta de programacion anual de la asignatura ccesa007
 
305 bài Toán chọn lọc lớp 3 có đáp án
305 bài Toán chọn lọc lớp 3 có đáp án305 bài Toán chọn lọc lớp 3 có đáp án
305 bài Toán chọn lọc lớp 3 có đáp án
 

Similar to Real timeml visualizationwithspark_v6

Real Time Machine Learning Visualization With Spark
Real Time Machine Learning Visualization With SparkReal Time Machine Learning Visualization With Spark
Real Time Machine Learning Visualization With SparkChester Chen
 
Simplifying the Creation of Machine Learning Workflow Pipelines for IoT Appli...
Simplifying the Creation of Machine Learning Workflow Pipelines for IoT Appli...Simplifying the Creation of Machine Learning Workflow Pipelines for IoT Appli...
Simplifying the Creation of Machine Learning Workflow Pipelines for IoT Appli...ScyllaDB
 
Bhadale group of companies - Our project works
Bhadale group of companies - Our project worksBhadale group of companies - Our project works
Bhadale group of companies - Our project worksVijayananda Mohire
 
Deep learning and streaming in Apache Spark 2.2 by Matei Zaharia
Deep learning and streaming in Apache Spark 2.2 by Matei ZahariaDeep learning and streaming in Apache Spark 2.2 by Matei Zaharia
Deep learning and streaming in Apache Spark 2.2 by Matei ZahariaGoDataDriven
 
Expanding Apache Spark Use Cases in 2.2 and Beyond with Matei Zaharia and dem...
Expanding Apache Spark Use Cases in 2.2 and Beyond with Matei Zaharia and dem...Expanding Apache Spark Use Cases in 2.2 and Beyond with Matei Zaharia and dem...
Expanding Apache Spark Use Cases in 2.2 and Beyond with Matei Zaharia and dem...Databricks
 
GDG Cloud Southlake #16: Priyanka Vergadia: Scalable Data Analytics in Google...
GDG Cloud Southlake #16: Priyanka Vergadia: Scalable Data Analytics in Google...GDG Cloud Southlake #16: Priyanka Vergadia: Scalable Data Analytics in Google...
GDG Cloud Southlake #16: Priyanka Vergadia: Scalable Data Analytics in Google...James Anderson
 
Real time machine learning visualization with spark -- Hadoop Summit 2016
Real time machine learning visualization with spark -- Hadoop Summit 2016Real time machine learning visualization with spark -- Hadoop Summit 2016
Real time machine learning visualization with spark -- Hadoop Summit 2016Chester Chen
 
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-AirflowPyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-AirflowChetan Khatri
 
Tech UG - Newcastle 09-17 - logic apps
Tech UG - Newcastle 09-17 -   logic appsTech UG - Newcastle 09-17 -   logic apps
Tech UG - Newcastle 09-17 - logic appsMichael Stephenson
 
June 2023 Architect Group FTW.pdf
June 2023 Architect Group FTW.pdfJune 2023 Architect Group FTW.pdf
June 2023 Architect Group FTW.pdfAmeyKulkarni84
 
XebiCon'17 : AxonFramework @ SGCIB (our experience) : (CQRS, Eventsourcing, A...
XebiCon'17 : AxonFramework @ SGCIB (our experience) : (CQRS, Eventsourcing, A...XebiCon'17 : AxonFramework @ SGCIB (our experience) : (CQRS, Eventsourcing, A...
XebiCon'17 : AxonFramework @ SGCIB (our experience) : (CQRS, Eventsourcing, A...Publicis Sapient Engineering
 
Big Data Adavnced Analytics on Microsoft Azure
Big Data Adavnced Analytics on Microsoft AzureBig Data Adavnced Analytics on Microsoft Azure
Big Data Adavnced Analytics on Microsoft AzureMark Tabladillo
 
What's New in Upcoming Apache Spark 2.3
What's New in Upcoming Apache Spark 2.3What's New in Upcoming Apache Spark 2.3
What's New in Upcoming Apache Spark 2.3Databricks
 
BigQuery ML - Machine learning at scale using SQL
BigQuery ML - Machine learning at scale using SQLBigQuery ML - Machine learning at scale using SQL
BigQuery ML - Machine learning at scale using SQLMárton Kodok
 
.Net development with Azure Machine Learning (AzureML) Nov 2014
.Net development with Azure Machine Learning (AzureML) Nov 2014.Net development with Azure Machine Learning (AzureML) Nov 2014
.Net development with Azure Machine Learning (AzureML) Nov 2014Mark Tabladillo
 
Infrastructure Agnostic Machine Learning Workload Deployment
Infrastructure Agnostic Machine Learning Workload DeploymentInfrastructure Agnostic Machine Learning Workload Deployment
Infrastructure Agnostic Machine Learning Workload DeploymentDatabricks
 
The Scout24 Data Platform (A Technical Deep Dive)
The Scout24 Data Platform (A Technical Deep Dive)The Scout24 Data Platform (A Technical Deep Dive)
The Scout24 Data Platform (A Technical Deep Dive)RaffaelDzikowski
 
ECS19 - Bill Ayers - UNLOCK YOUR BUSINESS KNOWLEDGE WITH THE MICROSOFT GRAPH,...
ECS19 - Bill Ayers - UNLOCK YOUR BUSINESS KNOWLEDGE WITH THE MICROSOFT GRAPH,...ECS19 - Bill Ayers - UNLOCK YOUR BUSINESS KNOWLEDGE WITH THE MICROSOFT GRAPH,...
ECS19 - Bill Ayers - UNLOCK YOUR BUSINESS KNOWLEDGE WITH THE MICROSOFT GRAPH,...European Collaboration Summit
 
2018 02-08-what's-new-in-apache-spark-2.3
2018 02-08-what's-new-in-apache-spark-2.3 2018 02-08-what's-new-in-apache-spark-2.3
2018 02-08-what's-new-in-apache-spark-2.3 Chester Chen
 

Similar to Real timeml visualizationwithspark_v6 (20)

Real Time Machine Learning Visualization With Spark
Real Time Machine Learning Visualization With SparkReal Time Machine Learning Visualization With Spark
Real Time Machine Learning Visualization With Spark
 
Simplifying the Creation of Machine Learning Workflow Pipelines for IoT Appli...
Simplifying the Creation of Machine Learning Workflow Pipelines for IoT Appli...Simplifying the Creation of Machine Learning Workflow Pipelines for IoT Appli...
Simplifying the Creation of Machine Learning Workflow Pipelines for IoT Appli...
 
Bhadale group of companies - Our project works
Bhadale group of companies - Our project worksBhadale group of companies - Our project works
Bhadale group of companies - Our project works
 
Deep learning and streaming in Apache Spark 2.2 by Matei Zaharia
Deep learning and streaming in Apache Spark 2.2 by Matei ZahariaDeep learning and streaming in Apache Spark 2.2 by Matei Zaharia
Deep learning and streaming in Apache Spark 2.2 by Matei Zaharia
 
Expanding Apache Spark Use Cases in 2.2 and Beyond with Matei Zaharia and dem...
Expanding Apache Spark Use Cases in 2.2 and Beyond with Matei Zaharia and dem...Expanding Apache Spark Use Cases in 2.2 and Beyond with Matei Zaharia and dem...
Expanding Apache Spark Use Cases in 2.2 and Beyond with Matei Zaharia and dem...
 
GDG Cloud Southlake #16: Priyanka Vergadia: Scalable Data Analytics in Google...
GDG Cloud Southlake #16: Priyanka Vergadia: Scalable Data Analytics in Google...GDG Cloud Southlake #16: Priyanka Vergadia: Scalable Data Analytics in Google...
GDG Cloud Southlake #16: Priyanka Vergadia: Scalable Data Analytics in Google...
 
Real time machine learning visualization with spark -- Hadoop Summit 2016
Real time machine learning visualization with spark -- Hadoop Summit 2016Real time machine learning visualization with spark -- Hadoop Summit 2016
Real time machine learning visualization with spark -- Hadoop Summit 2016
 
Real Time Machine Learning Visualization with Spark
Real Time Machine Learning Visualization with SparkReal Time Machine Learning Visualization with Spark
Real Time Machine Learning Visualization with Spark
 
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-AirflowPyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
 
Tech UG - Newcastle 09-17 - logic apps
Tech UG - Newcastle 09-17 -   logic appsTech UG - Newcastle 09-17 -   logic apps
Tech UG - Newcastle 09-17 - logic apps
 
June 2023 Architect Group FTW.pdf
June 2023 Architect Group FTW.pdfJune 2023 Architect Group FTW.pdf
June 2023 Architect Group FTW.pdf
 
XebiCon'17 : AxonFramework @ SGCIB (our experience) : (CQRS, Eventsourcing, A...
XebiCon'17 : AxonFramework @ SGCIB (our experience) : (CQRS, Eventsourcing, A...XebiCon'17 : AxonFramework @ SGCIB (our experience) : (CQRS, Eventsourcing, A...
XebiCon'17 : AxonFramework @ SGCIB (our experience) : (CQRS, Eventsourcing, A...
 
Big Data Adavnced Analytics on Microsoft Azure
Big Data Adavnced Analytics on Microsoft AzureBig Data Adavnced Analytics on Microsoft Azure
Big Data Adavnced Analytics on Microsoft Azure
 
What's New in Upcoming Apache Spark 2.3
What's New in Upcoming Apache Spark 2.3What's New in Upcoming Apache Spark 2.3
What's New in Upcoming Apache Spark 2.3
 
BigQuery ML - Machine learning at scale using SQL
BigQuery ML - Machine learning at scale using SQLBigQuery ML - Machine learning at scale using SQL
BigQuery ML - Machine learning at scale using SQL
 
.Net development with Azure Machine Learning (AzureML) Nov 2014
.Net development with Azure Machine Learning (AzureML) Nov 2014.Net development with Azure Machine Learning (AzureML) Nov 2014
.Net development with Azure Machine Learning (AzureML) Nov 2014
 
Infrastructure Agnostic Machine Learning Workload Deployment
Infrastructure Agnostic Machine Learning Workload DeploymentInfrastructure Agnostic Machine Learning Workload Deployment
Infrastructure Agnostic Machine Learning Workload Deployment
 
The Scout24 Data Platform (A Technical Deep Dive)
The Scout24 Data Platform (A Technical Deep Dive)The Scout24 Data Platform (A Technical Deep Dive)
The Scout24 Data Platform (A Technical Deep Dive)
 
ECS19 - Bill Ayers - UNLOCK YOUR BUSINESS KNOWLEDGE WITH THE MICROSOFT GRAPH,...
ECS19 - Bill Ayers - UNLOCK YOUR BUSINESS KNOWLEDGE WITH THE MICROSOFT GRAPH,...ECS19 - Bill Ayers - UNLOCK YOUR BUSINESS KNOWLEDGE WITH THE MICROSOFT GRAPH,...
ECS19 - Bill Ayers - UNLOCK YOUR BUSINESS KNOWLEDGE WITH THE MICROSOFT GRAPH,...
 
2018 02-08-what's-new-in-apache-spark-2.3
2018 02-08-what's-new-in-apache-spark-2.3 2018 02-08-what's-new-in-apache-spark-2.3
2018 02-08-what's-new-in-apache-spark-2.3
 

Recently uploaded

Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile EnvironmentVictorSzoltysek
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 

Recently uploaded (20)

Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 

Real timeml visualizationwithspark_v6

  • 1. Real Time Machine Learning Visualization with Spark Chester Chen Director of Engineering Alpine Data May 3, 2016
  • 2. COMPANY CONFIDENTIAL2 Who am I ? • Director of Engineering at Alpine Data • Founder and Organizer of SF Big Analytics Meetup (4000+ members) • Previous Employment: – Symantec, AltaVista, Ascent Media, ClearStory Systems, WebWare. • Experience with Spark – Exposed to Spark since Spark 0.6 – Architect for Alpine Spark Integration on Spark 1.1, 1.3 and 1.5.x • Hadoop Distribution – CDH, HDP and MapR
  • 3. COMPANY CONFIDENTIAL3 Alpine Data at a Glance Enterprise Scale Predictive Analytics with deep experience in Machine Learning, Data Science, and Distributed Data Architectures Industry Innovations and IP Broad patents awarded for in-cluster and in-database machine learning - 2012 First web-based solution for end-to-end Predictive analytics - 2012 Created Industry first integrated Analytics Services Platform - 2013 First Predictive Analytics solution to be certified on Spark - 2014 Launched Touchpoints, Industry first predictive applications service layer- 2015 Global Brand Names in Financial Services, Telco/Media, Healthcare, Manufacturing, Public Sector and Retail Visionary in the Gartner Magic Quadrant for Advanced Analytics Key Partners:
  • 4. COMPANY CONFIDENTIAL4 Lightning-fast cluster computing Real Time ML Visualization with Spark -- What is Spark http://spark.apache.org/
  • 5. COMPANY CONFIDENTIAL5 Iris data set, K-Means clustering with K=3 Cluster 2 Cluster 1 Cluster 0 Centroids Sepal width vs Petal length
  • 6. COMPANY CONFIDENTIAL6 Iris data set, K-Means clustering with K=3 distance
  • 7. COMPANY CONFIDENTIAL7 What is K-Means ? • Given a set of observations (x1, x2, …, xn), where each observation is a d- dimensional real vector, • k-means clustering aims to partition the n observations into k (≤ n) sets S = {S1, S2, …, Sk} • The clusters are determined by minimizing the inter-cluster sum of squares (ICSS) (sum of distance functions of each point in the cluster to the K center). In other words, the objective is to find • where μi is the mean of points in Si. • https://en.wikipedia.org/wiki/K-means_clustering
  • 9. COMPANY CONFIDENTIAL9 Real Time ML Visualization – Why ? • Use Cases – Use visualization to determine whether to end the training early • Need a way to visualize the training process including the convergence, clustering or residual plots, etc. • Need a way to stop the training and save current model • Need a way to disable or enable the visualization
  • 10. COMPANY CONFIDENTIAL10 Real Time ML Visualization with Spark DEMO
  • 11. COMPANY CONFIDENTIAL11 How to Enable Real Time ML Visualization ? • A callback interface for Spark Machine Learning Algorithm to send messages – Algorithms decide when and what message to send – Algorithms don’t care how the message is delivered • A task channel to handle the message delivery from Spark Driver to Spark Client – It doesn’t care about the content of the message or who sent the message • The message is delivered from Spark Client to Browser – We use HTML5 Server-Sent Events ( SSE) and HTTP Chunked Response (PUSH) – Pull is possible, but requires a message Queue • Visualization using JavaScript Frameworks Plot.ly and D3
  • 12. COMPANY CONFIDENTIAL12 Spark Job in Yarn-Cluster mode Spark Client Hadoop Cluster Yarn-Container Spark Driver Spark Job Spark Context Spark ML algorithm Command Line Rest API Servlet Application Host
  • 13. COMPANY CONFIDENTIAL13 Spark Job in Yarn-Cluster mode Spark Client Hadoop Cluster Command Line Rest API Servlet Application Host Spark Job App Context Spark ML Algorithms ML Listener Message Logger
  • 14. COMPANY CONFIDENTIAL14 Spark Client Hadoop ClusterApplication Host Spark Job App Context Spark ML Algorithms ML Listener Message Logger Spark Job in Yarn-Cluster mode Web/ Rest API Server Akka Browser
  • 15. COMPANY CONFIDENTIAL15 Enable Real Time ML Visualization SSE Plotly D3 Browser Rest API Server Web Server Spark Client Hadoop Cluster Spark Job App Context Message Logger Task Channel Spark ML Algorithms ML Listener Akka Chunked Response Akka
  • 16. COMPANY CONFIDENTIAL16 Enable Real Time ML Visualization SSE Plotly D3 Browser Rest API Server Web Server Spark Client Hadoop Cluster Spark Job App Context Message Logger Task Channel Spark ML Algorithms ML Listener Akka Chunked Response Akka
  • 18. COMPANY CONFIDENTIAL18 Callback Interface: ML Listener trait MLListener { def onMessage(message: => Any) }
  • 19. COMPANY CONFIDENTIAL19 Callback Interface: MLListenerSupport trait MLListenerSupport { // rest of code def sendMessage(message: => Any): Unit = { if (enableListener) { listeners.foreach(l => l.onMessage(message)) } }
  • 20. COMPANY CONFIDENTIAL20 KMeansEx: KMeans with MLListener class KMeansExt private (…) extends Serializable with Logging with MLListenerSupport { ... }
  • 21. COMPANY CONFIDENTIAL21 KMeansEx: KMeans with MLListener case class KMeansCoreStats (iteration: Int, centers: Array[Vector], cost: Double ) private def runAlgorithm(data: RDD[VectorWithNorm]): KMeansModel = { ... while (!stopIteration && iteration < maxIterations && !activeRuns.isEmpty) { ... if (listenerEnabled()) { sendMessage(KMeansCoreStats(…)) } ... } }
  • 22. COMPANY CONFIDENTIAL22 KMeans ML Listener class KMeansListener(columnNames: List[String], data : RDD[Vector], logger : MessageLogger) extends MLListener{ var sampleDataOpt : Option[Array[Vector]]= None message match { case coreStats :KMeansCoreStats => if (sampleDataOpt.isEmpty) sampleDataOpt = Some(data.takeSample(withReplacement = false, num=100)) //use the KMeans model of the current iteration to predict sample cluster indexes val kMeansModel = new KMeansModel(coreStats.centers) val cluster=sampleDataOpt.get.map(vector => (vector.toArray, kMeansModel.predict(vector))) //construct message consists of sample, cost, iteration and centroids //use logger to send the message out }
  • 23. COMPANY CONFIDENTIAL23 KMeans Spark Job Setup val kMeans = new KMeansExt().setK(numClusters) .setEpsilon(epsilon) .setMaxIterations(maxIterations) .enableListener(enableVisualization) .addListener( new KMeansListener(...)) appCtxOpt.foreach(_.addTaskObserver(new MLTaskObserver(kMeans,logger))) kMeans.run(vectors)
  • 24. COMPANY CONFIDENTIAL24 ML Task Observer • Receives command from User to update running Spark Job • Once receives UpdateTask Command from notify call, it preforms the necessary update operation trait TaskObserver { def notify (task: UpdateTaskCmd) } class MLTaskObserver(support: MLListenerSupport, logger: MessageLogger ) extends TaskObserver { //implement notify }
  • 25. COMPANY CONFIDENTIAL25 Logistic Regression MLListener class LogisticRegression(…) extends MLListenerSupport { def train(data: RDD[(Double, Vector)]): LogisticRegressionModel= { // initialization code val (rawWeights, loss) = OWLQN.runOWLQN( …) generateLORModel(…) } }
  • 26. COMPANY CONFIDENTIAL26 Logistic Regression MLListener object OWLQN extends Logging { def runOWLQN(/*args*/,mlSupport:Option[MLListenerSupport]):(Vector, Array[Double]) = { val costFun=new CostFun(data, mlSupport, IterationState(), /*other args */) val states : Iterator[lbfgs.State] = lbfgs.iterations( new CachedDiffFunction(costFun), initialWeights.toBreeze.toDenseVector ) … }
  • 27. COMPANY CONFIDENTIAL27 Logistic Regression MLListener In Cost function : override def calculate(weights: BDV[Double]): (Double, BDV[Double]) = { val shouldStop = mlSupport.exists(_.stopIteration) if (!shouldStop) { … mlSupport.filter(_.listenerEnabled()).map { s=> s.sendMessage( (iState.iteration, w, loss)) } … } else { … } }
  • 29. COMPANY CONFIDENTIAL29 Task Channel : Akka Messaging Spark Application Application Context Actor System Messager Actor Task Channel Actor SparkContext Spark tasks Akka Akka
  • 30. COMPANY CONFIDENTIAL30 Task Channel : Akka messaging SSE Plotly D3 Browser Rest API Server Web Server Spark Client Hadoop Cluster Spark Job App Context Message Logger Task Channel Spark ML Algorithms ML Listener Akka Chunked Response Akka
  • 32. COMPANY CONFIDENTIAL32 HTTP Chunked Response and SSE SSE Plotly D3 Browser Rest API Server Web Server Spark Client Hadoop Cluster Spark Job App Context Message Logger Task Channel Spark ML Algorithms ML Listener Akka Chunked Response Akka
  • 33. COMPANY CONFIDENTIAL33 HTML5 Server-Sent Events (SSE) • Server-sent Events (SSE) is one-way messaging – An event is when a web page automatically get update from Server • Register an event source (JavaScript) var source = new EventSource(url); • The Callback onMessage(data) source.onmessage = function(message){...} • Data Format: data: { n data: “key” : “value”, nn data: } nn
  • 34. COMPANY CONFIDENTIAL34 HTTP Chunked Response • Spray Rest Server supports Chunked Response val responseStart = HttpResponse(entity = HttpEntity(`text/event-stream`, s"data: Startn")) requestCtx.responder ! ChunkedResponseStart(responseStart).withAck(Messages.Ack) val nextChunk = MessageChunk(s"data: $r nn") requestCtx.responder ! nextChunk.withAck(Messages.Ack) requestCtx.responder ! MessageChunk(s"data: Finished nn") requestCtx.responder ! ChunkedMessageEnd
  • 35. COMPANY CONFIDENTIAL35 Push vs. Pull Push • Pros – The data is streamed (pushed) to browser via chunked response – There is no need for data queue, but the data can be lost if not consumed – Multiple pages can be pushed at the same time, which allows multiple visualization views • Cons – For slow network, slow browser and fast data iterations, the data might all show-up in browser at once, rather showing a nice iteration-by-iteration display – If you control the data chunked response by Network Acknowledgement, the visualization may not show-up at all as the data is not pushed due to slow network acknowledgement
  • 36. COMPANY CONFIDENTIAL36 Push vs. Pull Pull • Pros – Message does not get lost, since it can be temporarily stored in the message queue – The visualization will render in an even pace • Cons – Need to periodically send server request for update, – We will need a message queue before the message is consumed – Hard to support multiple pages rendering with simple message queue
  • 37. COMPANY CONFIDENTIAL37 Visualization: Plot.ly + D3 Cost vs. IterationCost vs. Iteration ArrTime vs. DistanceArrTime vs. DepTime Alpine Workflow
  • 38. COMPANY CONFIDENTIAL38 Use Plot.ly to render graph function showCost(dataParsed) { var costTrace = { … }; var data = [ costTrace ]; var costLayout = { xaxis: {…}, yaxis: {…}, title: … }; Plotly.newPlot('cost', data, costLayout); }
  • 39. COMPANY CONFIDENTIAL39 Real Time ML Visualization: Summary • Training machine learning model involves a lot of experimentation, we need a way to visualize the training process. • We presented a system to enable real time machine learning visualization with Spark: – Gives visibility into the training of a model – Allows us monitor the convergence of the algorithms during training – Can stop the iterations when convergence is good enough.
  • 40. COMPANY CONFIDENTIAL40 Thank You Chester Chen chesterxgchen@yahoo.com LinkedIn https://www.linkedin.com/in/chester-chen-3205992 SlideShare http://www.slideshare.net/ChesterChen/presentations demo video https://youtu.be/DkbYNYQhrao

Editor's Notes

  1. Steps : Choose centers Compute and min d = distance to centroid, choose new center Convergence when centroid is not changed
  2. Once we define the MLListener Support, we can gather stats at initial, iteration and final step and call: sendMessage(gatherKMeansStats(/*…*/))
  3. Turn into picture
  4. Two slides
  5. Two slides
  6. Share contact info? Link to slides again?