Database Systems · UGC NET: Data Mining
Classification and Regression
Overview
Classification and regression are supervised data-mining tasks that build a predictive model from labelled historical data.
Classification predicts a discrete class label, while regression predicts a continuous numeric value.
They sit inside predictive modelling, one of the core families of data-mining tasks alongside association, clustering and summarisation.
Before studying them, a student should know basic probability, measures of impurity such as entropy, simple distance measures, and the idea of training and test data.
These topics matter because UGC NET repeatedly asks direct definitions, algorithm characteristics, evaluation metrics, decision-tree measures and small numerical problems.
Key concepts
- Classification predicts a discrete class such as “loan default / no default”, “spam / not spam” or “disease present / absent”. The target is nominal or ordinal.
- Regression predicts a continuous numeric value such as price, sales, temperature or marks. The target is numeric.
- Supervised learning uses a training set with known target values. A test set estimates generalisation to unseen records. A model tuned only to training data overfits; a model too simple underfits.
- Predictive modelling maps input attributes to a target . Classification and regression are predictive; clustering and association discovery are generally descriptive and unsupervised.
- Decision tree induction builds a tree by recursive attribute splitting.
Common algorithms: ID3 uses Information Gain, C4.5 uses Gain Ratio, CART uses Gini Index for classification and squared error for regression trees.
Classification rules can be extracted from root-to-leaf paths of a decision tree. - Naive Bayes is a probabilistic classifier. It is called naive because it assumes that attributes are conditionally independent given the class.
Laplace smoothing adds a small count, usually one, to avoid zero probabilities. - k-Nearest Neighbour, k-NN, is a lazy learner and instance-based learner: it stores training data and does most work at prediction time.
It uses a distance measure, finds the nearest training records, and takes a majority vote for classification or an average for regression. For binary classification, is usually chosen odd to avoid ties. - Support Vector Machine, SVM, finds a separating hyperplane with the maximum margin. Support vectors are the training points closest to the margin boundary; they alone determine the boundary.
The kernel trick computes inner products in a higher-dimensional feature space without explicitly mapping points there. - Logistic regression is a classifier despite its name: it estimates class probability through a sigmoid function and applies a threshold, usually .
- Linear regression fits a straight line by least squares, minimising the sum of squared errors. Multiple linear regression uses several input variables.
- Evaluation: a confusion matrix gives TP, TN, FP and FN. Accuracy alone is misleading for imbalanced classes; use precision, recall (sensitivity), specificity, F1-score and AUC as needed.
- Preprocessing terms: feature selection chooses a subset of existing features, for example by branch and bound search.
Feature extraction creates new features, for example Principal Component Analysis, PCA, an unsupervised linear dimension-reduction method. - Unsupervised contrasts: k-means is centroid-based clustering, not classification. Fuzzy C-means is unsupervised soft clustering. Apriori is association-rule mining, not supervised learning.
- Distance measures commonly used with k-NN and clustering are Euclidean, Manhattan and Chebyshev distance. Lee distance is not part of the standard UGC NET data-mining set.
How it works
The supervised pipeline is fixed in every exam-friendly description:
- Fix the target type. If is a class label, use classification. If is numeric and continuous, use regression. Split labelled data into training and test sets, or use cross-validation.
The training set learns the model; the test set estimates generalisation. - Decision tree induction. Start with all training records at the root. If all records belong to one class, stop.
Otherwise evaluate every candidate attribute by a split measure: ID3 uses information gain, C4.5 uses gain ratio, CART uses Gini index. Choose the best split, create child nodes, and repeat on each child.
Stop when a node is pure, no attributes remain, or a pruning rule applies. Pruning removes weak branches and reduces overfitting. - Naive Bayes classification. Estimate the prior probability of each class and the conditional probability of each attribute value given the class.
For a new record, multiply the prior by all conditional probabilities and choose the class with the largest value. Because multiplying many small probabilities can underflow, logarithms are used in practice.
Laplace smoothing changes a count to a small nonzero value so that one unseen attribute does not force the whole probability to zero. - k-NN prediction. Store the training records. For a query record, compute its distance to every stored record. Select the closest records. For classification, take the majority class.
For regression, take the mean of their target values. k-NN is lazy because no explicit model is learned before prediction. Feature scaling is essential because distance is dominated by large-range variables. - SVM classification. For linearly separable data, choose the hyperplane that leaves the largest margin between classes. The closest points, the support vectors, fix the margin.
For non-separable data, a soft margin allows some errors. For non-linear data, a kernel function such as polynomial or RBF replaces a direct dot product, allowing a linear boundary in a transformed space. - Regression. Linear regression chooses the line that minimises the sum of squared vertical errors. A regression tree splits data so that squared error within child nodes is reduced.
Logistic regression models the probability of a class using the sigmoid function and is evaluated like a classifier. - Evaluation and imbalance. Build a confusion matrix. Report accuracy, precision, recall, specificity and F1. For a rare positive class, a model that predicts every case as negative can have very high accuracy but zero recall.
Use precision, recall, F1 or AUC to expose this failure. - Unsupervised contrast. k-means repeats: assign each point to the nearest centroid, then recompute each centroid as the mean of its assigned points. Manhattan distance can be used in assignment.
For example, if cluster contains , its centroid is ; Manhattan distance from to this centroid is .
Drawing the diagram…
Formulas
-
Convention: logarithms in entropy and information gain are base ; . “Positive” means the class of interest.
-
Entropy: , where is the fraction of records in class .
-
Information Gain: , where .
-
Split Information: .
-
Gain Ratio: .
-
Gini Index: .
-
Binary Gini split: .
-
Naive Bayes: .
-
Laplace smoothing for a categorical attribute: , where is the number of distinct values of the attribute.
-
Euclidean distance: .
-
Manhattan distance: .
-
Chebyshev distance: .
-
Linear SVM decision boundary: ; margin . Support vectors satisfy with suitable scaling.
-
Kernel function: .
-
Confusion matrix terms: TP, TN, FP, FN.
-
Accuracy: .
-
Precision: .
-
Recall or sensitivity: .
-
Specificity: .
-
F1-score: .
-
Simple linear regression: .
-
Least-squares slope: ; intercept .
-
Sum of squared errors: .
-
Mean squared error: ; .
-
Coefficient of determination: , where .
-
Logistic regression: .
-
Back-propagation squared-error score: , where is the network output.
Worked examples
Example 1: Entropy and gain ratio. A dataset has records, “Yes” and “No”, so bit. Attribute splits it into with records: Yes, No; and with records: Yes, No.
.
.
.
bits.
.
.
Answer: gain is about bits and gain ratio is about .
Example 2: Imbalanced classification. A bank screens messages: are legitimate negative cases and are spam positive cases. Model A predicts every message negative.
Its accuracy is , but recall for spam is , so it is useless for detecting spam. Model B gives TP , FN , FP , TN . Accuracy . Precision . Recall . F1 .
Model B has lower accuracy but far better positive-class performance. Answer: accuracy alone is misleading; use precision, recall and F1.
Example 3: k-NN with Manhattan distance. A query point is and . Training points are Yes, No, Yes, No, Yes. Manhattan distances: to ; to ; to ; to ; to .
The three nearest are Yes, No, Yes. Majority is Yes. Answer: predict Yes.
Example 4: Least-squares regression. Four students study hours; marks are . Here , . Compute . Compute . So . Then . The line is . For hours, predicted marks .
Fitted values for are ; residuals are ; SSE . Answer: and SSE .
Example 5: Statement type. Statement I: Laplace smoothing in Naive Bayes prevents a single unseen attribute value from making a class probability zero.
Statement II: k-NN is called eager learning because it builds an explicit model before prediction. Statement I is true. Statement II is false: k-NN is a lazy, instance-based learner. Answer: I true, II false.
Comparison
| Point | Classification | Regression |
|---|---|---|
| Target | Discrete class label | Continuous numeric value |
| Example | Loan default yes/no | Loan amount in rupees |
| Output | Class or probability | Numeric estimate |
| Typical algorithms | Decision tree, Naive Bayes, k-NN, SVM, logistic regression | Linear regression, regression tree, neural regression |
| Metrics | Accuracy, precision, recall, F1, AUC | MAE, MSE, RMSE, |
| Decision-tree method | Split measure | Main note |
|---|---|---|
| ID3 | Information Gain | Biased toward attributes with many distinct values |
| C4.5 | Gain Ratio | Divides gain by split information to correct the bias |
| CART classification | Gini Index | Binary splits, lower Gini is better |
| CART regression | Squared error | Leaf value is usually the mean target |
| Confusing pair | Key difference |
|---|---|
| k-NN vs k-means | k-NN is supervised lazy classification or regression; k-means is unsupervised centroid clustering. |
| Feature selection vs feature extraction | Selection chooses existing features, e.g. branch and bound; extraction creates new features, e.g. PCA. |
| Overfitting vs underfitting | Overfitting: low training error, high test error. Underfitting: high error on both. |
| Naive Bayes vs SVM | Naive Bayes is probabilistic with conditional independence; SVM is margin-based and can use kernels. |
| Logistic regression vs linear regression | Logistic regression predicts class probability; linear regression predicts a numeric value. |
Revision summary
- Classification gives a label; regression gives a number.
- ID3 uses information gain; C4.5 uses gain ratio; CART uses Gini for classification.
- Information gain favours attributes with many values; gain ratio reduces this bias.
- Naive Bayes is “naive” because of conditional independence.
- Laplace smoothing stops zero probabilities.
- k-NN is lazy and instance-based; k-means is unsupervised clustering.
- Support vectors are the closest points that fix the SVM margin.
- Kernel trick gives non-linear SVM boundaries without explicit mapping.
- Accuracy is misleading for imbalanced data; check recall and F1.
- Precision ; recall .
- PCA is feature extraction; branch and bound is feature selection.
- Back-propagation commonly uses a squared-error score function.
Previous-year exam insights
- Direct conceptual questions ask you to identify classification, regression, clustering, association or preprocessing from a definition.
- Match-the-list questions pair tasks with algorithms: classification with k-NN, clustering with k-means, feature extraction with PCA, feature selection with branch and bound.
- Statement I/II questions test overfitting versus underfitting, supervised versus unsupervised methods, PCA as dimension reduction, and Apriori as non-supervised association mining.
- Numerical questions ask for entropy, information gain, gain ratio, confusion-matrix metrics, distance calculations and k-means centroid distance.
- Algorithm-characteristic questions test lazy versus eager learning, Naive Bayes independence, SVM support vectors, kernel trick and decision-tree split measures.
- Traps include calling k-NN a clustering method, calling logistic regression a regression task, treating high accuracy as sufficient for imbalanced data, and confusing feature selection with feature extraction.
- In decision-tree questions, remember that the tree is learned from labelled training data, and classification rules can be extracted from the tree paths.
- Check first whether learning is supervised or unsupervised, then whether the target is discrete or continuous, then apply the matching formula.
Practice at PARIKSHA
You are ready for the PARIKSHA tests of this sub-topic when you can:
- State the difference between classification and regression with one example each.
- Explain why Naive Bayes is “naive” and how Laplace smoothing works.
- Explain why k-NN is lazy and compute a small Manhattan or Euclidean distance table.
- Identify support vectors and explain the kernel trick in SVM.
- Compute entropy, information gain and gain ratio for a small split.
- Build a confusion matrix and calculate accuracy, precision, recall and F1.
- Explain overfitting, underfitting and pruning in decision trees.
- Distinguish k-NN from k-means, and feature selection from feature extraction.
- Compute a least-squares regression line and SSE from a small dataset.
- Match classification, clustering, PCA and branch-and-bound with their correct tasks.
Attempt the PARIKSHA sub-topic test first, then the subject test.