1. What is Machine Learning (ML)?
Machine Learning (ML) is a branch of Artificial Intelligence (AI) that enables
computers to learn from data and make decisions or predictions without being
explicitly programmed.
In simple terms, ML uses data and algorithms to train a model. Once trained,
the model can make predictions or identify patterns in new data.
Real-Life Example of ML:
Email Spam Detection
Data: Thousands of emails labeled as "spam" or "not spam".
ML Task: Train a model to learn what features (like certain keywords or
senders) are common in spam emails.
Result: The model can automatically filter incoming emails into spam or
inbox.
2. What is Labeled Data in Supervised Learning?
1. Definition:
Labeled data consists of input-output pairs where each input has a known
correct output (label).
➤ Example: For an image of a cat, the label is “cat”.
2. Used in Supervised Learning:
Labeled data is essential in supervised learning, where the model learns
the mapping from input to output.
➤ Helps the model learn through error correction.
3. Helps in Model Evaluation:
Since the correct outputs are known, performance metrics like accuracy,
precision, etc., can be calculated.
4. Data Format:
Typically structured as a table where each row represents a data point with
features and a corresponding label.
➤ E.g., Age, Salary → Buys/Not Buys.
5. Used in Various Applications:
Classification (spam detection, medical diagnosis) and regression
(predicting prices, sales forecasting).
6. Manual or Automated Labeling:
Labeled data is often created manually, which can be time-consuming and
expensive.
3. Overfitting and Underfitting in Supervised Learning
1. Overfitting:
The model performs well on training data but poorly on new data because
it memorizes rather than generalizes.
➤ Caused by high model complexity.
2. Underfitting:
The model is too simple to capture the underlying pattern in data and
performs poorly on both training and testing data.
3. Symptoms:
Overfitting: Low training error, high testing error.
Underfitting: High training and testing error.
4. Solutions for Overfitting:
➤ Use of regularization, pruning (in decision trees), or collecting more
data.
5. Solutions for Underfitting:
➤ Use more complex models, add more relevant features, or reduce data
noise.
6. Importance:
Balancing between overfitting and underfitting is crucial for building
effective ML models.
4. Role of Training and Testing Dataset
1. Training Dataset:
Used to train the model, i.e., help the algorithm learn the patterns and
relationships in data.
2. Testing Dataset:
Used to evaluate how well the trained model performs on unseen data,
which reflects real-world scenarios.
3. Helps Prevent Overfitting:
Testing on separate data ensures the model generalizes well and doesn’t
just memorize training data.
4. Split Ratio:
Usually, the dataset is split in an 80:20 or 70:30 ratio for training and
testing.
5. Validation Set (Optional):
Sometimes a third set called the validation set is used for tuning model
parameters.
6. Significance:
Proper splitting ensures reliable performance metrics and robust models.
5. Supervised vs Unsupervised Learning
Aspect Supervised Learning Unsupervised Learning
Labeling Uses labeled data Uses unlabeled data
Predict outcomes based on
Objective Find hidden patterns or structure
input
Clustering, dimensionality
Examples Classification, regression
reduction
Output Predictive model Descriptive insight
Linear Regression, Decision
Algorithms K-Means, PCA
Trees
Use Case Email spam detection Customer segmentation
6. Classification vs Regression
Aspect Classification Regression
Discrete labels (e.g., spam or Continuous values (e.g.,
Output Type
not) price)
Goal Assign input to a category Predict a numerical value
Example Predicting disease type Predicting house price
Algorithms Logistic Regression, SVM Linear Regression, SVR
Evaluation
Accuracy, F1-Score RMSE, MAE
Metrics
Type of Learning Supervised Supervised
7. Linear Regression in Machine Learning
1. Definition:
Linear Regression is a supervised learning algorithm that models the
relationship between a dependent variable and one or more independent
variables.
2. Equation:
For simple linear regression:
y = mx + c
➤ Where m is the slope, c is the intercept.
3. Assumptions:
➤ Linear relationship
➤ Independence of errors
➤ Homoscedasticity (constant variance)
4. Applications:
Predicting house prices
Estimating sales
Forecasting stock prices
5. Evaluation:
➤ Mean Squared Error (MSE), R² Score are used to measure performance.
6. Limitations:
Works only for linear relationships; performance drops if the data has non-
linear patterns.
8. Features in Unsupervised Learning
1. No Labeled Data:
Unsupervised learning uses input data that has no output labels. The
algorithm learns hidden patterns without guidance.
2. Clustering and Association:
Algorithms group data into clusters (e.g., K-means) or find relationships
(e.g., Apriori) without predefined classes.
3. Dimensionality Reduction:
Techniques like PCA reduce feature space while preserving information,
improving visualization and performance.
4. Pattern Recognition:
Identifies trends or group behaviors (like customer segmentation) even if
they're not explicitly defined.
5. Self-Learning:
The model adapts based on the structure of data, helping in discovering
previously unknown structures.
9. Advantages and Disadvantages of Unsupervised Learning
Advantages:
1. No Need for Labeling:
Saves time and cost since data doesn't require manual labeling.
2. Pattern Discovery:
Useful for finding hidden structures or relationships in data.
3. Versatile Applications:
Ideal for customer segmentation, market basket analysis, and anomaly
detection.
4. Good for Exploratory Analysis:
Helps understand data distributions and feature relationships.
Disadvantages:
1. Uncertainty in Evaluation:
No ground truth makes performance evaluation difficult.
2. Less Control Over Output:
Harder to direct the outcome as there's no predefined goal.
3. May Find Meaningless Patterns:
Risk of discovering patterns that don’t have practical relevance.
4. Requires Domain Expertise:
Experts are often needed to interpret the results meaningfully.
10. Reinforcement Learning
1. Learning through Interaction:
An agent learns by interacting with the environment, receiving rewards or
penalties.
2. Trial and Error:
Agent tries various actions and learns from feedback over time to maximize
cumulative reward.
3. Core Elements:
Includes agent, environment, actions, states, rewards, and policies.
4. Markov Decision Process (MDP):
Used to model the environment with a sequence of states and actions.
5. Applications:
Used in robotics, game playing (e.g., AlphaGo), and autonomous vehicles.
11. Reinforcement Learning vs Unsupervised Learning
Aspect Reinforcement Learning Unsupervised Learning
Learns from feedback
Data Type Works with unlabeled data
(reward/punishment)
Aspect Reinforcement Learning Unsupervised Learning
Goal Maximize cumulative reward Discover hidden structure
Clustering customers,
Example Game playing, robot navigation
PCA
Requires agent-environment Passive learning from
Interaction
interaction dataset
Learning
Dynamic and sequential Static pattern discovery
Style
12. What is CRISP-DM?
1. Stands for:
Cross-Industry Standard Process for Data Mining – a widely used
methodology.
2. Six Phases:
Business Understanding
Data Understanding
Data Preparation
Modeling
Evaluation
Deployment
3. Iterative Process:
Steps can be revisited based on results or new findings.
4. Tool-Independent:
Can be used with any data mining tool or algorithm.
5. Standard Framework:
Ensures organized, systematic data analysis, suitable across domains.
13. Utility of CRISP-DM
1. Improves Project Planning:
Provides clear guidelines for each stage in data mining projects.
2. Standardization:
Helps in maintaining consistency and quality in data science workflows.
3. Cross-Domain Applicability:
Used in industries like banking, healthcare, marketing, etc.
4. Supports Reproducibility:
Since steps are well documented, it’s easier to reproduce or continue a
project.
5. Focuses on Business Goals:
Keeps business objectives at the center of analysis.
14. What is EDA (Exploratory Data Analysis)?
1. Data Exploration:
Involves examining datasets to summarize their main characteristics.
2. Visualization Techniques:
Includes histograms, scatter plots, box plots to understand distribution,
outliers, and patterns.
3. Statistical Measures:
Mean, median, standard deviation help understand central tendency and
spread.
4. Missing Value Detection:
Helps find null values or anomalies before modeling.
5. Data Cleaning Aid:
EDA is often the first step before cleaning and transforming data.
15. Role of EDA in ML
1. Understand Data Quality:
Helps identify missing values, noise, and outliers.
2. Feature Selection:
Highlights which features are important or redundant.
3. Model Input Preparation:
Aids in transforming variables (e.g., normalization, encoding) effectively.
4. Hypothesis Generation:
Generates new insights or hypotheses about the data.
5. Improves Model Performance:
A well-explored dataset leads to better-informed modeling decisions.
16. Data Cleaning vs Data Transformation
1. Definition:
Data cleaning involves identifying and correcting (or removing)
errors and inconsistencies in data.
Data transformation involves converting data into a suitable format
or structure for analysis.
2. Objective:
Cleaning ensures accuracy, consistency, and completeness.
Transformation prepares raw data for use by converting,
aggregating, or encoding it.
3. Examples:
Cleaning: Removing duplicates, handling missing values.
Transformation: Normalizing data, encoding categorical variables.
4. Order of Execution:
Cleaning is generally performed before transformation.
Transformation follows cleaning to format data properly.
5. Importance:
Both are essential for improving data quality and ensuring the
performance of machine learning models.
17. Significance of Feature Scaling in Data Preprocessing
1. Ensures Uniformity:
Brings all features to the same scale, preventing dominance of
features with larger values.
2. Improves Model Accuracy:
Algorithms like KNN, SVM, and gradient descent-based methods rely
on distance; scaling improves accuracy.
3. Faster Convergence:
Scaled features help gradient descent converge faster during
training.
4. Common Methods:
Min-Max Scaling, Standardization (Z-score), and Robust Scaling are
widely used.
5. Prevents Bias:
Without scaling, models may give undue importance to certain
features, leading to biased predictions.
18. Purpose of Data Partitioning for Model Building
1. Training and Testing Separation:
Divides data into training and testing sets to evaluate model
performance fairly.
2. Prevents Overfitting:
Ensures the model learns general patterns, not memorization.
3. Validation Set Usage:
A third partition (validation set) can be used for hyperparameter
tuning.
4. Cross-validation:
Improves reliability by using multiple train-test splits.
5. Realistic Evaluation:
Helps simulate how the model will perform on unseen data.
19. Importance of Model Selection in ML
1. Accuracy Optimization:
Selecting the right model directly affects predictive performance.
2. Problem Suitability:
Different tasks (classification, regression) require appropriate
models.
3. Computational Efficiency:
Some models are faster and more resource-efficient.
4. Interpretability:
Simpler models (like linear regression) are easier to interpret than
complex ones (like neural networks).
5. Bias-Variance Tradeoff:
Choosing a model with the right complexity balances underfitting and
overfitting.
20. Purpose of Evaluate Performance Matrices
1. Model Effectiveness:
Metrics like accuracy, precision, recall indicate how well the model
performs.
2. Error Analysis:
Helps identify where the model is making mistakes.
3. Comparison:
Enables comparison of multiple models on the same dataset.
4. Selection & Tuning:
Guides hyperparameter tuning and model selection.
5. Business Value:
Ensures model performance aligns with business objectives (e.g.,
reducing false positives).
21. Logistic Regression with Example
1. Definition:
Logistic regression is used for binary classification problems.
2. Sigmoid Function:
Uses sigmoid to map predictions to probabilities between 0 and 1.
3. Application Example:
Predicting if a customer will buy a product (yes/no) based on age and
income.
4. Decision Boundary:
Sets a threshold (e.g., 0.5) to classify between two classes.
5. Evaluation Metrics:
Accuracy, precision, recall, and ROC-AUC are used to assess
performance.
22. Feature Selection and Extraction
1. Definition:
Feature selection picks relevant features; extraction creates new
features from existing ones.
2. Purpose:
Reduces dimensionality, improves performance, and speeds up
training.
3. Methods:
Selection: Filter, wrapper, embedded.
Extraction: PCA, LDA, t-SNE.
4. Improves Interpretability:
Less complex models are easier to understand and maintain.
5. Prevents Overfitting:
Reduces noise and irrelevant data that could mislead models.
23. Confusion Matrices
1. Definition:
A table showing true positives, true negatives, false positives, and
false negatives.
2. Helps Evaluate Classifiers:
Useful for binary and multiclass classification.
3. Derived Metrics:
From the matrix, we calculate accuracy, precision, recall, and F1-
score.
4. Visual Representation:
Easy to visualize how well a classifier distinguishes between classes.
5. Error Analysis:
Identifies which classes are often confused with others.
24. Impact of Maximum Depth and Minimum Sample Split on Decision
Tree Performance
1. Maximum Depth:
Controls how deep the tree can grow.
Too deep: Overfitting; Too shallow: Underfitting.
2. Minimum Sample Split:
Minimum number of samples required to split a node.
Larger value prevents splitting on noisy patterns.
3. Controls Model Complexity:
Helps in maintaining the balance between bias and variance.
4. Improves Generalization:
Proper tuning leads to better performance on unseen data.
5. Used in Pruning:
Often used as a pruning criterion to simplify the tree and avoid
overfitting.
25. K-Means Clustering
Definition:
K-means clustering is an unsupervised learning algorithm that groups data into K
distinct clusters based on feature similarity.
Points with Explanation:
1. Cluster Initialization:
Randomly selects K initial centroids from the dataset.
2. Assignment Step:
Each data point is assigned to the nearest centroid using a distance metric
(commonly Euclidean distance).
3. Update Step:
New centroids are calculated by taking the mean of all points assigned to
each cluster.
4. Convergence:
The process repeats (assign and update) until centroids no longer change
or change is minimal.
5. Applications:
Used in customer segmentation, document classification, and image
compression.
26. Applications of Decision Tree
Definition:
A decision tree is a supervised learning algorithm used for classification and
regression by splitting data based on feature values.
Applications:
1. Medical Diagnosis:
Helps in predicting diseases based on symptoms and patient data.
2. Customer Churn Prediction:
Classifies customers likely to leave a service based on historical behavior.
3. Credit Risk Assessment:
Used in banks to determine loan approval based on financial history.
4. Marketing and Targeting:
Identifies the best customer segment for marketing campaigns.
5. Fraud Detection:
Detects abnormal patterns in transactions that may indicate fraud.
27. Type I and Type II Errors
Definition:
These are errors in hypothesis testing in statistics and machine learning.
Points with Explanation:
1. Type I Error (False Positive):
Rejecting a true null hypothesis. E.g., detecting fraud when there isn’t any.
2. Type II Error (False Negative):
Accepting a false null hypothesis. E.g., not detecting fraud when it exists.
3. Impact on Model:
Type I increases false alarms; Type II risks missing critical events.
4. Trade-off:
Reducing one may increase the other. A balance must be maintained based
on application.
5. Use in ML:
Important in evaluating classifiers where class imbalance exists (e.g.,
disease detection).
28. Supervised Learning
Definition:
A type of ML where the model is trained on labeled data to predict outcomes.
Points with Explanation:
1. Labeled Dataset:
Input features are paired with correct output labels for learning.
2. Training Process:
The algorithm learns a mapping from input to output using the dataset.
3. Common Algorithms:
Linear regression, decision trees, SVM, KNN, etc.
4. Applications:
Spam detection, sentiment analysis, and stock price prediction.
5. Evaluation:
Performance measured using metrics like accuracy, precision, and recall.
29. Accuracy, Precision, Recall, F1 Score
Definition:
These are performance metrics for classification models.
Points with Explanation:
1. Accuracy:
Ratio of correctly predicted instances to total instances. Good when data is
balanced.
2. Precision:
True Positives / (True Positives + False Positives). Indicates exactness.
3. Recall (Sensitivity):
True Positives / (True Positives + False Negatives). Indicates completeness.
4. F1 Score:
Harmonic mean of precision and recall. Useful when data is imbalanced.
5. Use Case:
In spam detection, high precision avoids misclassifying genuine emails as
spam.
30. MSE, MAE, RMSE
Definition:
These are error metrics used for evaluating regression models.
Points with Explanation:
1. Mean Squared Error (MSE):
Average of the squared differences between predicted and actual values.
Penalizes large errors.
2. Mean Absolute Error (MAE):
Average of absolute differences. Easier to interpret but less sensitive to
outliers.
3. Root Mean Squared Error (RMSE):
Square root of MSE. Same units as target variable and penalizes larger
errors more.
4. Comparison:
RMSE > MAE when errors are large. MAE is more robust to outliers.
5. Usage:
Useful in regression problems like predicting house prices or temperature.
31. Challenges of Data Imbalance in ML and Solutions
Definition:
Data imbalance occurs when one class significantly outnumbers the other in
classification tasks.
Challenges:
1. Biased Model:
The model tends to predict the majority class more often.
2. Poor Metric Performance:
Accuracy becomes misleading. Model may perform poorly on minority
class.
3. Loss of Information:
Minority class samples may be ignored, leading to lower recall.
Solutions:
4. Resampling Techniques:
Oversampling: Duplicate minority class samples (e.g., SMOTE).
Undersampling: Reduce majority class samples.
5. Use of Different Metrics:
Focus on precision, recall, and F1 score rather than accuracy.
6. Algorithmic Solutions:
Cost-sensitive learning assigns higher penalties to misclassifying the
minority class.