Course: Data Science and Database Technologies
Professor: Elena Baralis, Politecnico di Torino, Data Base and Data Mining Group.
Source: Classification fundamentals, local path DSTBD_10-DMClassification.pdf, 160 PDF pages. The source deck’s printed slide numbering reaches 171. Lecture number 10 is inferred from the local course sequence and filename; the PDF does not print a lecture number.

Lecture summary

Classification is supervised learning. A model learns from records whose class labels are known and assigns a class to a new record. The central workflow is training, model construction, prediction and evaluation on data that was not used to fit the model.

The lecture begins with decision trees. A tree asks attribute tests, recursively creates purer groups and assigns a class at each leaf. Hunt’s algorithm captures the general induction process. Gini impurity, entropy and information gain measure how useful a split is. Pre-pruning and post-pruning control overfitting.

The later sections compare random forests, rule-based and associative classifiers, k-nearest neighbours, Bayesian classifiers, support vector machines and neural networks. They differ in representation, interpretability, computational cost, robustness and the kind of structure they assume in the data.

The final section evaluates models using holdout and cross-validation, confusion matrices, accuracy, precision, recall, F-measure and ROC curves. Accuracy alone can be misleading for imbalanced classes.

Learning route

  1. Start with Classification and Decision Trees to learn the supervised-learning setup, tree traces, impurity and pruning.
  2. Compare Classification Methods and Model Tradeoffs to understand forests, rules, k-NN, Bayes, SVMs and neural networks.
  3. Use Classification Evaluation and Confusion Matrices for evaluation splits, formulas and an imbalanced-disease example.
  4. Finish with Neural Networks for Classification for forward propagation, backpropagation, CNNs, RNNs and embeddings.
  5. Revisit Data Science and the KDD Process and Data Types and Attribute Scales to connect classification to the wider mining workflow and to correct data representation.

Source examples and worked ideas

Tax-record decision tree

The source uses Refund, Marital Status and Taxable Income to predict Cheat. A record with Refund=No and Marital Status=Married follows the tree to Cheat=No. A record with Refund=No, a non-married status and income above 80K follows the income branch to Cheat=Yes. The same training table can support more than one tree, which is why the split criterion and stopping strategy matter.

Impurity

For a node containing two classes, Gini is 1 - sum(p(class)^2). A node containing only one class has Gini 0. A node containing equal numbers of two classes has Gini 0.5. A split is evaluated by the weighted impurity of its child nodes, and CART-style methods prefer the lowest value.

Naive Bayes

The source’s weather example classifies <rain, hot, high, false> by multiplying the prior class probability by the conditional probabilities of the attributes. The class with the larger resulting score is selected. The method assumes conditional independence of attributes, which is convenient but not always true.

Evaluation

The source distinguishes training, validation and test roles. Holdout uses a fixed partition. k-fold cross-validation repeatedly trains on k-1 folds and evaluates on the remaining fold. A confusion matrix records true positives, false positives, false negatives and true negatives. Precision asks how reliable positive predictions are; recall asks how many actual positives were found.

Common confusions

  • Classification predicts a category; regression predicts a numeric value; clustering finds groups without predefined labels.
  • Gini and entropy both measure impurity. Gini is minimized, while information gain is maximized.
  • A high training score does not prove generalization. The test set must remain unseen during model construction.
  • Random forests improve stability by combining trees, but their individual predictions are harder to explain.
  • k-NN has almost no model-building phase, but prediction can be slow and depends strongly on scaling and the distance metric.
  • Precision and recall answer different questions. A medical screening system may prioritize recall because false negatives are costly.

Revision prompts

  • Trace a new tax record through the source decision tree and explain why each branch is taken.
  • Calculate Gini for a node containing 3 records of class A and 1 of class B.
  • Explain why a tree that perfectly memorizes training records can perform worse on new records.
  • Compare k-NN, Naive Bayes and a decision tree for a small, interpretable dataset.
  • A disease affects 1% of patients. Explain why a 99% accurate always-healthy classifier is not useful.
  • Explain what the SVM margin represents and why it matters.
  • Describe how a CNN’s shallow and deep filters differ.

Source map

PDF pagesMaterial
2-9Classification objectives, applications, training/test sets and evaluation criteria
10-59Decision trees, induction, split tests, Gini, entropy, pruning and decision boundaries
61-67Random forests, bootstrap aggregation and feature bagging
69-83Rule-based and associative classification
86-94Instance-based and k-nearest-neighbour classifiers
96-102Bayes theorem, Naive Bayes and evaluation
104-112Linear and nonlinear support vector machines
114-151Neural networks, CNNs, RNNs, LSTMs, autoencoders and word embeddings
153-171Evaluation partitions, confusion matrices, precision, recall, F-measure and ROC curves

Source and scope

Elena Baralis, Classification fundamentals, Politecnico di Torino, Data Base and Data Mining Group, local path DSTBD_10-DMClassification.pdf. The lecture and concept notes paraphrase the source. Real-life examples and explanatory analogies are added study explanations; the original PDF and figures remain local.