Week 4 Supervised Learning Classification
Week 4 Supervised Learning Classification
Learning -
Classification
What is Classification?
1 Predicting Categories 2 Categorical Output
Classification is a type of The output of a classification
supervised learning where the model is a discrete category,
goal is to predict the category such as "spam" or "not spam,"
or class of a given data point. "cat" or "dog," or "positive" or
"negative."
3 Training Data
Classification models are trained on labeled data where each data point
has a known category.
Logistic Regression
Sigmoid Function Binary Classification
Logistic regression uses a The simplest form of logistic
sigmoid function to map the regression involves two classes,
input features to a probability often referred to as "positive"
between 0 and 1, representing and "negative."
the likelihood of belonging to a
specific class.
Logistic regression works by fitting a sigmoid function to the data. The sigmoid function takes the input features and outputs a probability
between 0 and 1. This probability represents the likelihood that the data point belongs to the positive class. For example, if the sigmoid
function outputs a probability of 0.8, this means that the model predicts an 80% chance that the customer will click on the ad.
Decision Trees
Tree Structure 1
Decision trees represent a hierarchical structure where
each node represents a feature and each branch
represents a decision rule based on the feature's value. 2 Recursive Partitioning
The tree is built recursively by partitioning the data
based on features that best separate the classes.
Prediction 3
Predictions are made by traversing the tree from the
root to a leaf node, where the leaf node represents the
predicted class.
Decision Tree Example
Here is an example of a decision tree used for a dataset about playing tennis.
The tree begins with the root node, which asks whether the weather is sunny. If
the weather is sunny, the tree branches to the next node, which asks if humidity
is high. If humidity is high, the tree predicts that the player should not play
tennis.
Decision Tree:
Root Node
The tree starts with the root node, which is the feature that best splits the data into different classes.
Internal Nodes
Each internal node represents a decision based on a feature, and branches lead to different child nodes.
Leaf Nodes
Leaf nodes represent the final prediction for a specific class.
Advantages of Decision Trees
Interpretability Handling Categorical Data Non-Linear Relationships
Decision trees are easy to understand and Decision trees can handle both numerical Decision trees can capture non-linear
interpret, as the rules are transparent and and categorical features without requiring relationships between features and the
readily visualized. feature scaling or transformation. target variable.
Disadvantages of Decision Trees
Overfitting Sensitivity to Small Changes
Decision trees can easily overfit the training data, resulting in poor Slight changes in the training data can significantly alter the
generalization performance on unseen data. structure of the tree, leading to instability in predictions.
Evaluation Metrics - Confusion
Matrix
Definition A table that summarizes the
performance of a classification model
by showing the number of true
positives, true negatives, false
positives, and false negatives.