Social Media Mining - Chapter 5 (Data Mining Essentials)
Jun. 21, 2016β’0 likes
1 likes
Be the first to like this
Show More
β’1,507 views
views
Total views
0
On Slideshare
0
From embeds
0
Number of embeds
0
Download to read offline
Report
Education
R. Zafarani, M. A. Abbasi, and H. Liu, Social Media Mining: An Introduction, Cambridge University Press, 2014.
Free book and slides at http://socialmediamining.info/
2Social Media Mining Measures and Metrics 2Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Dear instructors/users of these slides:
Please feel free to include these slides in your own
material, or modify them as you see fit. If you decide
to incorporate these slides into your presentations,
please include the following note:
R. Zafarani, M. A. Abbasi, and H. Liu, Social Media Mining:
An Introduction, Cambridge University Press, 2014.
Free book and slides at http://socialmediamining.info/
or include a link to the website:
http://socialmediamining.info/
3Social Media Mining Measures and Metrics 3Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Introduction
Data production rate has increased
dramatically (Big Data) and we are
able store much more data
β E.g., purchase data, social media
data, cellphone data
Businesses and customers need
useful or actionable knowledge to
gain insight from raw data for
various purposes
β Itβs not just searching data or
databases
The process of extracting useful patterns from raw data is
known as Knowledge Discovery in Databases (KDD)
4Social Media Mining Measures and Metrics 4Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
KDD Process
5Social Media Mining Measures and Metrics 5Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Collecting Data on Social Media
β’ Collect Raw Data
β Use site provided APIs
β’ Flickrβs: https://www.flickr.com/services/api/
β Scrape information directly
β’ Use Provided Repositories
β http://socialcomputing.asu.edu
β http://snap.Stanford.edu
β https://github.com/caesar0301/awesome-public-
datasets
6Social Media Mining Measures and Metrics 6Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Data Mining
β’ Extracting/βminingβ knowledge from large-scale data (big data)
β’ Data-driven discovery and modeling of hidden patterns in big data
β’ Extracting information/knowledge from data that is
β implicit,
β previously unknown,
β unexpected, and
β potentially useful
Data Mining: the process of discovering hidden and
actionable patterns from data
It utilizes methods at the intersection of artificial intelligence,
machine learning, statistics, and database systems
7Social Media Mining Measures and Metrics 7Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Data Mining vs. Databases
β’ Data mining is the process of extracting
hidden and actionable patterns from data
β’ Database systems store and manage data
β Queries return part of stored data
β Queries do not extract hidden patterns
β’ Examples of querying databases
β Find all employees with income more than $250K
β Find top spending customers in last month
β Find all students from engineering college with GPA
more than average
8Social Media Mining Measures and Metrics 8Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Examples of Data Mining Applications
β’ Fraud/Spam Detections: Identifying fraudulent
transactions of a credit card or spam emails
β You are given a userβs purchase history and a new transaction,
identify whether the transaction is fraud or not;
β Determine whether a given email is spam or not
β’ Frequent Patterns: Extracting purchase patterns
from existing records
β beer β dippers (80%)
β’ Forecasting: Forecasting future sales and needs
according to some given samples
β’ Finding Like-Minded Individuals: Extracting groups
of like-minded people in a given network
9Social Media Mining Measures and Metrics 9Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Data
10Social Media Mining Measures and Metrics 10Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Data Instances
β’ In the KDD process,
β Data is in a tabular format (a set of instances)
β’ Each instance is a collection of properties and features
related to an object or person
β A patientβs medical record
β A userβs profile
β A geneβs information
β’ Instances are also called points, data points, or
observations
Data Instance:
Features ( Attributes or measurements) Class Label
Feature Value Class Attribute
11Social Media Mining Measures and Metrics 11Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Data Instances
β’ Predicting whether an individual who visits an online
book seller is going to buy a specific book
β’ Features can be
β Continues: values are numeric values
β’ Money spent: $25
β Discrete: can take a number of values
β’ Money spent: {high, normal, low}
Labeled
Example
Unlabeled
Example
12Social Media Mining Measures and Metrics 12Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Data Types + Permissible Operations (statistics)
β’ Nominal
β Operations:
β’ Mode (most common feature value), Equality Comparison
β E.g., {male, female}
β’ Ordinal
β Feature values have an intrinsic order to them, but the difference is not
defined
β Operations:
β’ same as nominal, feature value rank
β E.g., {Low, medium, high}
β’ Interval
β Operations:
β’ Addition and subtractions are allowed whereas divisions and multiplications are
not
β E.g., 3:08 PM, calendar dates
β’ Ratio
β Operations:
β’ divisions and multiplications are allowed
β E.g., Height, weight, money quantities
13Social Media Mining Measures and Metrics 13Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Sample Dataset β Twitter Users
Activity Date Joined Number of Followers Verified Account?
Has Profile
Picture?
High 2015 50 FALSE no
High 2013 300 TRUE no
Average 2011 860000 FALSE yes
Low 2012 96 FALSE yes
High 2008 8,000 FALSE yes
Average 2009 5 TRUE no
Very High 2010 650,000 TRUE yes
Low 2010 95 FALSE no
Average 2011 70 FALSE yes
Very High 2013 80,000 FALSE yes
Low 2014 70 TRUE yes
Average 2013 900 TRUE yes
High 2011 7500 FALSE yes
Low 2010 910 TRUE no
NominalOrdinal Interval Ratio Nominal
14Social Media Mining Measures and Metrics 14Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Text Representation
β’ The most common way to represent
documents is to transform them into vectors
β Process them with linear algebraic operations
β’ This representation is called βBag of Wordsβ
β Vector Space Model
β’ Weights for words can be assigned by TF-IDF
15Social Media Mining Measures and Metrics 15Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Vector Space Model
β’ Consider a set of documents π·
β’ Each document is a set of words
β’ Goal: convert these documents to vectors
How to set ππ, π
β’ Set π€π, π to 1 when the word π exists in document π and 0
when it does not.
β’ We can also set π€π, π to the number, of times the word π
is observed in document π (frequency)
β’ ππ : document π
β’ π€π, π : the weight for word π in document π
16Social Media Mining Measures and Metrics 16Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Vector Space Model: An Example
β’ Documents:
β π1: social media mining
β π2: social media data
β π3: financial market data
β’ Reference vector (Dictionary):
β (social, media, mining, data, financial, market)
β’ Vector representation:
17Social Media Mining Measures and Metrics 17Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
TF-IDF (Term Frequency-Inverse Document Frequency)
TF-IDF of term (word) π‘, document π, and
document corpus π· is calculated as follows:
is the frequency of word π in document π
The total number of
documents in the corpus
The number of documents where the term π appears
18Social Media Mining Measures and Metrics 18Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
TF-IDF: An Example
Document π1 contains 100 words
β Word βappleβ appears 10 times in π1
β Word βorangeβ appears 20 times in π1
We have |π·| = 20 documents
β Word βappleβ only appears in document π1
β Word βorangeβ appears in all 20 documents
19Social Media Mining Measures and Metrics 19Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
TF-IDF: An Example
β’ Documents:
β π1: social media mining
β π2: social media data
β π3: financial market data
β’ TF values:
β’ TF-IDF
20Social Media Mining Measures and Metrics 20Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Data Quality
When making data ready for mining, data quality needs to be assured
β’ Noise
β Noise is the distortion of the data
β’ Outliers
β Outliers are data points that are considerably different from other data points in
the dataset
β’ Missing Values
β Missing feature values in data instances
β Solution:
β’ Remove instances that have missing values
β’ Estimate missing values, and
β’ Ignore missing values when running data mining algorithm
β’ Duplicate data
21Social Media Mining Measures and Metrics 21Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Data Preprocessing
β’ Aggregation
β It is performed when multiple features need to be combined into a single one or
when the scale of the features change
β Example: image width , image height -> image area (width x height)
β’ Discretization
β From continues values to discrete values
β Example: money spent -> {low, normal, high}
β’ Feature Selection
β Choose relevant features
β’ Feature Extraction
β Creating new features from original features
β Often, more complicated than aggregation
β’ Sampling
β Random Sampling
β Sampling with or without replacement
β Stratified Sampling: useful when having class imbalance
β Social Network Sampling
22Social Media Mining Measures and Metrics 22Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Data Preprocessing
Sampling social networks:
β’ Start with a small set of nodes
(seed nodes)
β’ Sample
β (a) the connected components
they belong to;
β (b) the set of nodes (and edges)
connected to them directly; or
β (c) the set of nodes and edges
that are within n-hop distance
from them.
23Social Media Mining Measures and Metrics 23Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Data Mining Algorithms
24Social Media Mining Measures and Metrics 24Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Data Mining Algorithms
β’ Supervised Learning Algorithm
β Classification (class attribute is discrete)
β’ Assign data into predefined classes
β Spam Detection
β Regression (class attribute takes real values)
β’ Predict a real value for a given data instance
β Predict the price for a given house
β’ Unsupervised Learning Algorithm
β Group similar items together into some clusters
β’ Detect communities in a given social network
25Social Media Mining Measures and Metrics 25Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Supervised Learning
26Social Media Mining Measures and Metrics 26Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Supervised Learning: The Process
β’ We are given a set of labeled records/instances
β In the format (πΏ, π¦)
β πΏ is a vector of features
β π¦ is the class attribute (commonly a scalar)
β’ [Training] The supervised learning task is to build model that
maps πΏ to π¦ (find a mapping π such that π(πΏ) = π¦)
β’ [Testing] Given an unlabeled instance (πΏβ, ? ), we compute π(πΏβ)
β E.g., spam/non-spam prediction
27Social Media Mining Measures and Metrics 27Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Classification: An Email Example
β’ A set of emails is given
β Users have manually labeled
them as spam / non-spam
β’ Use a set of features (x) to
identify spam/non-spam
status of the email (y)
β We can use words in the email
β’ In this case, classes are
π¦ = {π πππ, πππ β π πππ}
28Social Media Mining Measures and Metrics 28Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
A Twitter Example
29Social Media Mining Measures and Metrics 29Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Supervised Learning Algorithms
β’ Classification
β Decision tree learning
β Naive Bayes Classifier
β π-nearest neighbor classifier
β Classification with Network information
β’ Regression
β Linear Regression
β Logistic Regression
30Social Media Mining Measures and Metrics 30Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Decision Tree Learning
31Social Media Mining Measures and Metrics 31Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Decision Tree
β’ A decision tree is
learned from the
dataset
β (training data with known
classes)
β’ The learned tree is later
applied to predict the
class attribute value of
new data
β (test data with unknown
classes)
β Only the feature values
are known
32Social Media Mining Measures and Metrics 32Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Decision Tree: Example
Class Labels
Multiple
decision trees
can be learned
from the same
dataset
33Social Media Mining Measures and Metrics 33Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Decision Tree Construction
β’ Decision trees are constructed recursively
β A top-down greedy approach in which features are sequentially
selected.
β’ After selecting a feature for each node,
β based on its attribute values, different branches are created.
β’ The training set is then partitioned into subsets based on
the feature values,
β each of which fall under the respective feature value branch;
β The process is continued for these subsets and other nodes
β’ When selecting features, we prefer features that partition
the set of instances into subsets that are more pure.
β’ A pure subset has instances that all have the same class
attribute value.
34Social Media Mining Measures and Metrics 34Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Decision Tree Construction
β’ When reaching pure (or highly pure) subsets under a branch,
β the decision tree construction process no longer partitions the
subset,
β creates a leaf under the branch, and
β assigns the class attribute value (or the majority class attribute value)
for subset instances as the leafβs predicted class attribute value
β’ To measure purity we can use/minimize entropy.
β’ Over a subset of training instances, π, with a binary class
attribute (values in {+,-}), the entropy of π is defined as:
β π+ is the proportion of positive examples in π
β πβ is the proportion of negative examples in π
35Social Media Mining Measures and Metrics 35Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Entropy Example
Assume there is a subset π that has 10 instances:
β’ Seven instances have a positive class attribute value
β’ Three have a negative class attribute value
β’ Denote π as [7+, 3-]
β’ The entropy for subset π is
In a pure subset, all instances have the same class attribute
value (entropy is 0)
If the subset contains an unequal number of positive and
negative instances
β’ The entropy is between 0 and 1.
36Social Media Mining Measures and Metrics 36Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
NaΓ―ve Bayes Learning
37Social Media Mining Measures and Metrics 37Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Naive Bayes Classifier
For two random variables πΏ and π, Bayes
theorem states that,
class variable the instance features
Then class attribute value for instance πΏ
We assume that features
are independent given the
class attribute
38Social Media Mining Measures and Metrics 38Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
NBC: An Example
39Social Media Mining Measures and Metrics 39Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Nearest Neighbor Classifier
40Social Media Mining Measures and Metrics 40Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Nearest Neighbor Classifier
β’ π-nearest neighbor or π-NN,
β Utilizes the neighbors of an instance to perform classification.
β’ It uses the π nearest instances, called neighbors, to
perform classification.
β’ The instance being classified is assigned the label (class
attribute value) that the majority of its π neighbors are
assigned
β’ When π = 1, the closest neighborβs label is used as the
predicted label for the instance being classified
β’ To determine the neighbors of an instance, we need to
measure its distance to all other instances based on some
distance metric.
β Often Euclidean distance is employed
41Social Media Mining Measures and Metrics 41Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
π-NN: Algorithm
42Social Media Mining Measures and Metrics 42Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
π-NN example
β’ When π = 5, the predicted label is:
β’ When π = 9, the predicted label is:
β
β‘
43Social Media Mining Measures and Metrics 43Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
π-NN: Example 2
Data instance Outlook Temperature Humidity Similarity Label K Prediction
2 1 1 1 3 N 1 N
1 1 0 1 2 N 2 N
4 0 1 1 2 Y 3 N
3 0 0 1 1 Y 4 ?
5 1 0 0 1 Y 5 Y
6 0 0 0 0 N 6 ?
7 0 0 0 0 Y 7 Y
Similarity between row 8 and other data instances;
(Similarity = 1 if attributes have the same value, otherwise similarity = 0)
44Social Media Mining Measures and Metrics 44Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Classification with
Network Information
45Social Media Mining Measures and Metrics 45Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Classification with Network Information
β’ Consider a friendship network on social media and a
product being marketed to this network.
β’ The product seller wants to know who the potential buyers
are for this product.
β’ Assume we are given the network with the list of
individuals that decided to buy or not buy the product. Our
goal is to predict the decision for the undecided
individuals.
β’ This problem can be formulated as a classification problem
based on features gathered from individuals.
β’ However, in this case, we have additional friendship
information that may be helpful in building better
classification models
46Social Media Mining Measures and Metrics 46Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Classification with Network Information
β’ Let π¦π denote the label for node π.
β’ We can assume that
β’ How can we estimate P(π¦π = 1|π π£π )?
47Social Media Mining Measures and Metrics 47Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Weighted-vote Relational-Neighbor (wvRN)
wvRN provides an approach to estimate P(π¦π = 1|π π£π )
β’ In wvRN, to find the label of a node, we compute a
weighted vote among its neighbors
β’ P(π¦π = 1|π π£π ) is only calculated for unlabeled π£πβs
β’ We need to compute these probabilities using some
order until convergence [i.e., they donβt change]
β What happens for different orders?
48Social Media Mining Measures and Metrics 48Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
wvRN example
49Social Media Mining Measures and Metrics 49Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
wvRN example
50Social Media Mining Measures and Metrics 50Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Regression
51Social Media Mining Measures and Metrics 51Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Regression
In regression,
β’ Class values are real
numbers as class values
β In classification, class
values are categorical
π¦ β π(π)
Features
(regressors)
π = (π₯1, π₯2, β¦ , π₯ π)
Class attribute
(dependent variable)
π¦οπ
Goal: find the relation between π¦
and vector π = (π₯1, π₯2, β¦ , π₯ π)
52Social Media Mining Measures and Metrics 52Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Linear Regression
β’ Linear regression: we assume the relation
between the class attribute π and feature set πΏ is
linear
β’ π represents the vector of regression coefficients
β’ Regression can be solved by estimating π and
ο₯ using the provided dataset and the labels π
β βLeast squaresβ is a popular method to solve regression
β The goal is to minimize
53Social Media Mining Measures and Metrics 53Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Least Squares
Find π such that minimizing Ηπ β ππΗ2 for
regressors πΏ and labels π
54Social Media Mining Measures and Metrics 54Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Simplifying W with SVD
SVD of πΏ
55Social Media Mining Measures and Metrics 55Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Logistic Regression
β’ A probabilistic view of regression
β’ Assuming the class attribute is binary, logistic
regression finds the probability π
β’ We can assume that π can be obtained from π
β’ Unbounded: π can take any values and π½ is
also unconstrained
π: Feature vector
56Social Media Mining Measures and Metrics 56Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Logistic Regression
β’ Solution: transform π using π(π), such that
π(π) is unbounded
β Fit π(π) using π½X
β’ Known an as the logit function
β’ For any π between [0,1]
β πΊ(π) is in range [ββ, +β]
57Social Media Mining Measures and Metrics 57Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Logistic Regression
Logistic Function
β Acts as a probability
β’ Goal: Find π½ such that π(π|π) is maximized
β No closed form solution
β Iterative maximum likelihood
β’ Prediction: once π½ is determined compute π(π|π)
β For a binary class problem if it is more than 0.5, predict 1
58Social Media Mining Measures and Metrics 58Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Supervised Learning
Evaluation
59Social Media Mining Measures and Metrics 59Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Evaluating Supervised Learning
β’ Training/Testing Framework:
β A training dataset (i.e., the labels are known) is used to train a model
β the model is evaluated on a test dataset.
β’ The correct labels of the test dataset are unknown,
β In practice, the training set is divided into two parts,
β’ One used for training and
β’ The other used for testing.
β’ When testing, the labels from this test set are removed.
β After these labels are predicted using the model, the predicted
labels are compared with the masked labels (ground truth).
60Social Media Mining Measures and Metrics 60Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Evaluating Supervised Learning
β’ Dividing the training set into train/test sets
β Leave-one-out training
β’ Divide the training set into π equally sized partitions
β Often called folds
β’ Use all folds but one to train and the one left out for testing
β π-fold cross validation training
β’ Divide the training set into π equally sized sets
β’ Run the algorithm π times
β’ In round π, we use all folds but fold π for training and fold π for
testing.
β’ The average performance of the algorithm over π rounds
measures the performance of the algorithm.
61Social Media Mining Measures and Metrics 61Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Evaluating Supervised Learning
β’ As the class labels are discrete, we can measure the
accuracy by dividing number of correctly predicted
labels (πΆ) by the total number of instances (π)
β’ More sophisticated approaches of evaluation
β’ AUC
β’ F-Measure
62Social Media Mining Measures and Metrics 62Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Evaluating Regression Performance
β’ The labels cannot be predicted precisely
β’ We need to set a margin to accept or reject
the predictions
β Example. When the observed temperature is 71,
any prediction in the range of 71Β±0.5 can be
considered as a correct prediction
β’ Or, we can use correlation between predicted
labels and the ground truth.
63Social Media Mining Measures and Metrics 63Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Unsupervised Learning
64Social Media Mining Measures and Metrics 64Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Unsupervised Learning
β’ Clustering is a form of
unsupervised
learning
β’ Clustering algorithms
group together
similar items
β’ The algorithm does not
have examples showing
how the samples should
be grouped together
(unlabeled data)
Unsupervised division of instances
into groups of similar objects
Kernel Density Estimation
65Social Media Mining Measures and Metrics 65Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Measuring Distance/Similarity in Clustering
β’ Clustering Goal: Group together similar items
β’ Instances are put into different clusters based
on the distance to other instances
β’ Any clustering algorithm requires a distance
measure
The most popular
(dis)similarity measure for
continuous features are
Euclidean Distance and
Pearson Linear Correlation
Euclidean Distance
66Social Media Mining Measures and Metrics 66Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Similarity Measures
β’ π and π are π-dimensional vectors
Once a distance measure is selected, instances are grouped using it.
67Social Media Mining Measures and Metrics 67Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Clustering
β’ Clusters are usually represented by compact and
abstract notations.
β’ βCluster centroidsβ are one common example of
this abstract notation.
β’ Partitional Algorithms (most common type)
β Partition the dataset into a set of clusters
β Each instance is assigned to a cluster exactly once
β No instance remains unassigned to clusters.
β’ Example: π-means
68Social Media Mining Measures and Metrics 68Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
π-means for π = 6
69Social Media Mining Measures and Metrics 69Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
π-means
The most commonly used clustering algorithm
β Related to Expectation Maximization (EM) in statistics.
70Social Media Mining Measures and Metrics 70Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
π-means: Algorithm
Given data points π₯π and an initial set
of π centroids π1
1
, π2
1
,β¦, π π
1
the algorithm proceeds
as follows:
β’ Assignment step: Assign each data point to the
cluster ππ
π‘
with the closest centroid
β Each data point goes into exactly one cluster
β’ Update step: Calculate the new means to be
the centroid of the data points in the cluster
β After all points are assigned
71Social Media Mining Measures and Metrics 71Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
When do we stop?
The procedure is repeated until convergence
β’ Convergence:
β Whether centroids are no longer changing
β Equivalent to clustering assignments not changing
β The algorithm can be stopped when the Euclidean
distance between the centroids in two consecutive
steps is less than some small positive value
72Social Media Mining Measures and Metrics 72Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
π-means (alternative!)
β’ As an alternative, π-means implementations try to
minimize an objective function.
β Example: the squared distance error:
β π₯π
π
is the πth instance of cluster π
β π(π) is the number of instances in cluster π
β ππ is the centroid of cluster π.
β’ Stopping Criterion:
β when the difference between the objective function
values of two consecutive iterations of the π-means
algorithm is less than some small value .
73Social Media Mining Measures and Metrics 73Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
π-means
β’ Finding the global optimum of the π partitions is
computationally expensive (NP-hard).
β’ This is equivalent to finding the optimal centroids
that minimize the objective function
β’ Solution: efficient heuristics
β Outcome: converge quickly to a local optimum that
might not be global
β Example: running π-means multiple times
β’ Select the clustering assignment that is observed most often or
β’ Select the clustering that is more desirable based on an
objective function, such as the squared error.
74Social Media Mining Measures and Metrics 74Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Unsupervised Learning
Evaluation
75Social Media Mining Measures and Metrics 75Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Evaluating the Clusterings
β’ Evaluation with ground truth
β’ Evaluation without ground truth
We are given two
types of objects
β’ In perfect
clustering,
objects of the
same type are
clustered
together.
76Social Media Mining Measures and Metrics 76Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Evaluation with Ground Truth
When ground truth is available,
β We have prior knowledge on what the clustering
should be (the correct clustering assignments)
β’ We will discuss these methods in community
analysis chapter
77Social Media Mining Measures and Metrics 77Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Evaluation without Ground Truth
β’ Cohesiveness
β In clustering, we are interested in clusters that
exhibit cohesiveness
β In cohesive clusters, instances inside the clusters
are close to each other
β’ Separateness
β We are also interested in clusterings of the data
that generates clusters that are well separated
from one another
78Social Media Mining Measures and Metrics 78Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Cohesiveness
β’ Cohesiveness
β In statistics: having a small standard deviation, i.e.,
being close to the mean value
β In clustering: being close to the centroid of the cluster
79Social Media Mining Measures and Metrics 79Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Separateness
β’ Separateness
β In statistics: separateness can be measured by
standard deviation
β’ Standard deviation is maximized when instances are far
from the mean
β In clustering: cluster centroids being far from the
mean of the entire dataset
80Social Media Mining Measures and Metrics 80Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Silhouette Index
β’ We are interested in clusters that are both cohesive and
separate
β Silhouette index
β’ It compares
β the average distance value between instances in the same cluster
To
β the average distance value between instances in different clusters
β’ In a well-clustered dataset,
β the average distance between instances in the same cluster is
small (cohesiveness) and
β the average distance between instances in different clusters is
large (separateness).
81Social Media Mining Measures and Metrics 81Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Silhouette Index
β’ For any instance π₯ that is a member of cluster πΆ
β’ Compute the within-cluster average distance
β’ Compute the average distance between π₯ and
instances in cluster πΊ
β πΊ is closest to π₯ in terms of the average distance
between π₯ and members of πΊ
82Social Media Mining Measures and Metrics 82Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Silhouette Index
β’ Our interest: clusterings where π(π₯) < π(π₯)
β’ Silhouette can take values between [β1,1]
β’ The best case happens when for all π₯,
β π(π₯) = 0, π(π₯) > π(π₯)
83Social Media Mining Measures and Metrics 83Social Media Mining Data Mining Essentialshttp://socialmediamining.info/
Silhouette Index - Example
Editor's Notes
Beer and chips are not interesting patterns, for example.
Weather dataset
number of documents where the term t appearsΒ
Using the inverse of similarity as a distance measure
\frac{\partial}{\partial W} {(W^T X^T Y )} = X^T Y
\frac{\partial}{\partial W} { (W^T X^T X W) } = 2 X^T X W
SVD form of matrix X: X = U \Sigma V^T
U and V are real valued, they each are an orthogonal matrix
U^T = U^{-1}
V is orthogonal so: V^T^{-1} = V
(V \Sigma^2 V^T)^{-1} = V^T^{-1} \Sigma^{-2} V^T = V \Sigma^{-2} V^T