Unit 1 Complete Notes
Unit 1 Complete Notes
BY
V I J AY MANGALCHAND BANDE
LECTURER IN COMPUTER ENGINEERING
G O V E R N M E N T P O LY T E C H N I C K H A M G A O N
COURSE LEVEL LEARNING OUTCOMES (COS)
CO1 - Explain the role of machine learning in AI and data science.
Abstraction
◦ Input data is processed using an algorithm
◦ Important patterns and relationships are extracted
◦ Data is represented in a broader, simplified form
Generalization
◦ Abstracted knowledge is used to make decisions
◦ Helps in solving new and unseen problems
1.1 Basics of ML - Define Machine Learning
Comparison with Human Learning Process
Example: Classification
Animal Classification Concept Map Advantage of Concept
1. Invertebrates Mapping
of Animals No backbone or skeleton
1. Reduces memorization load
Memorizing 2. Vertebrates
2. Characteristics can be
characteristics of all Have backbone
derived using group concepts
animals is difficult Types of Vertebrates:
3. Makes learning easier and
Fishes: Live in water, lay eggs
Better approach: efficient
Amphibians: Live on land and water, smooth
◦ Group animals
skin, lay eggs Generalization in Machine Learning
Reptiles: Scaly skin, lay eggs, cold-blooded Learned patterns are applied to new data
◦ Learn key characteristics of
each group Birds: Can fly, lay eggs, warm-blooded
Examples:
Mammals: Hair/fur, produce milk, warm- ◦ Given animal group → predict
blooded characteristics
◦ Given characteristics → predict animal
group
1.1 Basics of ML - Define Machine Learning
Concept-Based Learning (Human Learning)
Example: Classification
Animal Classification Concept Map Advantage of Concept
1. Invertebrates Mapping
of Animals No backbone or skeleton
1. Reduces memorization load
Memorizing 2. Vertebrates
2. Characteristics can be
characteristics of all Have backbone
derived using group concepts
animals is difficult Types of Vertebrates:
3. Makes learning easier and
Fishes: Live in water, lay eggs
Better approach: efficient
Amphibians: Live on land and water, smooth
◦ Group animals
skin, lay eggs Generalization in Machine Learning
Reptiles: Scaly skin, lay eggs, cold-blooded Learned patterns are applied to new data
◦ Learn key characteristics of
each group Birds: Can fly, lay eggs, warm-blooded
Examples:
Mammals: Hair/fur, produce milk, warm- ◦ Given animal group → predict
blooded characteristics
◦ Given characteristics → predict animal
group
1.1 Basics of ML - Define Machine Learning
• In machine learning, you feed the computer a massive amount of data, and the
computer identifies its own patterns and rules to make predictions or decisions.
1.1 Basics of ML - Define Machine Learning
How it works
Think of it like teaching a child to recognize a fruit:
Data: You show the computer thousands of photos of apples and
oranges.
Training: The computer analyzes pixels and colors to find patterns (e.g.,
apples are often red/round; oranges have a specific texture).
Inference: You show it a new photo it has never seen before, and it uses
those learned patterns to correctly identify it as an apple.
Relationship between AI, ML, DL
•Artificial Intelligence (AI)
•Broad field focused on creating systems that can perform
tasks requiring human intelligence
•Examples: reasoning, problem-solving, decision-making,
language understanding
Note:
All Deep Learning is Machine Learning, and all Machine Learning is Artificial Intelligence, but not all AI is ML, and
not all ML is DL.
1.1 Traditional programming vs ML-based approaches
1.1 Traditional programming vs ML-based approaches
Basic Idea Programmer writes explicit rules System learns rules from data
Flexibility Rigid, hard to adapt to new cases Flexible, adapts with more data
Handling
Difficult for complex patterns Efficient for complex patterns
Complexity
Definition
• Supervised Learning is a type of machine learning where a model is trained on a labeled
dataset.
• A labeled dataset consists of input data (features) and the corresponding correct output
(labels).
• The goal is for the model to learn a general rule that maps inputs to outputs so it can accurately
predict the labels for new, unseen data.
◦ Input (X): The data you feed the model (e.g., floor area, location of a house).
◦ Output (Y): The "target" or answer the model should learn (e.g., the price of the house).
1.2 Supervised Learning: Definition, working principle,
examples→(classification, regression)
1.2 Supervised Learning: Definition, working principle, examples→(classification, regression)
Working Principle
The working principle of supervised learning follows a structured iterative process:
1. Data Collection & Labeling: You gather a large amount of data and manually "tag" it. (e.g., marking 10,000 emails as
either "Spam" or "Not Spam").
2. Training Phase: The algorithm looks at the input data and makes a guess at the output.
3. Error Measurement (The Loss Function): The system compares its guess to the actual "true" label provided by the
teacher. If the guess is wrong, it calculates the "loss" (how far off it was).
4. Optimization: Based on the error, the algorithm adjusts its internal logic (weights) to minimize future mistakes.
5. Iteration: This cycle repeats thousands or millions of times until the model's accuracy reaches a satisfactory level.
6. Inference (Testing): You give the model new data it has never seen before, and it uses its learned patterns to provide a
prediction.
1.2 Supervised Learning: Definition, working principle, examples→(classification, regression)
1. Classification (Categorical)
Real-World Examples:
Email Spam Detection: Binary classification (Is it Spam or Not Spam?).
Medical Diagnosis: Determining if a tumor is Malignant (cancerous) or Benign (non-cancerous).
Image Recognition: Identifying whether a photo contains a Dog, Cat, or Bird.
Sentiment Analysis: Categorizing a customer review as Positive, Negative, or Neutral.
1.2 Supervised Learning: Definition, working principle, examples→(classification, regression)
Classification can be broken down into three main types based on the number of categories (classes) involved
and how the labels are assigned.
1. Binary Classification
This is the simplest form of classification, where there are only two possible outcomes. The model is essentially
answering a "Yes/No" or "True/False" question.
Examples:
◦ Email Filtering: An email is either Spam or Not Spam.
◦ Credit Approval: A loan application is either Approved or Rejected.
◦ Medical Testing: A test result is either Positive or Negative for a disease.
◦ Quality Control: A product on a factory line is either Functional or Defective.
1.2 Supervised Learning: Definition, working principle, examples→(classification, regression)
Classification can be broken down into three main types based on the number of categories (classes) involved
and how the labels are assigned.
2. Multi-Class Classification
In this type, there are more than two categories, but each data point can only belong to one specific class.
Examples:
◦ Handwritten Digit Recognition: Identifying a digit as 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9.
◦ Species Identification: Looking at a photo and labeling it as a Lion, Tiger, or Leopard.
◦ Music Genre Tagging: Labeling a song as Jazz, Rock, Pop, or Classical.
◦ E-commerce: Categorizing a product as Clothing, Electronics, or Home Decor.
1.2 Supervised Learning: Definition, working principle, examples→(classification, regression)
Classification can be broken down into three main types based on the number of categories (classes) involved
and how the labels are assigned.
3. Multi-Label Classification
This is often confused with multi-class, but the difference is key: here, a single data point can belong to multiple
categories at the same time.
Examples:
◦ Social Media Tagging: A single photo can be tagged with #Vacation, #Beach, and #Family all at once.
◦ Movie Categorization: A film like The Dark Knight can be categorized as both Action and Drama.
1.2 Supervised Learning: Definition, working principle, examples→(classification, regression)
Classification can be broken down into three main types based on the number of categories (classes) involved
and how the labels are assigned.
4. Ordinal Classification
Classes have a natural order or ranking
Examples:
◦ Customer feedback → Poor / Average / Good / Excellent
◦ Student grades → A / B / C / D
1.2 Supervised Learning: Definition, working principle, examples→(classification, regression)
2. Regression (Numerical)
In regression, the model is trained to predict a continuous numerical value. The output is a specific number that
can fall anywhere within a range.
◦ Goal: To predict a quantity.
◦ The "Line": The model finds the Best-Fit Line (or curve) that passes as close as possible to all data points.
Real-World Examples:
House Price Prediction: Estimating the price of a house based on its square footage and location (e.g., 452,500).
Weather Forecasting: Predicting the exact temperature for tomorrow (e.g., 24°C).
Stock Market: Estimating the future price of a stock based on historical trends.
Retail: Predicting how many units of a product will sell next month (e.g., 1,250 units).
1.2 Supervised Learning: Definition, working principle, examples→(classification, regression)
Types of Regression
Regression models are categorized based on the number of variables involved and the shape of the relationship
between them.
1. Simple Linear Regression
This is the most basic form of regression. It involves exactly one independent variable (x) and one dependent
variable (y). It assumes the relationship between them is a straight line.
◦ Example: Predicting the price of a house based on its square footage (x_1), the
number of bedrooms (x_2), and the age of the building (x_3).
1.2 Supervised Learning: Definition, working principle, examples→(classification, regression)
Types of Regression
Regression models are categorized based on the number of variables involved and the shape of the relationship
between them.
3. Polynomial Regression
Sometimes the relationship between variables isn't a straight line; it might be a curve. Polynomial regression fits
a non-linear relationship between the value of x and the corresponding conditional mean of y.
◦ Usage: Used when the data points are distributed in a curved pattern (e.g., the growth
rate of a set of cells over time).
◦ Example: Predicting the yield of a crop based on the amount of fertilizer used (where
too much fertilizer might actually decrease the yield, creating a curve).
1.2 Supervised Learning: Definition, working principle, examples→(classification, regression)
Types of Regression
Regression models are categorized based on the number of variables involved and the shape of the relationship
between them.
4. Logistic Regression (The Exception)
Despite its name, Logistic Regression is actually used for Classification, not for predicting continuous numbers. It
predicts the probability of an event occurring (a value between 0 and 1) and then maps it to a discrete class.
Usage: Binary classification (Yes/No).
Example: Predicting the probability that a patient has a certain disease (0.85 probability→ "Positive").
1.2 Supervised Learning: Definition, working principle, examples→(classification, regression)
Differentiate Between Classification and Regression
Feature Classification Regression
Definition
Unsupervised Learning is a type of machine learning in which the model is trained using unlabeled data. The
system learns hidden patterns, structures, or relationships in the data without any predefined output labels.
It is primarily used for Clustering, Association, and Dimensionality Reduction.
◦ Input (X): Raw data with no corresponding output labels (e.g., a list of customer
purchase histories without any "category" assigned to them).
◦ Output: Discovered patterns, logical groupings, or a compressed version of the data.
1.2 Unsupervised Learning: Definition, working principle,
examples→ (Clustering, dimensionality reduction techniques)
1.2 Unsupervised Learning: Definition, working principle, examples→ (Clustering, dimensionality
reduction techniques)
Working Principle
The working principle of unsupervised learning focuses on identifying similarities and differences within the
data:
1. Data Input: The algorithm is fed a large volume of raw, unlabeled data.
2. Pattern Recognition: The model scans the data for inherent [Link] looks for data points that are
"close" to each other in terms of their features.
3. Grouping (Clustering): The algorithm organizes the data into groups (clusters) based on these
similarities. Points in the same cluster share similar characteristics, while points in different clusters are
distinct.
4. Feature Extraction: In some cases, the model simplifies the data by identifying which features are most
important and discarding the "noise.“
5. Output: The model presents the organized data, revealing relationships that were previously unknown to
the human user.
1.2 Unsupervised Learning: Definition, working principle, examples→ (Clustering, dimensionality
reduction techniques)
1. Clustering
Clustering is an unsupervised learning technique in which data points are grouped into clusters such
that objects within the same cluster are more similar to each other than to those in other clusters.
The similarity is usually measured using distance measures like Euclidean distance.
Example
◦ 1. Customer Segmentation
Customers are grouped based on purchasing behavior
Helps businesses design targeted marketing strategies
◦ 2. Gene Sequencing:
Grouping organisms with similar genetic sequences to identify species.
1.2 Unsupervised Learning: Definition, working principle, examples→ (Clustering, dimensionality
reduction techniques)
Types of Clustering
There are several ways an algorithm can "decide" how to group data. Here are the 3 most common types:
1. Centroid-based Clustering (Partitioning)
◦ Divides data into a fixed number of clusters (K)
◦ Each data point belongs to only one cluster
How it works: It can be Agglomerative (starting with individual points and merging them into
groups) or Divisive (starting with one big group and splitting it).
Use Case: Biological Taxonomy. Scientists use this to group animals into families, orders, and
species based on genetic similarities, creating a "tree of life."
1.2 Unsupervised Learning: Definition, working principle, examples→ (Clustering, dimensionality
reduction techniques)
Types of Clustering
3. Density-based Clustering
Instead of looking for a center point, this method looks for areas where data points are "thickly
packed" together.
How it works: It identifies high-density regions as clusters and treats points in low-density
regions as "noise" or outliers. This is excellent for finding clusters of odd, non-spherical shapes.
Use Case: Satellite Imagery. Identifying "urban areas" on a map. High-density clusters of
buildings are marked as cities, while isolated houses in the countryside are ignored as noise.
1.2 Unsupervised Learning: Definition, working principle, examples→ (Clustering, dimensionality
reduction techniques)
2. Dimensionality Reduction
Example
Principal Component Analysis (PCA)
PCA reduces many correlated features into fewer uncorrelated components
Commonly used in image processing and data visualization
1.2 Unsupervised Learning: Definition, working principle, examples→ (Clustering, dimensionality
reduction techniques)
Types of Dimensionality Reduction
There are two primary ways to reduce dimensions: Feature Selection and Feature Extraction.
1. Feature Selection
In this approach, you keep the most relevant features and simply discard the rest. You do not
change the data; you just choose a smaller subset of the original columns.
How it works: It uses statistical tests to see which features have the strongest relationship
with the target output.
Techniques: Filter methods (Correlation), Wrapper methods (Forward selection), and
Embedded methods (LASSO).
Example: If you are predicting "Car Price," you might have columns for Engine Size, Color,
Owner's Name, and Fuel Type.
◦ Selection: You keep Engine Size and Fuel Type because they affect price, but you drop Owner's Name and
Color because they are less relevant.
1.2 Unsupervised Learning: Definition, working principle, examples→ (Clustering, dimensionality
reduction techniques)
High (you know exactly which columns you Low (the new components are
Readability
kept). harder to interpret).
Input Data Uses Labeled data (Input + correct Output). Uses Unlabeled data (Input only).
Goal To predict an output for new, unseen data. To discover hidden patterns or structures.
Role of Machine Learns the relationship between X and Y. Learns the inherent structure of X.
Complexity Generally simpler; results are easy to verify. More complex; results can be subjective.
Examples Spam detection, Price prediction Customer segmentation, Market basket analysis
1.2 Reinforcement Learning: Concept of agents, rewards, and policy learning
Definition-Reinforcement Learning (RL)
2) Unlike supervised learning, where the model is given the "correct" answers,
RL is based on trial and error and the pursuit of a long-term goal.
1.2 Reinforcement Learning: Concept of agents, rewards, and policy learning
1. The Core Components
At the heart of RL is a feedback loop between two main entities: the Agent and the Environment.
The Agent
The agent is the learner or the decision-maker. It is the "brain" of the operation. Its job is to observe the current
situation and decide which action to take to maximize its success over time.
The Environment
The environment is everything the agent interacts with. It represents the world or the problem space (e.g., a
chessboard, a stock market, or a physical maze). The environment responds to the agent's actions by changing its
State and providing feedback(or rewards).
1.2 Reinforcement Learning: Concept of agents, rewards, and policy learning
2. Rewards: The Incentive System
The Reward is the feedback signal from the environment. It tells the agent how well it is doing.
Goal: The agent’s primary objective is to maximize the cumulative reward (the total score)
over time, not just the immediate reward.
1.2 Reinforcement Learning: Concept of agents, rewards, and policy learning
3. Policy Learning
A Policy is the "rulebook" or strategy that the agent uses to decide which action to take based
on its current situation (the State).
How it learns:
◦ Initially, the agent acts randomly to "explore" what happens.
◦ As it receives rewards, it updates its policy to "exploit" the actions that worked well in the
past.
1.2 Reinforcement Learning: Example
Agent Traffic signal controller 1. The traffic signal observes traffic density.
2. It decides how long the green signal should
Environment Roads, vehicles, pedestrians remain.
Number of vehicles waiting, 3. If traffic flows smoothly → positive
State reward.
signal timing
Change signal (green, 4. If congestion increases → negative reward.
Action
yellow, red)
5. Over time, the system learns the best
Reduced waiting time, signal timing.
Reward
smooth traffic flow
1.2 Reinforcement Learning: Example
Example:
ML detects early-stage cancer from radiology images more accurately than manual observation
1.3 Applications of ML- Real-world use cases of ML in various
domains such as healthcare, finance, e-commerce, etc
2. Finance & Banking
How ML is used:
ML helps financial institutions reduce risk and improve decision-making.
How ML is used:
ML improves user experience and increases sales through personalization.
Real-World Use Cases:
1. Recommendation systems → Products suggested on Amazon/Flipkart
2. Dynamic pricing → Price changes based on demand
3. Customer segmentation → Grouping users based on purchase history
4. Chatbots → 24×7 customer support
5. Inventory management → Demand forecasting
Example:
Amazon recommends products based on your past searches and purchases.
1.3 Applications of ML- Real-world use cases of ML in various
domains such as healthcare, finance, e-commerce, etc
4. Education
How ML is used:
ML personalizes learning and improves academic outcomes.
Real-World Use Cases:
1. Student performance prediction
2. Adaptive learning platforms → Personalized content
3. Automatic grading → Online exams and assignments
4. Dropout prediction → Early identification of at-risk students
5. Attendance analysis
Example:
ML predicts students likely to fail and suggests extra learning support.
1.3 Applications of ML- Real-world use cases of ML in various
domains such as healthcare, finance, e-commerce, etc
5. Transportation & Autonomous Systems
How ML is used:
ML enables intelligent decision-making in vehicles and traffic systems.
Example:
Autonomous cars use ML to identify pedestrians and traffic signals.
1.3 Applications of ML- Real-world use cases of ML in various
domains such as healthcare, finance, e-commerce, etc
6. Manufacturing & Industry 4.0
How ML is used:
ML increases efficiency and reduces downtime.
Example:
Factories predict machine failure before it occurs, avoiding losses.
1.3 Challenges in Machine Learning
01. Data Quality and Availability
Machine Learning models depend heavily on the quality and amount of data they’re
trained on. Yet, real-world data is often messy, incomplete or unstructured, forcing
professionals to spend more time cleaning than modeling. Obtaining high-quality labeled
data is costly and time-consuming, especially in sensitive fields like healthcare or finance.
Nearly 70–80% of ML project time goes into data collection and cleaning rather than
model development.
Example: In healthcare, inconsistent or missing patient records can lead to wrong
diagnoses or unreliable predictions.
1.3 Challenges in Machine Learning
02. Imbalanced Datasets
In many ML problems, one class dominates the dataset, causing the model to ignore
minority classes. This imbalance hurts model performance on rare but critical cases like
fraud detection or disease diagnosis. Standard algorithms often fail here because they
assume balanced distributions.
In financial systems, fraudulent transactions make up less than 1% of total data, yet
missing them can cause huge losses.
Example: A cancer detection model might classify nearly all scans as “healthy” because it
rarely sees positive cases during training.
1.3 Challenges in Machine Learning
03. Overfitting and Underfitting
Overfitting occurs when a model memorizes training data, while underfitting happens
when the model is too simple to learn patterns.
Example:
A student who memorizes answers scores well in practice but fails in the final exam.
1.3 Challenges in Machine Learning
04. Model Interpretability and Explainability
Machine learning models can be very complex, making it difficult to understand how they
arrive at their predictions. This can be a challenge when explaining the model to
stakeholders or regulatory bodies. Techniques such as feature importance and partial
dependence plots can help improve model interpretability.
Example:
A bank cannot explain why a loan application was rejected by an ML system.
1.3 Challenges in Machine Learning
05. Generalization
Machine learning models are trained on a specific dataset, and they may not perform well
on new data that is outside the training set. This can be addressed by using techniques
such as cross-validation and regularization.
Example:
A face recognition model failing in different lighting conditions.
1.3 Challenges in Machine Learning
06. Scalability
Machine learning models can be computationally expensive and may not scale well to
large datasets. Techniques such as distributed computing, parallel processing, and
sampling can help address scalability issues.
Example:
Training deep learning models on millions of images.
1.3 Challenges in Machine Learning
07. Model Deployment and Integration
Deploying ML models into production is more complex than training them. Integration
with APIs, databases and real-time systems often introduces compatibility and
performance challenges.
Gartner reports that only about 15% of trained ML models reach production due to
deployment hurdles.
Example: A recommendation model that works offline may crash under live traffic or
mismatched infrastructure.
1.3 Challenges in Machine Learning
08. Lack of Domain Expertise
Machine Learning isn’t just about algorithms it requires deep understanding of the domain
to interpret results correctly. Without domain insight, even accurate models can lead to
poor business decisions.
A McKinsey report showed ML projects involving domain experts had 30–40% higher
success rates.
Example: A financial model built without economic insight might overlook market cycles
and mispredict investment risks.
1.4 Introduction to Python for ML-Basics of Python programming relevant to ML
Python is the most widely used language for Machine Learning due to its
simplicity, readability, and rich ML libraries.
Comparison Operators:
== != > < >= <=
ML relevance: Reading dataset values and ML relevance: Used in conditions and
displaying results. evaluation metrics.
1.4 Introduction to Python for ML-Basics of Python programming relevant to ML
While Loop:
ML Relevance:
Most ML projects start with CSV or Excel
datasets, so Pandas is essential for loading
data efficiently.
ML Relevance:
DataFrames are the main way to store and manipulate
datasets before training ML models. Columns represent
features, rows represent samples.
1.4 Overview required libraries: Pandas
3. Handling Missing Values 4. Selecting Columns & Rows
ML Relevance:
ML models cannot handle missing values directly.
Pandas allows filling or dropping missing data for
cleaner model inputs.
ML Relevance:
Selecting features (columns) and samples (rows) is
essential for feature engineering and preparing
training/test sets.
1.4 Overview required libraries: Pandas
5. Statistical Analysis 6. Data Transformation
ML Relevance: ML Relevance:
Exploratory Data Analysis (EDA) helps in
understanding feature distributions, detecting ML models require numerical features, so
outliers, and scaling/normalizing features. Pandas is used for feature transformation
and encoding categorical variables.
1.4 Overview required libraries: Pandas
7. Integration with Machine Learning Overview:
What is Matplotlib?
Matplotlib is a Python library used for data visualization.
It helps in creating graphs and plots such as:
◦ Line plots
◦ Bar charts
◦ Histograms
◦ Scatter plots
In Machine Learning, Matplotlib is mainly used for data exploration, understanding
patterns, model evaluation, and result visualization.
1.4 Overview required libraries: Matplotlib
ML Relevance: ML Relevance:
Used to visualize training loss vs epochs, Helps visualize class distribution, useful in
helping detect overfitting or underfitting. identifying imbalanced datasets.
1.4 Overview required libraries: Matplotlib
3. Histogram 4. Scatter Plot
ML Relevance: ML Relevance:
Used to understand feature distribution and Shows relationships between two features,
detect skewness or outliers before training helping decide whether regression or
ML models. classification is suitable.
1.4 Overview required libraries: Matplotlib
5. Multiple Plots (Model Comparison) 6. Box Plot
ML Relevance: ML Relevance:
Compares training vs testing performance to Outliers (like very high salary) can skew
detect overfitting. regression models and should be handled
before training.
1.4 Overview required libraries: Scikit-learn
What is Scikit-learn?
ML Relevance:
Separates data into training and testing sets
to evaluate how well the model generalizes ML Relevance:
to unseen data. Used for predicting continuous values
such as price, salary, or temperature.
1.4 Overview required libraries: Scikit-learn
3. Logistic Regression (Classification) 4. K-Nearest Neighbors (KNN)
ML Relevance: ML Relevance:
Used for binary classification problems like Classifies data based on similarity to nearby data
spam detection or pass/fail prediction. points.
1.4 Overview required libraries: Scikit-learn
5. K-Means Clustering (Unsupervised 6. Feature Scaling (Standardization)
Learning)
ML Relevance: ML Relevance:
Groups unlabeled data into clusters, useful Improves model performance by
for customer segmentation. ensuring features are on the same scale.
1.4 Overview required libraries: Scikit-learn
7. Model Evaluation (Accuracy Score)
ML Relevance:
Measures how accurately the model predicts
correct outputs.
1.4 Writing and executing simple ML scripts in Python
To understand how to write, run, and test a simple Machine Learning program using Python and Scikit-learn.
ML Relevance:
Libraries provide ready-made ML algorithms and numerical operations.
1.4 Writing and executing simple ML scripts in Python
Steps to Write a Simple ML Script
• Example: df = pd.read_csv('[Link]’).
• Exploratory Data Analysis (EDA): This is a "sub-step" where you check for missing values or
outliers before moving forward.
ML Relevance:
ML models learn the relationship between input features and target output.
1.4 Writing and executing simple ML scripts in Python
Steps to Write a Simple ML Script
Splitting: You must split your data into a Training Set and a Testing Set.
◦ Training Set: Used to build the model.
◦ Testing Set: A "blind test" to see how the model handles data it has never seen before.
◦ Standard split: 80% training / 20% testing.
1.4 Writing and executing simple ML scripts in Python
Steps to Write a Simple ML Script
Splitting: You must split your data into a Training Set and a Testing Set.
◦ Training Set: Used to build the model.
◦ Testing Set: A "blind test" to see how the model handles data it has never seen before.
◦ Standard split: 80% training / 20% testing.
1.4 Writing and executing simple ML scripts in Python
Steps to Write a Simple ML Script
4. Choose ML Algorithm
Select the algorithm based on your goal:
• Classification: RandomForestClassifier, SVM, LogisticRegression.
• Regression: LinearRegression, XGBoost.
7. Evaluate Performance
Finally, you compare the model’s predictions (y_pred) against the actual known answers (y_test).
Metrics: Accuracy, Precision, Recall, or Mean Squared Error (for regression).
1.4 Writing and executing simple ML scripts in Python
Code Blueprint: A Simple Script
Note: