0% found this document useful (0 votes)
14 views54 pages

Big Data Analytics Course Overview

The document outlines a Big Data Analytics course taught by Hossein Maserrat, emphasizing the importance of understanding data science concepts and real-world applications. It discusses grading criteria, student engagement, and the significance of attention in learning. The course will cover topics such as MapReduce, large-scale computing, and data mining techniques, using the textbook 'Mining of Massive Datasets' as a primary resource.

Uploaded by

pand4inca
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views54 pages

Big Data Analytics Course Overview

The document outlines a Big Data Analytics course taught by Hossein Maserrat, emphasizing the importance of understanding data science concepts and real-world applications. It discusses grading criteria, student engagement, and the significance of attention in learning. The course will cover topics such as MapReduce, large-scale computing, and data mining techniques, using the textbook 'Mining of Massive Datasets' as a primary resource.

Uploaded by

pand4inca
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Instructor: Hossein Maserrat

Big Data Analytics

Slides from:
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets,
[Link]
Instructor

Hossein Maserrat, Ph.D in Data Sciences


Worked many years in the industry as Data Architect
and Data Scientist

2
Grades
◼ Grades:
● 10% Attendance and Participation
● 25% Quizzes (6 in total)
● 25% Homeworks
● 15% Midterm
● 25% Final exam
◼ Homeworks:
● Python + google colab (there will be a tutorial as part
of your first homework)
◼ You get one break for the 3-hour class
● do not disturb the lecture by leaving or entering the
class (unless it’s an emergency)
3
Why I started to teach again?

Many new graduates have trouble applying their


knowledge to real world problems:
■ Their knowledge is mostly procedural
■ They have no intuition on how to connect these
procedures to real world challenges
■ It is much easier to just force students to memorize
procedures rather than teach the intuition and the
meaning behind those procedures

4
Students
Three types of students:
■ Those who are motivated and eager to learn
■ Those who don’t have the confidence to engage
with the lecture and course material but with some
encouragement they will try
■ Those who think it’s clever to get the credit without
any real attempt of learning

5
Procedure vs. Substance
■ Basic premise: The divided brain
▪ The left hemisphere of the brain deals with
concrete procedures, has evolved to focus its
attention on detail; see things as a collection of
parts and misses the whole picture
▪ The right hemisphere, on the other hand, has a
broad and flexible point of view that is open to
all possibilities, and it sees things in their
broader context
■ Too much left hemisphere? Iain McGilchrist is a psychiatrist,
▪ Western civilisation is in a predicament writer, and former Oxford literary
exemplified by alienation, environmental scholar. He later trained in medicine
despoliation, the atrophy of value, the sterility of and has been a neuroimaging
researcher (Wikipedia).
contemporary art, the increasing prevalence of
rectilinear, bureaucratised thinking and the The Matter with Things: Our Brains,
triumph of procedure over substance. Our Delusions, and the Unmaking of
the World is a 2021 book of
(Jonathan Gaisman, writing in The Spectator in
neuroscience, epistemology and
February 2022 reviewing the book) metaphysics written by psychiatrist,
thinker and former literary scholar
(Wikipedia)

6
So what?
What do I expect from students? Just pay attention

“Attention is a creative act”

“Attention is a moral act”

“Attention is all you need”

“Attention is all I ask”

7
What is Data Science?
◼Given lots of data
▪ Imagine the footprint of all the users that play a
popular smartphone game
◼Discover patterns and models that are:
▪ Valid: hold on new data with some certainty
▪ Useful: should be possible to act on the item
▪ Unexpected: non-obvious to the system
▪ Understandable: humans should be able to
interpret the pattern

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 8


TEXTBOOK (pdf available online)
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 9
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 10
Data contains value and
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 11
Data Science
◼But to extract the knowledge
data needs to be
▪Stored
▪Managed
▪And ANALYZED 🡨 this class

Data Mining ≈ Big Data ≈


Predictive Analytics ≈ Data Science

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 12


Good news: Demand for
Data Mining

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 13


Data Science Tasks
◼Descriptive methods
▪ Find human-interpretable patterns that
describe the data
▪ Example: Clustering

◼Predictive methods
▪ Use some variables to predict unknown
or future values of other variables
▪ Example: Recommender systems

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 14


How It All Fits Together
High
Graph Infinite Machine
dim. Apps
data data learning
data

Locality Filtering
PageRank, Recommen
sensitive data SVM
SimRank der systems
hashing streams

Community Web Decision Association


Clustering
Detection advertising Trees Rules

Dimensional Duplicate
Spam Queries on Perceptron,
ity document
Detection streams kNN
reduction detection

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 15


Map-Reduce and
the New Software
Stack
MapReduce
◼Much of the course will be devoted to
large scale computing for data mining
◼Challenges:
▪ How to distribute computation?
▪ Distributed/parallel programming is hard

◼Map-reduce addresses all of the above


▪ Google’s computational/data manipulation model
▪ Elegant way to work with big data

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 17


Single Node Architecture

CPU
Machine Learning,
Memory Statistics

“Classical” Data
Disk Mining

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 18


Motivation: Google Example

◼20+ billion web pages x 20KB = 400+ TB


◼1 computer reads 30-35 MB/sec from disk
▪ ~4 months to read the web
◼~1,000 hard drives to store the web
◼Takes even more to do something useful
with the data!
◼Today, a standard architecture for such
problems is emerging:
▪ Cluster of commodity Linux nodes
▪ Commodity network (ethernet) to connect them
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 19
Cluster Architecture
2-10 Gbps backbone between racks
1 Gbps between Switch
any pair of nodes
in a rack
Switch Switch

CPU CPU CPU CPU


Me Me Me Me
m … m m … m

Disk Disk Disk Disk

Each rack contains 16-64 nodes

In 2011 it was guestimated that Google had 1M machines, [Link]


J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 20
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 21
Large-scale Computing
◼Large-scale computing for data mining
problems on commodity hardware
◼Challenges:
▪ How do you distribute computation?
▪ How can we make it easy to write distributed
programs?
▪ Machines fail:
▪ One server may stay up 3 years (1,000 days)
▪ If you have 1,000 servers, expect to lose 1/day
▪ People estimated Google had ~1M machines in 2011
▪ 1,000 machines fail every day!
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 22
Idea and Solution
◼Issue: Copying data over a network takes time
◼Idea:
▪ Bring computation close to the data
▪ Store files multiple times for reliability
◼Map-reduce addresses these problems
▪ Google’s computational/data manipulation model
▪ Elegant way to work with big data
▪ Storage Infrastructure – File system
▪ Google: GFS. Hadoop: HDFS
▪ Programming model
▪ Map-Reduce
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 23
Storage Infrastructure
◼Problem:
▪ If nodes fail, how to store data persistently?
◼Answer:
▪ Distributed File System:
▪ Provides global file namespace
▪ Google GFS; Hadoop HDFS;
◼Typical usage pattern
▪ Huge files (100s of GB to TB)
▪ Data is rarely updated in place
▪ Reads and appends are common

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 24


Distributed File System
◼Reliable distributed file system
◼Data kept in “chunks” spread across machines
◼Each chunk replicated on different machines
▪ Seamless recovery from disk or machine failure

C0 C1 D0 C1 C2 C5 C0 C5

C5 C2 C5 C3 D0 D … D0 C2
1
Chunk Chunk Chunk Chunk
server 1 server 2 server 3 server N
Bring computation directly to the
data!
Chunk servers also serve as compute
servers
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 25
Distributed File System
◼Chunk servers
▪ File is split into contiguous chunks
▪ Typically each chunk is 16-64MB
▪ Each chunk replicated (usually 2x or 3x)
▪ Try to keep replicas in different racks
◼Master node
▪ a.k.a. Name Node in Hadoop’s HDFS
▪ Stores metadata about where files are stored
▪ Might be replicated
◼Client library for file access
▪ Talks to master to find chunk servers
▪ Connects directly to chunk servers to access data
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 26
Programming Model: MapReduce

Warm-up task:
◼We have a huge text document
◼Count the number of times each
distinct word appears in the file
◼Sample application:
▪ Analyze web server logs to find popular URLs

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 27


Task: Word Count
Case 1:
▪ File too large for memory, but all <word, count>
pairs fit in memory
Case 2:
◼Count occurrences of words:
▪ words([Link]) | sort | uniq -c
▪ where words takes a file and outputs the words in it,
one per a line
◼Case 2 captures the essence of MapReduce
▪ Great thing is that it is naturally parallelizable

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 28


MapReduce: Overview
◼Sequentially read a lot of data
◼Map:
▪ Extract something you care about
◼Group by key: Sort and Shuffle
◼Reduce:
▪ Aggregate, summarize, filter or transform
◼Write the result

Outline stays the same, Map and


Reduce change to fit the
problem
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 29
MapReduce: The Map Step

Input Intermediate
key-value pairs key-value pairs

k v
ma
k v p k v
ma
k v
p k v

… …

k v k v

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 30


MapReduce: The Reduce Step

Output
Intermediate Key-value groups key-value pairs
key-value pairs
redu
k v k v v v ce k v
redu
Grou
k v k v v ce k v
p
by
k v key
… …

k v k v k v

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 31


More Specifically
◼Input: a set of key-value pairs
◼Programmer specifies two methods:
▪ Map(k, v) → <k’, v’>*
▪ Takes a key-value pair and outputs a set of key-value pairs
▪ E.g., key is the filename, value is a single line in the file
▪ There is one Map call for every (k,v) pair
▪ Reduce(k’, <v’>*) → <k’, v’’>*
▪ All values v’ with same key k’ are reduced together
and processed in v’ order
▪ There is one Reduce function call per unique key k’

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 32


MapReduce: Word Counting

Provided by the Provided by the


programmer programmer
MAP: Reduce:
Group by Collect all
Read input and
produces a set key: values
Collect all pairs belonging to
of key-value
with same key the key and
pairs
output

read the
The crew of the space (The, 1)
(crew, 1)
shuttle Endeavor recently (crew, 1)

sequential
returned to Earth as (crew, 1)
ambassadors, harbingers (of, 1) (crew, 2)
of a new era of space (space, 1)
(the, 1) (space, 1)
exploration. Scientists at
(the, 1)

Sequentially
NASA are saying that the (space, 1) (the, 3)
recent assembly of the (the, 1)
Dextre bot is the first step (shuttle, 1) (shuttle, 1)
in a long-term space-based (the, 1)
(Endeavor, (recently, 1)
man/mache partnership. (shuttle, 1)

reads
data
Only
'"The work we're doing now 1) …
-- the robotics we're doing (recently, 1)
-- is what we're going to (recently, 1)

need ……………………..
….
Big document (key, value) (key, value) (key, value)
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 33
Word Count Using MapReduce

map(key, value):
// key: document name; value: text of the document
for each word w in value:
emit(w, 1)

reduce(key, values):
// key: a word; value: an iterator over counts
result = 0
for each count v in values:
result += v
emit(key, result)

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 34


Map-Reduce: Environment

Map-Reduce environment takes care of:


◼Partitioning the input data
◼Scheduling the program’s execution across a
set of machines
◼Performing the group by key step
◼Handling machine failures
◼Managing required inter-machine
communication

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 35


Map-Reduce: A diagram
Big
MAP: document
Read input and
produces a set
of key-value
pairs

Group by
key:
Collect all pairs
with same key
(Hash merge,
Shuffle, Sort,
Partition)

Reduce:
Collect all
values
belonging to the
key and output

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 36


Map-Reduce: In Parallel

All phases are distributed with many tasks


J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 37
Map-Reduce
◼ Programmer specifies: Inpu Inpu Inpu
▪ Map and Reduce and input files t0 t1 t2
◼ Workflow:
▪ Read inputs as a set of key-value-pairs Map Map Map
▪ Map transforms input kv-pairs into a new 0 1 2
set of k'v'-pairs
▪ Sorts & Shuffles the k'v'-pairs to output Shuffl
nodes e
▪ All k’v’-pairs with a given k’ are sent to the
Reduc Reduc
same reduce e0 e1
▪ Reduce processes all k'v'-pairs grouped by
key into new k''v''-pairs
▪ Write the resulting pairs to files Out Out
0 1
◼ All phases are distributed with many
tasks doing the work
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 38
Data Flow
◼Input and final output are stored on a
distributed file system (FS):
▪ Scheduler tries to schedule map tasks “close” to
physical storage location of input data

◼Intermediate results are stored on local FS


of Map and Reduce workers
◼Output is often input to another
MapReduce task

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 39


