<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>DataMining | Portfolio</title><link>https://ansangah.github.io/en/tags/datamining/</link><atom:link href="https://ansangah.github.io/en/tags/datamining/index.xml" rel="self" type="application/rss+xml"/><description>DataMining</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en</language><lastBuildDate>Tue, 16 Apr 2024 00:00:00 +0000</lastBuildDate><image><url>https://ansangah.github.io/media/sharing.png</url><title>DataMining</title><link>https://ansangah.github.io/en/tags/datamining/</link></image><item><title>Data Mining</title><link>https://ansangah.github.io/en/blog/subjects/dm/</link><pubDate>Tue, 16 Apr 2024 00:00:00 +0000</pubDate><guid>https://ansangah.github.io/en/blog/subjects/dm/</guid><description>&lt;h2 id="1-overview"&gt;1. Overview&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Data mining extracts &lt;strong&gt;meaningful patterns and knowledge&lt;/strong&gt; from massive datasets.&lt;/li&gt;
&lt;li&gt;Pipeline: data cleaning → feature construction → modelling/pattern discovery → evaluation &amp;amp; visualisation.&lt;/li&gt;
&lt;li&gt;Algorithms must account for the “4 V’s” of big data: volume, variety, velocity, veracity.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="2-frequent-itemset-mining"&gt;2. Frequent Itemset Mining&lt;/h2&gt;
&lt;h3 id="21-concepts"&gt;2.1 Concepts&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Identify sets of items that co-occur in transaction data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Support:&lt;/strong&gt; fraction of transactions containing itemset $X$&lt;br&gt;
$$\mathrm{support}(X) = \frac{#\text{transactions containing }X}{#\text{all transactions}}$$&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Confidence:&lt;/strong&gt; probability that $Y$ appears when $X$ does in rule $X \rightarrow Y$.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lift:&lt;/strong&gt; $ \frac{P(X,Y)}{P(X)P(Y)}$ measures how much more often $X$ and $Y$ appear together than by independence.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="22-apriori-algorithm"&gt;2.2 Apriori Algorithm&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Top-down&lt;/strong&gt; search that grows larger frequent itemsets from smaller ones.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Apriori principle:&lt;/strong&gt; if an itemset is not frequent, none of its supersets can be frequent.&lt;/li&gt;
&lt;li&gt;Steps:
&lt;ol&gt;
&lt;li&gt;Generate candidate 1-itemsets and compute support.&lt;/li&gt;
&lt;li&gt;Keep itemsets above the minimum support threshold.&lt;/li&gt;
&lt;li&gt;Combine survivors to form $(k+1)$-item candidates.&lt;/li&gt;
&lt;li&gt;Repeat until no more frequent sets remain.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Limitation: repeated data scans and huge candidate sets.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="23-fp-growth"&gt;2.3 FP-Growth&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Compress transactions into an &lt;strong&gt;FP-tree&lt;/strong&gt; without candidate generation.&lt;/li&gt;
&lt;li&gt;Process: order items by support → insert transactions into the tree sharing prefixes → build conditional FP-trees recursively.&lt;/li&gt;
&lt;li&gt;Requires less I/O than Apriori and scales well to large datasets.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="24-association-rules"&gt;2.4 Association Rules&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Split each frequent itemset into antecedent/consequent pairs to form rule candidates.&lt;/li&gt;
&lt;li&gt;Filter by support, confidence, lift, etc.&lt;/li&gt;
&lt;li&gt;Applications: recommendation, market-basket analysis, intrusion detection.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="3-similar-item-search-locality-sensitive-hashing-lsh"&gt;3. Similar Item Search: Locality-Sensitive Hashing (LSH)&lt;/h2&gt;
&lt;h3 id="31-problem"&gt;3.1 Problem&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Quickly find &lt;strong&gt;similar objects&lt;/strong&gt; in very large datasets (duplicate documents, image search, record linkage).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="32-core-idea"&gt;3.2 Core Idea&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Design hash families so that &lt;strong&gt;similar items collide with high probability&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Choose hash functions according to similarity metrics:
&lt;ul&gt;
&lt;li&gt;Jaccard → MinHash&lt;/li&gt;
&lt;li&gt;Cosine → Random hyperplane&lt;/li&gt;
&lt;li&gt;$L_p$ distance → $p$-stable hashes&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="33-minhash-with-banding"&gt;3.3 MinHash with Banding&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Represent documents as sets and build MinHash signatures (minimum values of multiple hash functions).&lt;/li&gt;
&lt;li&gt;Split the signature matrix into $b$ bands of $r$ rows; hash each band to buckets.&lt;/li&gt;
&lt;li&gt;If two signatures match in any band, treat them as a candidate pair and compute exact similarity.&lt;/li&gt;
&lt;li&gt;Adjust $(r, b)$ to balance false negatives (more bands) vs. false positives (more rows).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="34-lsh-pipeline"&gt;3.4 LSH Pipeline&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Preprocess data into sets or vectors.&lt;/li&gt;
&lt;li&gt;Generate LSH signatures.&lt;/li&gt;
&lt;li&gt;Extract candidate pairs.&lt;/li&gt;
&lt;li&gt;Compute exact distances and return top-$k$ or threshold matches.&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;h2 id="4-clustering"&gt;4. Clustering&lt;/h2&gt;
&lt;h3 id="41-essentials"&gt;4.1 Essentials&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Discover &lt;strong&gt;natural groupings&lt;/strong&gt; in unlabeled data.&lt;/li&gt;
&lt;li&gt;Objectives: maximise intra-cluster similarity and minimise inter-cluster similarity.&lt;/li&gt;
&lt;li&gt;Distance metrics: Euclidean, cosine, Hamming, DTW, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="42-k-means"&gt;4.2 K-means&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Classic algorithm for roughly spherical clusters.&lt;/li&gt;
&lt;li&gt;Procedure: choose $K$ centres (random or k-means++), assign points to nearest centre, recompute centres, repeat until convergence.&lt;/li&gt;
&lt;li&gt;Watch out for $K$ selection (elbow, silhouette), sensitivity to outliers, and initial seeds.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="43-hierarchical-clustering"&gt;4.3 Hierarchical Clustering&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Builds a &lt;strong&gt;dendrogram&lt;/strong&gt; based on pairwise distances.&lt;/li&gt;
&lt;li&gt;Agglomerative (bottom-up): start with singletons and merge clusters using linkage criteria (single, complete, average, Ward).&lt;/li&gt;
&lt;li&gt;Divisive (top-down): start with all points and split recursively.&lt;/li&gt;
&lt;li&gt;Cut the tree at a chosen level to obtain the desired number of clusters.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="44-density-based-clustering"&gt;4.4 Density-Based Clustering&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;DBSCAN/HDBSCAN treat dense regions as clusters and sparse areas as noise.&lt;/li&gt;
&lt;li&gt;Parameters: radius $\varepsilon$ and minimum points MinPts.&lt;/li&gt;
&lt;li&gt;Captures arbitrarily shaped clusters and automatically flags outliers.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="5-community-detection-in-graphs"&gt;5. Community Detection in Graphs&lt;/h2&gt;
&lt;h3 id="51-definition"&gt;5.1 Definition&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Partition a graph into subgraphs with &lt;strong&gt;dense internal connections&lt;/strong&gt; and sparse external ones.&lt;/li&gt;
&lt;li&gt;Use cases: social networks, recommendation engines, biological networks.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="52-modularity"&gt;5.2 Modularity&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Measures the difference between intra-cluster and inter-cluster edge density.&lt;/li&gt;
&lt;li&gt;Louvain/Leiden algorithms greedily maximise modularity for large graphs.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="53-spectral-clustering"&gt;5.3 Spectral Clustering&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Uses eigenvectors of the graph Laplacian to embed nodes into a low-dimensional space.&lt;/li&gt;
&lt;li&gt;Workflow: build adjacency matrix $W$, degree matrix $D$, compute normalised Laplacian $L = D^{-1/2}(D-W)D^{-1/2}$, take the smallest $k$ eigenvectors, and run k-means.&lt;/li&gt;
&lt;li&gt;Handles nonlinear structures and non-spherical clusters.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="54-comparison"&gt;5.4 Comparison&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Modularity optimisation is fast but subject to resolution limits.&lt;/li&gt;
&lt;li&gt;Spectral methods are more costly (eigen decomposition) yet yield high-quality partitions.&lt;/li&gt;
&lt;li&gt;Choose based on graph size, sparsity, and runtime constraints.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="6-dimensionality-reduction"&gt;6. Dimensionality Reduction&lt;/h2&gt;
&lt;h3 id="61-motivation"&gt;6.1 Motivation&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;High-dimensional data worsens computation, visualisation, and the curse of dimensionality.&lt;/li&gt;
&lt;li&gt;Dimensionality reduction keeps as much information as possible while compressing representation.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="62-principal-component-analysis-pca"&gt;6.2 Principal Component Analysis (PCA)&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Eigen-decompose the covariance matrix to find directions of maximal variance.&lt;/li&gt;
&lt;li&gt;Steps: standardise data → compute covariance → eigenvalues/vectors → project onto top-$k$ components.&lt;/li&gt;
&lt;li&gt;Linear, orthogonal transform that preserves maximum variance; sensitive to nonlinearity/outliers.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="63-linear-discriminant-analysis-lda"&gt;6.3 Linear Discriminant Analysis (LDA)&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Maximises between-class variance while minimising within-class variance.&lt;/li&gt;
&lt;li&gt;Supervised dimensionality reduction; boosts classification performance.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="64-nonlinear-techniques"&gt;6.4 Nonlinear Techniques&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;t-SNE: excellent for local structure visualisation, but distorts global layout.&lt;/li&gt;
&lt;li&gt;UMAP: faster than t-SNE with better global preservation.&lt;/li&gt;
&lt;li&gt;Autoencoders: neural networks that learn nonlinear embeddings.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="65-working-with-lshclustering"&gt;6.5 Working with LSH/Clustering&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Reduce dimensionality first to improve LSH efficiency and denoise features.&lt;/li&gt;
&lt;li&gt;Applying PCA before clustering often yields higher silhouette scores.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="7-project-tips"&gt;7. Project Tips&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Prioritise data quality: handle missing values, detect outliers, and scale appropriately.&lt;/li&gt;
&lt;li&gt;Evaluation metrics:
&lt;ul&gt;
&lt;li&gt;Frequent patterns: support, confidence, lift, conviction, Kulczynski, etc.&lt;/li&gt;
&lt;li&gt;Clustering/community detection: silhouette, Davies–Bouldin, modularity.&lt;/li&gt;
&lt;li&gt;Dimensionality reduction: reconstruction error, downstream model accuracy.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Visualise results with heatmaps, correlation matrices, network graphs, and 2D embeddings (PCA, t-SNE).&lt;/li&gt;
&lt;li&gt;In practice, LSH is just a candidate generator—always follow up with precise distance checks.&lt;/li&gt;
&lt;li&gt;Document your pipeline and tuning experiments to ensure reproducibility.&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>