Skip to content

Mining Web Data

1. Introduction

The Web is unique because of its scale, distributed and uncoordinated creation, open platform, and diversity of applications.

Two primary types of data

  • Web content information: document data and linkage data (graph).
  • Web usage data: web transactions, ratings, user feedback, web logs.

Application classes

ClassExamples
Content-centricCluster/classify web documents; web crawling & resource discovery; web search (linkage + content); web linkage mining
Usage-centricRecommender systems; web-log analysis (anomalies, site design)

2. Web Crawling and Resource Discovery

A web crawler (spider/robot) downloads pages to a central location. Motivations: resources are dispersed across globally distributed sites; sometimes all relevant pages must be fetched centrally.

Crawler typeDescription
UniversalCrawl all pages on the Web (Google, Bing)
PreferentialCrawl pages on a subject or from a site

2.1 Basic crawler algorithm

A real crawler is complex (selection, parsing, distributed multi-threading). Core loop: maintain a frontier of URLs; fetch a URL; parse out new links; add unseen links to the frontier.

2.2 Selection algorithms (frontier ordering)

  • Breadth-first / Depth-first.
  • Frequency-based — most universal crawlers are incremental, refreshing previous crawls.
  • PageRank-based — prioritize pages with high PageRank.

2.3 Preferential crawlers

User-defined criteria decide which pages to fetch: keyword presence, a topical ML classifier, a geographical criterion, or a combination. Modify (a) the selection algorithm and (b) how the frontier is updated so that pointed-to pages also satisfy the criterion.

2.4 Multiple threads & distribution

The network is slow — a single crawler idles while waiting for responses. Use multiple threads updating shared structures (visited-URL set, page repository) with locking. Crawlers may also be geographically distributed, each sub-crawler collecting nearby pages.

2.5 Combatting spider traps

The crawler keeps a visited-URL list to avoid repeats. Dynamic URLs (e.g., .../page1/page2/...) create infinite traps. Defenses: limit maximum URL length; limit number of URLs taken from a single site.

2.6 Near-duplicate detection

Many duplicates of the same page are crawled. A k-shingle (or k-gram) is a string of k consecutively occurring words (e.g., "Mary had", "had a", "a little"). Shingle-based similarity uses the Jaccard coefficient between the shingle sets of two documents D1,D2:

J(D1,D2)=|S1S2||S1S2|

3. Search Engine Indexing and Query Processing

3.1 Two-stage process

  • Offline stage: preprocess crawled documents (tokenize, stem, remove stop words); build an index; compute a quality-based ranking score per page.
  • Online query processing: access relevant documents, then rank by both query relevance and quality.

3.2 Index construction

  • Inverted index: maps each word ID to a list of document IDs containing it (with document ID, frequency, position).
  • Vocabulary index: locates the storage of each inverted word list.

3.3 Content-based score

A word gets different weights depending on whether it is in the title, body, URL token, or anchor text. The number of occurrences matters; font size/color prominence may be leveraged; for multi-keyword queries, relative positions are used.

3.4 Limitations of content-based scoring → web spam

Content alone ignores page reputation/quality. Spam techniques:

  • Content-spamming: fill the page with repeated keywords.
  • Cloaking: serve different content to crawlers vs. users.
  • SEO: owners tune pages using search-engine knowledge.

3.5 Reputation-based score

  • Citation mechanism: high-quality pages are pointed to by many others.
  • User feedback / behavioral analysis: a user clicking a result is evidence of relevance.
  • The final score combines content and reputation; spam penalties are always applied.

4. Ranking Algorithms

4.1 Google's PageRank (random-walk model)

Imagine a random surfer who follows random links. The long-term visit frequency of a page depends on (1) how many pages link to it, and (2) whether those linking pages are themselves frequently visited.

Steady-state formulation. Let G=(V,E) be the directed web graph (with edges added from dead-ends). Let xi be the steady-state probability at node i, Ii its in-linking nodes, and Oi its out-linking endpoints (with out-degree Out(i)). The transition matrix entry is

pij={1Out(i)if edge ij exists0otherwise

Teleportation (restart) handles dead-ends (pages with no out-links): with probability α the surfer jumps to an arbitrary page; with probability 1α follows a link. The power-iteration update is

xi=αjIixjOut(j)+(1α)1n

subject to ixi=1. Repeated until convergence: xi(t+1)=αjIixj(t)Out(j)+(1α)/n.

AspectDetail
Dead-end fixAdd edges to all nodes (incl. self-loop) or rely on teleportation
Typical α0.85 (favors following links)
ComputationPower iteration; sparse matrix × vector

4.2 Topic-Sensitive PageRank

Give more weight to certain topics. Fix a list of topics; gather a high-quality sample per topic; restrict teleportation to that topic's sample set (indicator vector ep).

4.3 SimRank (similarity-based ranking)

A limiting case of topic-sensitive PageRank where teleportation goes only to a single target node iq (vector eq of all zeros except a 1 at iq). Given iq and a subset of nodes, rank nodes by similarity to iq. The symmetric structural similarity is defined iteratively:

s(a,b)=C|I(a)||I(b)|iI(a)jI(b)s(i,j)

where I() are in-linking nodes and C is a constant; apply iteratively until convergence.

  • Authority: a page with many in-links (authoritative content).
  • Hub: a page with many out-links to authorities.
  • Insight: good hubs point to many good authorities; good authorities are pointed to by many good hubs.

Procedure:

  1. Collect top-r relevant results (root set R, r200).
  2. Expand to the base set S = all nodes immediately connected (in or out) to R, restricting in-linking nodes per node to k50.
  3. On subgraph of S, assign each page i a hub score hi and authority score ai.
  4. Iterate (normalize after each step):
aijIihj,hijOiaj

The converged vectors are eigenvectors/singular vectors of the adjacency matrix.

PropertyPageRankHITS
Computed onWhole web (offline)Query-dependent base set (online)
ScoresOne per page (importance)Hub + authority per page
Needs query?NoYes

5. Recommender Systems

5.1 Utility matrix

For n users and d items, an n×d utility matrix D holds preferences. Typically extremely sparse — only a small subset of entries is specified.

  • Positive only: "like", browse, quantity bought.
  • Positive & negative (ratings): explicit like/dislike scores.

5.2 Types of recommendation

  • Content-based: users and items both have feature descriptions; recommend by matching.
  • Collaborative filtering: use the utility matrix "collaboratively" to find relevant users/items.

5.3 Content-based recommendations

  • Without a utility matrix: represent the user by interest documents; use tf-idf + cosine k-NN to find the top-k closest items.
  • With a utility matrix: train a classification model (item descriptions = docs, utility values = labels; remaining items = test docs) or a regression model. Limitation: depends on feature quality.

5.4 Collaborative filtering algorithms

FamilyMethods
Neighborhood-basedUser-based similarity (ratings); Item-based similarity (ratings)
Graph-basedBipartite user-item graph; Topic-Sensitive PageRank; SimRank
ClusteringAdapted k-means; Adapted co-clustering
Latent factorSVD; Matrix Factorization; Matrix Completion

User-based (Pearson correlation): for users X=(x1,,xs),Y=(y1,,ys) over common ratings,

rXY=t(xtx¯)(yty¯)t(xtx¯)2t(yty¯)2

Take top-k peers by rXY; return the normalized weighted-average rating of target items.

Item-based: subtract each row's mean; for columns U,V compute Pearson over co-rated users; take top-k similar items to j that user i rated; return weighted average.

Graph-based: bipartite graph Nu (users) × Ni (items); each nonzero utility entry is an edge. Normalize ratings by user-mean → treat as positive/negative edge weights; use random walks / SimRank; return weighted averages.

Clustering methods: reduce cost & sparsity.

  • User-user: cluster users into ng groups; for user i report the average (normalized) rating of specified items in its cluster.
  • Item-item: cluster items into ng groups; proceed as item-based.

Adapting k-means: compute centroids by averaging each dimension over specified values only; compute distance over specified dimensions, divided by their count (fair comparison). Adapting co-clustering: discover user- and item-neighborhoods simultaneously.

5.5 Latent factor models

Encode row/column correlations as lower-dimensional latent factors (hidden variables) usable even with incomplete data.

SVD (truncated) of the (fully observed) utility matrix:

DQkΣkPk

where Qk (n×k) are user factors and Pk (d×k) are item factors. Rating rijqipj. Caveat: SVD is undefined for incomplete matrices; PLSA may be used for nonnegative matrices.

Matrix Factorization (MF) — a general form DUV minimizing, over observed indices Ω:

J=(i,j)Ω(Dij(UV)ij)2+λ(UF2+VF2)

Regularization (λ) prevents overfitting.

Matrix Completion — assume D is low-rank; recover missing entries by minimizing rank/observed-error under the low-rank assumption.

MethodHandles missing?Output
SVDNo (needs complete)Orthogonal factors
MFYes (over Ω)User/item latent vectors
Matrix CompletionYesFull low-rank matrix

6. Web Usage Mining

6.1 Types of logs

  • Web server logs: user activity in NCSA common log format (or variants).
  • Query logs: searches a user posed.

6.2 Data preprocessing

Log entries from different users are interleaved. Steps:

  • Identify user sessions via client-side cookies, IP address, user-agent.
  • Extract a subset as click streams (page-view sequences) or search-token sequences.

6.3 Applications

  • Recommendations: suggest pages from browsing patterns.
  • Frequent traversal patterns: reorganize the site.
  • Forecasting & anomaly detection: predict future clicks; flag unusual patterns.
  • Classification: label sequences (shopping vs. intrusion).

7. Summary

Web data splits into content (documents + linkage graph) and usage (logs). Crawling covers universal/preferential crawlers, multi-threading, spider-trap avoidance, and shingle-based near-duplicate detection. Search engines build inverted indexes and combine content-based with reputation-based scores. Ranking uses PageRank (random walk + teleportation power iteration) and its variants (topic-sensitive, SimRank) plus query-dependent HITS (hub/authority iteration). Recommender systems use content-based and collaborative filtering — neighborhood, graph, clustering, and latent-factor (SVD / MF / matrix completion) methods. Web usage mining preprocesses logs into sessions and supports recommendation, pattern discovery, forecasting, and anomaly detection.