Difference between revisions of "Unsupervised Learning"

From Bitnami MediaWiki
Jump to navigation Jump to search
 
(15 intermediate revisions by the same user not shown)
Line 41: Line 41:
 
* Grouping or segmenting a collection of objects into clusters, such that things within a cluster have more in common that with things in another cluster (Hastie, p.501). Also used to check if different clusters actually contain substantially different objects, which requires assesssing some sort of distance metric. Key insight is the ''degree of similarity''.  
 
* Grouping or segmenting a collection of objects into clusters, such that things within a cluster have more in common that with things in another cluster (Hastie, p.501). Also used to check if different clusters actually contain substantially different objects, which requires assesssing some sort of distance metric. Key insight is the ''degree of similarity''.  
 
* Most algorithms use a (non-negative) ''dis''similarity matrix. The proximity matrix <math>\mathbf{D}</math> is a matrix of dissimilarities (covariances) with zeros on the diagonal.  
 
* Most algorithms use a (non-negative) ''dis''similarity matrix. The proximity matrix <math>\mathbf{D}</math> is a matrix of dissimilarities (covariances) with zeros on the diagonal.  
−
::<math>D(x_i, x_{i\prime})</math> where the RHS is usually the squared distance.  
+
::<math>D(x_i, x_{i^\prime}) = \displaystyle\sum^p_{j=1} d_j (x_{ij}, x_{i^\prime j})</math>  
 +
where the RHS is usually the squared distance.  
 +
* Appropriate distance metrics vary by feature type:
 +
** Numeric: absolute error, squared error loss, correlation
 +
** Ordinal: <math>\dfrac{i-1/2}{M}, i=1,\dots,M</math>
 +
** Categorical: degree-of-difference must be delineated explicitly
  
 +
====K-Means====
 +
*Popular iterative descent clustering method. Intended for only numeric data
 +
* Euclidean distance is the metric: <math>\parallel x_i - x_{i^\prime}\parallel^2 </math>
 +
* The algorithm:
 +
 +
1. Minimize total cluster variance:
 +
:: <math> \underset{C,\{m_k\}^K_1}{\min} \sum^K_{k=1}N_k \sum_{C(i)=k} \parallel x_i - m_k\parallel^2 </math>
 +
 +
2. Given current means <math>\{m_1,\dots,m_k\} </math>, minimize the above by assigning each observation to the nearest cluster mean:
 +
:: <math> C(i) =\underset{1\leq k\leq K}{\arg\min} \parallel x_i - m_k\parallel^2 </math>
  
−
====K-Means====
+
====Hierarchical Clustering====
 +
* Requires specifying a dissimilarity measure between (disjoint) groups of observations. ''Agglomerative'' strategies are bottom-up and ''divisive'' are top-down.
  
−
====Vector Quantization====
 
  
−
====
+
====Other Methods====
 +
* Vector Quantization ('''VQ'''): takes a 1MB image of 1024x1024 pixels (grayscale; requires 8 bits per pixel to store). Break image into 2x2 blocks. Each of the four 512x512 blocks into which the image is split is a vector in <math>\mathbb{R}^4</math>. K-means is then run for K=200 on the middle (23.9% compressed) image. Each 512x512 block is approximated by its closest centroid, its ''codeword''. Clustering is the ''encoding'' step, and the collection of centroids is the ''codebook''. Compression is <math>\log_2(K)/(4\cdot 8) = 0.2388</math>
  
 
===Self-Organizing Maps===
 
===Self-Organizing Maps===
  
 
===Principal Components, Curves and Surfaces===
 
===Principal Components, Curves and Surfaces===
 +
====Principal Components====
 +
 +
 +
====Kernel PCA====
 +
 +
 +
====Sparse PCA====
  
 
===Non-Negative Matrix Factorization===
 
===Non-Negative Matrix Factorization===

Latest revision as of 21:53, 16 March 2021

Following Hastie et al.

Supervised learning concerns finding a conditional density estimation [math]\displaystyle{ \text{Pr}(Y|X) }[/math]. In unsupervised learning, the goal is to directly infer properties about the joint marginal density of [math]\displaystyle{ \text{Pr}(X) }[/math]:

[math]\displaystyle{ \text{Pr}(X,Y) = \text{Pr}(Y|X)\cdot \text{Pr}(X) }[/math]

Association Rules[edit]

Goal: Find subsets of variable values [math]\displaystyle{ s_1, \dots, s_p }[/math] such that the probability of each of the variables occupying a value within its respective subset is large. (The intersection of subsets is called a conjunctive rule):

[math]\displaystyle{ \text{Pr}\left [\, \bigcap^p_{j=1} (X_j \in s_j) \right ] }[/math]

Market Basket Analysis[edit]

Assume all subsets are either [math]\displaystyle{ s_j }[/math] consists of exactly one value of [math]\displaystyle{ X_j }[/math] or it's the entire set of possible [math]\displaystyle{ X_j }[/math] values, [math]\displaystyle{ s_j = \mathcal{S}_j }[/math]. Usually dummy variables are used such that the number of dummies is

[math]\displaystyle{ K=\displaystyle\sum^p_{j=1}|\mathcal{S_j}| }[/math]

where [math]\displaystyle{ |\mathcal{S_j}| }[/math] is number of unique [math]\displaystyle{ X_j }[/math] Each of the [math]\displaystyle{ K }[/math] new [math]\displaystyle{ Z }[/math] variables has the value [math]\displaystyle{ Z_k=1 }[/math] or [math]\displaystyle{ 0 }[/math]. This recasts the problem into finding a subset of the integers [math]\displaystyle{ \mathcal{K} \subset \{1,\dots,K\} }[/math] so that

[math]\displaystyle{ \text{Pr}\left [\,\bigcap_{k\in\mathcal{K}}(Z_k=1)\right ] = \text{Pr} \left [\,\prod_{k\in\mathcal{K}} Z_k = 1 \right ] \implies \widehat{\text{Pr}}\left [\,\prod_{k\in\mathcal{K}}(Z_k=1)\right ] = \dfrac{1}{N}\sum^N_{i=1}\prod_{k\in\mathcal{K}}z_{ik} }[/math]

[math]\displaystyle{ z_{ik} }[/math] is the ith case of [math]\displaystyle{ Z_k }[/math] and is called the "support" or "prevalence" of the item set [math]\displaystyle{ \mathcal{K} }[/math], denoted [math]\displaystyle{ T(\mathcal{K}) }[/math]. Association rule mining entails specifying a lower support bound [math]\displaystyle{ t }[/math] and finding all item sets [math]\displaystyle{ \mathcal{K}_l }[/math] that can be formed from [math]\displaystyle{ Z_1,\dots,Z_K }[/math] with support in the data greater than [math]\displaystyle{ t }[/math]: [math]\displaystyle{ \{\mathcal{K}_l\,|\,T(\mathcal{K}_l) \gt t\} }[/math].

The Apriori Algorithm[edit]

There are [math]\displaystyle{ 2^K }[/math] possible item sets so [math]\displaystyle{ t }[/math] must be adjusted to make the problem computationally tractable. The apriori algorithm says that for a given support threshold [math]\displaystyle{ t }[/math],

  • The cardinality is relatively small: [math]\displaystyle{ |\{\mathcal{K}_l\,|\,T(\mathcal{K}_l) \gt t\}| }[/math]
  • If [math]\displaystyle{ \mathcal{L} }[/math] is an item set whose items are a subset of [math]\displaystyle{ \mathcal{K} }[/math] it must have support [math]\displaystyle{ \geq\mathcal{K}: \mathcal{L}\subseteq\mathcal{K}\Rightarrow T(\mathcal{L})\geq T(\mathcal{K}) }[/math].
  • The algorithm then:
  1. computes the support of all single-item sets; discards those below threshold
  2. computes support of remaining possibly pairs; retain only those above threshold
  3. continue until all candidate (associative) rules have support below [math]\displaystyle{ t }[/math]
  4. each "high support" item [math]\displaystyle{ \mathcal{K} }[/math] returned by the algo are subject to association rules. The [math]\displaystyle{ Z_k }[/math]'s are partitioned into [math]\displaystyle{ A\cup B=\mathcal{K} }[/math]
  • [math]\displaystyle{ A\Rightarrow B }[/math] expresses the antecedent/consequent relation between the two partitions
  • The "support" of the rule [math]\displaystyle{ T(A\Rightarrow B) }[/math] is the proportion of observations that fall within the union of antecedent and consequent, i.e., the support of the original item set [math]\displaystyle{ \mathcal{K} }[/math]
  • The "confidence" of the rule is given by
[math]\displaystyle{ C(A\Rightarrow B) = \dfrac{T(A\Rightarrow B)}{T(A)} }[/math], where C is the confidence/predictability and is equal to its support T divided by its antecedent, which is analogous to [math]\displaystyle{ \text{Pr}(B|A) }[/math].
  • The "lift" of the rule is given by
[math]\displaystyle{ L(A\Rightarrow B) = \dfrac{C(A\Rightarrow B)}{T(B)} }[/math], which is an estimate of the association measure [math]\displaystyle{ \text{Pr}(A\cap B)/\text{Pr}(A)\text{Pr}(B) }[/math]

Example: item set [math]\displaystyle{ \mathcal{K} }[/math] = {PB, jelly, bread} and the rule {PB, jelly} [math]\displaystyle{ \Rightarrow }[/math]{bread}. Support of 0.03 means all three items appeared in 3% of the market baskets. A confidence of 0.82 for this rule implies that 82% of the times {PB, jelly} were purchased, so was bread. If bread appeared in 43% of all market baskets, the rule would have a lift of 1.95.

Cluster Analysis[edit]

  • Grouping or segmenting a collection of objects into clusters, such that things within a cluster have more in common that with things in another cluster (Hastie, p.501). Also used to check if different clusters actually contain substantially different objects, which requires assesssing some sort of distance metric. Key insight is the degree of similarity.
  • Most algorithms use a (non-negative) dissimilarity matrix. The proximity matrix [math]\displaystyle{ \mathbf{D} }[/math] is a matrix of dissimilarities (covariances) with zeros on the diagonal.
[math]\displaystyle{ D(x_i, x_{i^\prime}) = \displaystyle\sum^p_{j=1} d_j (x_{ij}, x_{i^\prime j}) }[/math]

where the RHS is usually the squared distance.

  • Appropriate distance metrics vary by feature type:
    • Numeric: absolute error, squared error loss, correlation
    • Ordinal: [math]\displaystyle{ \dfrac{i-1/2}{M}, i=1,\dots,M }[/math]
    • Categorical: degree-of-difference must be delineated explicitly

K-Means[edit]

  • Popular iterative descent clustering method. Intended for only numeric data
  • Euclidean distance is the metric: [math]\displaystyle{ \parallel x_i - x_{i^\prime}\parallel^2 }[/math]
  • The algorithm:

1. Minimize total cluster variance:

[math]\displaystyle{ \underset{C,\{m_k\}^K_1}{\min} \sum^K_{k=1}N_k \sum_{C(i)=k} \parallel x_i - m_k\parallel^2 }[/math]

2. Given current means [math]\displaystyle{ \{m_1,\dots,m_k\} }[/math], minimize the above by assigning each observation to the nearest cluster mean:

[math]\displaystyle{ C(i) =\underset{1\leq k\leq K}{\arg\min} \parallel x_i - m_k\parallel^2 }[/math]

Hierarchical Clustering[edit]

  • Requires specifying a dissimilarity measure between (disjoint) groups of observations. Agglomerative strategies are bottom-up and divisive are top-down.


Other Methods[edit]

  • Vector Quantization (VQ): takes a 1MB image of 1024x1024 pixels (grayscale; requires 8 bits per pixel to store). Break image into 2x2 blocks. Each of the four 512x512 blocks into which the image is split is a vector in [math]\displaystyle{ \mathbb{R}^4 }[/math]. K-means is then run for K=200 on the middle (23.9% compressed) image. Each 512x512 block is approximated by its closest centroid, its codeword. Clustering is the encoding step, and the collection of centroids is the codebook. Compression is [math]\displaystyle{ \log_2(K)/(4\cdot 8) = 0.2388 }[/math]

Self-Organizing Maps[edit]

Principal Components, Curves and Surfaces[edit]

Principal Components[edit]

Kernel PCA[edit]

Sparse PCA[edit]

Non-Negative Matrix Factorization[edit]

Independent Component Analysis (ICA)[edit]

Multi-Dimensional Scaling (MDS)[edit]