Machine Learning Most Important Question For Mid Term Ipu University
Machine Learning Most Important Question For Mid Term Ipu University
Answer:
Answer:
Answer:
1. Supervised Learning:
a. The algorithm learns from labeled data, meaning both
input and corresponding output are provided.
b. Examples:
i. Predicting house prices (Regression)
ii. Email spam detection (Classification)
2. Unsupervised Learning:
a. The algorithm learns from unlabeled data, aiming to
identify patterns or groupings.
b. Examples:
i. Customer segmentation
ii. Market basket analysis
3. Reinforcement Learning:
a. The algorithm learns by interacting with an environment
and receiving feedback in the form of rewards or
penalties.
b. Examples:
i. Self-driving cars
ii. Game-playing agents (e.g., AlphaGo)
Answer:
1. Healthcare:
a. Predicting diseases using patient data (e.g., early
detection of cancer).
b. Personalized treatment plans and drug discovery.
2. Finance:
a. Fraud detection in banking transactions.
b. Stock market predictions and automated trading.
3. E-commerce and Retail:
a. Recommendation systems (e.g., Amazon, Netflix).
b. Inventory management and demand forecasting.
4. Transportation:
a. Predictive maintenance of vehicles.
b. Optimization of delivery routes (e.g., Uber, FedEx).
Answer:
• Regression:
o Regression is used to predict a continuous numerical
value based on input variables.
o Example: Predicting the price of a house based on its
size, location, and other features.
o Algorithm Example: Linear Regression, Polynomial
Regression.
• Classification:
o Classification is used to assign data points to predefined
categories or classes.
o Example: Identifying whether an email is spam or not.
o Algorithm Example: Logistic Regression, Decision Trees,
Support Vector Machines (SVM).
Answer:
1. Binary Classification:
a. The model predicts one of two possible outcomes.
b. Example: Predicting whether a patient has a disease
(Yes/No).
2. Multiclass Classification:
a. The model predicts one of more than two classes.
b. Example: Classifying an image as a cat, dog, or bird.
3. Multilabel Classification:
a. Each instance can belong to multiple classes
simultaneously.
b. Example: A news article categorized as both politics and
sports.
7. Performance Measures: Confusion Matrix, Accuracy,
Precision & Recall, ROC Curve
Answer:
1. Confusion Matrix:
a. A table that summarizes the performance of a
classification model.
i. True Positives (TP): Correctly predicted positives
ii. True Negatives (TN): Correctly predicted negatives
iii. False Positives (FP): Incorrectly predicted as
positive
iv. False Negatives (FN): Incorrectly predicted as
negative
2. Accuracy:
a. Accuracy=TP+TNTP+TN+FP+FNAccuracy = \frac{TP +
TN}{TP + TN + FP + FN}Accuracy=TP+TN+FP+FNTP+TN
b. It measures how often the model makes correct
predictions.
3. Precision:
a. Precision=TPTP+FPPrecision = \frac{TP}{TP +
FP}Precision=TP+FPTP
b. Precision measures the proportion of true positive
predictions out of all positive predictions.
4. Recall (Sensitivity):
a. Recall=TPTP+FNRecall = \frac{TP}{TP +
FN}Recall=TP+FNTP
b. Recall measures how well the model identifies positive
cases.
5. ROC Curve:
a. A graphical representation of the trade-off between True
Positive Rate (TPR) and False Positive Rate (FPR).
b. The area under the curve (AUC) indicates the model's
ability to distinguish between classes.
Answer:
• NumPy:
o A library for numerical computing, providing support for
multi-dimensional arrays and mathematical operations.
o Example Usage: Matrix operations, linear algebra, and
random number generation.
• Pandas:
o A library for data manipulation and analysis, offering data
structures like DataFrames and Series.
o Example Usage: Data cleaning, filtering, and merging
datasets.
9. Scikit-Learn: A Python Machine Learning Library
Answer:
Answer:
Answer:
Unit-2
1. Decision Trees
Answer:
Working:
Advantages:
Disadvantages:
2. Tree Pruning
Answer:
Types of Pruning:
Importance:
3. Rule-based Classification
Answer:
Working:
1. Generating Rules:
a. Rules are often extracted from decision trees or trained
directly using rule-generation algorithms like RIPPER.
2. Rule Matching:
a. For each input, the model checks which rule applies
based on the feature values.
3. Conflict Resolution:
a. If multiple rules apply, a conflict resolution strategy like
rule priority or majority voting is used.
Example:
• If (age > 30) AND (income > 50K) Then Class = Premium
Customer.
Advantages:
Disadvantages:
Answer:
Example:
In spam detection:
Advantages:
Disadvantages:
Answer:
Example:
• In a healthcare scenario:
o Nodes: Smoking, Lung Cancer, Shortness of Breath.
o If a person is a smoker, it increases the probability of lung
cancer, which in turn increases the likelihood of
shortness of breath.
Answer:
Working:
1. Margin Maximization:
a. SVM finds the hyperplane with the largest margin
(distance) from the nearest points of any class, called
support vectors.
2. Kernel Trick:
a. For non-linearly separable data, SVM applies the kernel
trick to map data into a higher-dimensional space where
it becomes linearly separable.
Advantages:
Disadvantages:
Working:
1. Choosing k:
a. Select the number of neighbors (k) to consider.
2. Calculating Distance:
a. Use distance metrics like Euclidean distance to find the
nearest neighbors.
3. Voting:
a. For classification, the class with the majority vote among
neighbors is assigned.
Example:
If k = 3, and the three nearest neighbors are two dogs and one cat,
the new instance is classified as a dog.
Answer:
Ensemble Learning is a technique that combines multiple models
(often called weak learners) to produce a stronger, more robust
model.
1. Bagging:
a. Multiple models are trained on different subsets of the
data. Example: Random Forest.
2. Boosting:
a. Models are trained sequentially, with each model
focusing on the mistakes of the previous ones. Example:
AdaBoost.
Disadvantages:
PYQ
Applications:
1. Accuracy:
Accuracy=TP+TNTP+TN+FP+FN=4+410=0.8 (80%)Accuracy =
\frac{TP + TN}{TP + TN + FP + FN} = \frac{4 + 4}{10} = 0.8 \,
(80\%)Accuracy=TP+TN+FP+FNTP+TN =104+4 =0.8(80%)
2. Precision (for Man):
Precision=TPTP+FP=44+1=0.8 (80%)Precision = \frac{TP}{TP +
FP} = \frac{4}{4 + 1} = 0.8 \, (80\%)Precision=TP+FPTP =4+14
=0.8(80%)
3. Recall (Sensitivity):
Recall=TPTP+FN=44+1=0.8 (80%)Recall = \frac{TP}{TP + FN} =
\frac{4}{4 + 1} = 0.8 \, (80\%)Recall=TP+FNTP =4+14 =0.8(80%)
4. Specificity (for Woman):
Specificity=TNTN+FP=44+1=0.8 (80%)Specificity = \frac{TN}{TN
+ FP} = \frac{4}{4 + 1} = 0.8 \, (80\%)Specificity=TN+FPTN =4+14
=0.8(80%)
Multiclass Classification:
Multilabel Classification:
Dataset:
Weather Play?
Sunny No
Sunny Yes
Overcast Yes
Rainy No
1. Bagging:
a. Uses multiple models trained on different subsets of
data.
b. Example: Random Forest.
2. Boosting:
a. Sequentially trains models to correct the errors of
previous ones.
b. Example: AdaBoost.
Applications of Classification:
Key Features:
Applications:
Diagram of SVM:
Where:
Subject to:
where yi∈{−1,+1}y_i \in \{-1, +1\}yi ∈{−1,+1} is the class label for
data point xix_ixi .
1. Store the training data: In K-NN, the model only stores the
training examples and doesn’t explicitly learn a model during
training.
2. Choose the number of neighbors (K): K is a hyperparameter
that determines how many nearest data points will vote for the
label of the test point.
3. Compute distances: For each test point, the distances to all
training points are calculated using a distance metric (e.g.,
Euclidean distance).
4. Identify K-nearest neighbors: The algorithm selects the K
data points from the training set that are closest to the test
point.
5. Assign a label: In classification, the label with the most votes
among the K-neighbors is assigned to the test point. For
regression, the algorithm predicts the average value of the K-
neighbors.
• Advantages:
o Simple and easy to implement.
o Works well for smaller datasets with low dimensionality.
• Disadvantages:
o Requires high computation during prediction as it
computes distances for all training points.
o Performance decreases with high-dimensional data due
to the curse of dimensionality.
9. What is Linear Regression in Machine Learning? What Are Its Types?
Write the Cost Function and Explain the Importance of Gradient Descent
The Mean Squared Error (MSE) is the most commonly used cost
function in linear regression. It measures the average squared
difference between the predicted and actual values.
J(β0,β1)=12m∑i=1m(h(Xi)−Yi)2J(\beta_0, \beta_1) =
\frac{1}{2m} \sum_{i=1}^{m} \left( h(X_i) - Y_i
\right)^2J(β0 ,β1 )=2m1 i=1∑m (h(Xi )−Yi )2
Where:
Where: