FML - |||
FML - |||
1. Binary Classification:
2. Multi-Class Classification:
3. Multi-Label Classification:
o An instance can belong to more than one class at the same time.
4. Imbalanced Classification:
o Example: Detecting fraud (fraud cases are fewer than normal ones).
1. Data Collection:
Gather the dataset which contains input features and class labels.
2. Data Preprocessing:
Clean the data by handling missing values, converting categories to numbers (encoding), and
scaling values if needed.
3. Splitting Data:
Divide the data into training and testing sets (e.g., 80% train, 20% test).
4. Model Selection:
Choose an algorithm like Decision Tree, SVM, k-NN, etc.
2. Explain the working principle of the k-Nearest Neighbour algorithm with an example.
When given a new data point, it compares it to all the data in the training set.
It selects the ‘k’ closest points (neighbors) and assigns the class that is most frequent among
those neighbors.
Steps:
2. Calculate the distance (usually Euclidean) from the new point to all existing points.
Example: Predicting if a person likes tea or coffee based on age and income:
A Decision Tree is a tree-shaped structure used to make decisions. It splits the data into branches
based on questions or conditions.
Working:
1. It chooses the best feature that divides the data well (based on Gini Index or Information
Gain).
4. This continues until the tree reaches leaves with class labels.
Is it sunny?
No → Play
o No → Play
Advantages:
1. Simple to Understand:
o The structure looks like a flowchart with decisions (questions) and outcomes
(answers), so it is easy to explain.
o Handles both categorical (like gender) and numerical (like age) data.
Disadvantages:
1. Overfitting:
o If the tree is too deep, it might memorize the training data and perform badly on
new data.
2. Unstable:
Definition: SVM is a powerful supervised learning algorithm used mainly for binary classification. It
tries to find the best separating line or hyperplane between two classes.
Key Components:
1. Hyperplane:
o A line (2D) or plane (3D+) that divides the data.
o The best hyperplane separates the classes with the largest margin.
2. Support Vectors:
3. Margin:
Sometimes data points are not linearly separable in the current dimension. In such cases, we use
kernel tricks.
Example:
Kernel functions like RBF (Gaussian) or polynomial kernel can map the data into a higher
dimension where a straight line (hyperplane) can separate them.
Types of Kernels:
1. Linear Kernel:
2. Polynomial Kernel:
o Used when we don’t know the best shape of the decision boundary.
4. Sigmoid Kernel:
Benefits:
Memory Usage Low (only support vectors) High (stores all data)
1. Problem Definition:
2. Data Collection:
3. Data Preprocessing:
o Clean data, handle missing values, encode categories, and scale features if needed.
4. Split Data:
o Divide the data into training and test sets (e.g., 70/30 split).
5. Model Selection:
o Choose a suitable algorithm like Decision Tree, SVM, or k-NN based on data and
accuracy needs.
6. Training:
o Use the training data to help the algorithm learn the pattern.
7. Evaluation:
o Use the test data and metrics like accuracy, precision, recall, and F1-score.
8. Improvement (Tuning):
9. Deployment:
o Use the trained model in a real-world system (like a medical app or email filter).
Input Features: Age, job type, income, credit score, number of dependents.
7. How does feature selection affect the performance of classification algorithms? (Expanded)
Explanation:
Features are the input values used to make predictions (like age, income, marks, etc.).
If the right features are chosen, the model will learn better patterns and make more accurate
predictions.
1. Better Accuracy:
o Example: Using a person’s “eye color” to predict salary may confuse the model.
2. Faster Computation:
o Using only important features helps the model generalize better to new data.