Unit 3: Stream computing and real-time analytics
Big Data Analytics notes · PTU syllabus (PGCA1947)
On this page
Unit summary
Some data must be analysed as it arrives. This unit covers the stream data model and architecture, sampling and filtering streams, counting distinct elements, estimating moments, decaying windows, real-time analytics platforms, sentiment analysis, stock market prediction and graph analytics.
After this unit you can
- Explain the stream data model
- Apply sampling, Bloom filters and Flajolet–Martin
- Explain moments and decaying windows
- Describe real-time and graph analytics applications
PTU syllabus topics
- Stream data model and architecture
- sampling and filtering streams
- counting distinct elements
- estimating moments
- decaying windows
- real-time analytics platform applications
- real-time sentiment analysis
- stock market prediction
- graph analytics for big data
- 1Data streams in
Tweets, ticks, sensors
- 2Sample or filter
- 3Windowed computation
Counts, averages, decaying windows
- 4Detect patterns
Sentiment, anomalies
- 5Act or alert in real time
Topic 1
Stream data model and architecture
- 1Sources
Sensors, clicks, tweets, transactions
- 2Ingestion
Apache Kafka
- 3Stream processor
Spark Streaming, Flink, Storm with limited working memory
- 4Standing and ad hoc queries
- 5Output
Dashboards, alerts, storage
- Data arrives continuously and can be seen only once; algorithms use small memory and give approximate answers.
Topic 2
Sampling and filtering streams
- Fixed-proportion sampling
- Hash a key (e.g., user ID) to keep a representative 1/10 of users
- Reservoir sampling
- Keep a uniform sample of size s from an unknown-length stream
- Bloom filter
- Bit array with k hash functions to test membership; no false negatives, some false positives
Example
Bloom filter for spam senders: an e-mail address hashes to bits 3, 7 and 12; if all three are set the address is possibly on the list, if any is 0 it is definitely not.
Topic 3
Counting distinct elements
- Flajolet–Martin: hash each element; track R = maximum number of trailing zeros seen; estimate distinct count ≈ 2^R. Combine many hash functions (averages of medians) for accuracy. HyperLogLog is the modern version.
Topic 4
Estimating moments and decaying windows
k-th moment = Σ (mi)^k
mi = count of element i
0th moment
Number of distinct elements
1st moment
Stream length
2nd moment (surprise number)
Measures skew — AMS algorithm estimates it
- Decaying window: weight recent items more — score = Σ a(t−i) × (1 − c)^i with small c; used for "trending" items.
Topic 5
Real-time analytics applications
Sentiment analysis
Tweets and reviews
Tokenise, classify positive or negative (Naive Bayes, deep models) in streams; track brand mood
Stock market prediction
Price ticks, news
Moving averages, time-series and ML models in real time; event alerts
Fraud detection
Card transactions
Score each transaction in milliseconds
Topic 6
Graph analytics for big data
- PageRank
- Importance of nodes from links
- Community detection
- Groups of tightly connected nodes
- Shortest path
- Routing, logistics
- Centrality
- Influencers in social networks
- Tools
- Neo4j, Spark GraphX, Apache Giraph
Key terms
- Data stream
- Continuous, unbounded sequence of data
- Reservoir sampling
- Uniform sample from a stream of unknown length
- Bloom filter
- Probabilistic set-membership structure
- Flajolet–Martin
- Algorithm estimating distinct elements
- Decaying window
- Weighting recent elements more
Quick revision
- Stream model; Kafka, Spark, Flink.
- Sampling; Bloom filter.
- Flajolet–Martin; HyperLogLog.
- Moments; AMS; decaying windows.
- Sentiment, stock, fraud analytics; PageRank and graph tools.
Important exam questions
Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).
Short-answer questions
- Q1.Why are stream algorithms approximate?
- Q2.What is reservoir sampling?
- Q3.Can a Bloom filter give false negatives?
- Q4.How does Flajolet–Martin estimate distinct counts?
- Q5.What is the second moment?
- Q6.What is PageRank?
Long-answer questions
- Q1.Explain the stream data model and architecture.
- Q2.Explain sampling and filtering of streams.
- Q3.Explain counting distinct elements and estimating moments.
- Q4.Explain real-time analytics applications.
Stuck on this unit?
Message SBS on WhatsApp for help with Big Data Analytics, or to ask about studying M.Sc IT at Synetic.
