In the previous blog, we learned about creating K-Means Clustering Model . In this blog we will use the created model in a streaming use case for analysis in real time.
For previous blog refer @ https://querydb.blogspot.com/2019/12/machine-learning-part-3.html
1) Load the Model created in previous blog.
2) Create a dataframe with cluster id, and centroid location ( centroid longitude , centroid latitude)
3) Create a Kafka Streaming dataframe.
4) Parse the Message into a Typed Object.
5) Use Vector assembler to put all features in to a vector
6) Transform the dataframe using model to get predictions.
7) Join with dataframe created in #2
8) Print the results to console or save it to HBase.
Note that this example also describes about Spark Structured Streaming, where-in,
Refer code @ https://github.com/dinesh028/SparkDS/tree/master/src/indore/dinesh/sachdev/uber/streaming
Part 5 - https://querydb.blogspot.com/2019/12/machine-learning-part-5.html
1) Load the Model created in previous blog.
2) Create a dataframe with cluster id, and centroid location ( centroid longitude , centroid latitude)
3) Create a Kafka Streaming dataframe.
4) Parse the Message into a Typed Object.
5) Use Vector assembler to put all features in to a vector
6) Transform the dataframe using model to get predictions.
7) Join with dataframe created in #2
8) Print the results to console or save it to HBase.
Note that this example also describes about Spark Structured Streaming, where-in,
- We created a streaming Kafka Source
- And, a custom Foreach Sink to write data to HBase.
Refer code @ https://github.com/dinesh028/SparkDS/tree/master/src/indore/dinesh/sachdev/uber/streaming
Part 5 - https://querydb.blogspot.com/2019/12/machine-learning-part-5.html
Comments
Post a Comment