Coordination: Master
◼Master node takes care of coordination:
▪ Task status: (idle, in-progress, completed)
▪ Idle tasks get scheduled as workers become
available
▪ When a map task completes, it sends the master
the location and sizes of its R intermediate files,
one for each reducer
▪ Master pushes this info to reducers

◼Master pings workers periodically to detect


failures
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 40
Dealing with Failures
◼Map worker failure
▪ Map tasks completed or in-progress at
worker are reset to idle
▪ Reduce workers are notified when task is
rescheduled on another worker
◼Reduce worker failure
▪ Only in-progress tasks are reset to idle
▪ Reduce task is restarted
◼Master failure
▪ MapReduce task is aborted and client is notified

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 41


How many Map and Reduce jobs?

◼M map tasks, R reduce tasks


◼Rule of a thumb:
▪ Make M much larger than the number of nodes
in the cluster
▪ One DFS chunk per map is common
▪ Improves dynamic load balancing and speeds up
recovery from worker failures
◼Usually R is smaller than M
▪ Because output is spread across R files

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 42


Task Granularity & Pipelining

◼Fine granularity tasks: map tasks >> machines


▪ Minimizes time for fault recovery
▪ Can do pipeline shuffling with map execution
▪ Better dynamic load balancing

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 43


Problems Suited for
Map-Reduce
Example: Host size
◼Suppose we have a large web corpus
◼Look at the metadata file
▪ Lines of the form: (URL, size, date, …)
◼For each host, find the total number of bytes
▪ That is, the sum of the page sizes for all URLs from
that particular host

◼Other examples:
▪ Link analysis and graph processing
▪ Machine Learning algorithms

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 45


Example: Language Model

◼Statistical machine translation:


▪ Need to count number of times every 5-word
sequence occurs in a large corpus of documents

◼Very easy with MapReduce:


▪ Map:
▪ Extract (5-word sequence, count) from document
▪ Reduce:
▪ Combine the counts

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 46


Example: Join By Map-Reduce

◼Compute the natural join R(A,B) ⋈ S(B,C)


◼R and S are each stored in files
◼Tuples are pairs (a,b) or (b,c)

A B B C A C
a1 b1 b2 c1 a3 c1
a2
a3
b1
b2
⋈ b2 c2 = a3 c2
b3 c3 a4 c3
a4 b3
S
R

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 47


Map-Reduce Join
◼Use a hash function h from B-values to 1...k
◼A Map process turns:
▪ Each input tuple R(a,b) into key-value pair (b,(a,R))
▪ Each input tuple S(b,c) into (b,(c,S))

◼Map processes send each key-value pair with


key b to Reduce process h(b)
▪ Hadoop does this automatically; just tell it what k is.
◼Each Reduce process matches all the pairs (b,
(a,R)) with all (b,(c,S)) and outputs (a,b,c).
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 48
Pointers and Further
Reading
Implementations
◼Google
▪ Not available outside Google
◼Hadoop
▪ An open-source implementation in Java
▪ Uses HDFS for stable storage
▪ Download: [Link]
◼ Aster Data
▪ Cluster-optimized SQL Database that also
implements MapReduce
◼ CouchDB
▪ A noSQL database that uses map-reduce to
implement an aggregation function (view)
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 50
Cloud Computing
◼Ability to rent computing by the hour
▪ Additional services e.g., persistent storage

◼Amazon’s “Elastic Compute Cloud” (EC2)


◼Aster Data and Hadoop can both be run on
EC2

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 51


Reading
◼Jeffrey Dean and Sanjay Ghemawat:
MapReduce: Simplified Data Processing on
Large Clusters
▪ [Link]

◼Sanjay Ghemawat, Howard Gobioff, and Shun-


Tak Leung: The Google File System
▪ [Link]

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 52


Resources
◼ Hadoop Wiki
▪ Introduction
▪ [Link]
▪ Getting Started
▪ [Link]
adoop
▪ Map/Reduce Overview
▪ [Link]
▪ [Link]
es
▪ Eclipse Environment
▪ [Link]
◼ Javadoc
J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 53
Resources
◼ Releases from Apache download mirrors
▪ [Link]
oop/
◼ Nightly builds of source
▪ [Link]
htly/
◼ Source code from subversion
▪ [Link]
html

J. Leskovec, A. Rajaraman, J. Ullman: Mining of Massive Datasets, [Link] 54

You might also like