Introduction to Artificial Intelligence (AI) and Machine Learning (ML)
Complete Class 10 Computer Science Chapter 6 notes covering Artificial Intelligence (AI), Machine Learning (ML), AI applications, supervised and unsupervised learning, machine learning algorithms, confusion matrix, and model performance evaluation. Includes simple examples, MCQs, short questions, long questions, and FAQs for FBISE and Punjab Board students.
Class 10 Computer Science Chapter 6: Introduction to AI and Machine Learning
Posted in 10 Computer Science
These lecture notes are prepared by Salman Ahmad, who is both a teacher and a web developer.
The purpose of this material is to make the topic clear and useful for students of Class 10 Computer Science.
Artificial Intelligence (AI)
Artificial Intelligence (AI) is a technology that enables computers and machines to perform tasks that normally require human intelligence, such as understanding language, recognizing images, and solving problems.
Examples of AI [Mention any 1 or 2 Examples during writing exam]
Google Assistant: Understands voice commands and responds to users.
ChatGPT: Answers questions, explains topics, and helps users write content.
Self-Driving Cars: Use AI to recognize roads, traffic signs, and other vehicles.
YouTube: Recommends videos based on users' interests.
Face Recognition: Identifies people by analyzing their facial features.
Online Chatbots: Answer customers' questions on websites.
Medical Diagnosis: Helps doctors identify diseases by analyzing medical images and data.
Robots: Use AI to perform tasks such as sorting objects and working in factories.
Machine Learning (ML)
Machine Learning (ML) is a branch of Artificial Intelligence that enables computers to learn from data, identify patterns, and make predictions or decisions without being programmed for every task.
Examples of ML [Mention any 1 or 2 Examples during writing exam]
YouTube: Recommends videos based on users' interests and viewing history.
Email Spam Filters: Learn to identify and separate spam emails from normal emails.
Online Shopping: Recommends products based on users' previous searches and purchases.
Netflix: Recommends movies and shows based on users' viewing habits.
Difference Between Artificial Intelligence (AI) and Machine Learning (ML)
Artificial Intelligence (AI)
Machine Learning (ML)
AI is a technology that enables machines to perform tasks that normally require human intelligence.
ML is a branch of AI that enables machines to learn from data.
It focuses on making machines perform intelligent tasks.
It focuses on learning patterns from data and making predictions.
AI can use different methods, including rules, logic, and machine learning.
ML uses data and algorithms to learn patterns.
AI is the broader field.
ML is a part of AI.
Examples: Google Assistant, ChatGPT, Self-Driving Cars, Face Recognition, Rule-Based Chatbots.
Machine Learning (ML) is a branch of Artificial Intelligence that enables computers to learn from data and make predictions or decisions. It has three main types:
Supervised Learning
Unsupervised Learning
Reinforcement Learning: The computer learns through trial and error by receiving rewards for good actions and penalties for incorrect actions.
Difference Between Supervised and Unsupervised Learning
Supervised and unsupervised learning are two important types of machine learning. The main difference is that supervised learning uses labeled data, while unsupervised learning uses unlabeled data.
Supervised Learning
Unsupervised Learning
It learns from labeled data, where the correct answers are already known.
It learns from unlabeled data, where the correct answers are not provided.
The computer learns by comparing its predictions with the correct answers.
The computer identifies patterns, similarities, and groups in the data on its own.
It is mainly used to predict results or classify information into known categories.
It is mainly used to discover hidden patterns and group similar information.
Example: Teaching a computer using labeled pictures of cats and dogs so it can identify them in new pictures.
Example: Giving a computer pictures of different animals without labels so it can group similar animals together.
Practical Applications of AI/ML
1. Smart Assistants
Smart assistants use AI and ML to understand voice commands, answer questions, and perform different tasks. They help users set alarms, search for information, make calls, send messages, and control smart devices.
Examples: Siri, Google Assistant, and Alexa.
2. Recommendation Systems
Recommendation systems use AI and ML to suggest videos, products, music, movies, and other content based on users' interests, searches, and previous activities. They help users find content they may like.
Examples: YouTube recommends videos, Netflix suggests movies, and Daraz recommends products based on users' interests and activities.
Bias, Privacy, and Responsibility in AI
1. Bias in AI
Bias in AI occurs when an AI system produces unfair results because of the data it learns from.
Example: If an AI system is trained only on English or male voices, it may not work well with Urdu speakers or female voices.
2. Privacy and Data Use
AI systems often use personal information, such as names, locations, and user preferences. This information must be protected from misuse.
Example: An app that tracks a user's location without permission can misuse their personal information.
Best Practices
Ask users for permission before collecting their data.
Protect data using encryption.
Collect only the data that is needed.
3. Responsibility of Humans
Humans are responsible for developing, using, and monitoring AI systems. They must check AI decisions and correct mistakes to prevent harm.
Example: If a facial recognition system identifies the wrong person, developers must investigate the error and improve the system to prevent similar mistakes.
Supervised and Unsupervised Learning Algorithms
1. Linear Regression (Supervised Learning)
Linear Regression is a supervised learning algorithm that predicts future values by finding a straight-line relationship between existing data. It studies how one value changes with another to make predictions.
Example: Predicting a student's exam score based on the number of hours they study. Generally, students who study more hours may achieve higher scores.
2. Decision Trees (Supervised Learning)
Decision Trees are supervised learning algorithms that make predictions or decisions by following a tree-like structure of questions and conditions.
Example: Predicting whether a student will pass or fail based on their exam preparation and previous marks.
3. K-Means Clustering (Unsupervised Learning)
K-Means Clustering is an unsupervised learning algorithm that groups similar data into different clusters based on their features, without using predefined labels.
Example: Grouping customers based on their shopping habits, such as customers who buy frequently, occasionally, or rarely.
Evaluating Model Performance
Model Performance Evaluation: It is the process of checking how accurately a machine learning model makes predictions.
Confusion Matrix
A confusion matrix is a table used to compare a model's predictions with the actual results. It helps check the performance and quality of a machine learning model by showing its correct and incorrect predictions.
A confusion matrix contains four values:
True Positive (TP): The model correctly predicts a positive result.
True Negative (TN): The model correctly predicts a negative result.
False Positive (FP): The model predicts a positive result, but the actual result is negative.
False Negative (FN): The model predicts a negative result, but the actual result is positive.
Example of a Confusion Matrix
Suppose an AI model predicts whether students will pass or fail an exam. After comparing the predictions with the actual results of 100 students, the following confusion matrix is obtained:
Model Predictions
Actual Results
Actual Pass
Actual Fail
Predicted Pass
TP = 40
FP = 10
Predicted Fail
FN = 5
TN = 45
TP = 40: The model correctly predicts that 40 students will pass.
TN = 45: The model correctly predicts that 45 students will fail.
FP = 10: The model predicts that 10 students will pass, but they actually fail.
FN = 5: The model predicts that 5 students will fail, but they actually pass.
Accuracy
Accuracy measures the percentage of all predictions that are correct. It is calculated by dividing the total number of correct predictions by the total number of predictions and multiplying by 100.
Formula:
Accuracy = (TP + TN) / (TP + TN + FP + FN) × 100
Calculation:
Accuracy = (40 + 45) / (40 + 45 + 10 + 5) × 100
Accuracy = 85 / 100 × 100
Accuracy = 85%
Result: The model has an accuracy of 85%, meaning it correctly predicts the results for 85 out of 100 students.
Exercise: Short Answer Questions
1. What is the difference between AI and ML?
Already mentioned in the notes.
2. Give one real-life example of AI used in Pakistan.
One real-life example of AI used in Pakistan is a chatbot on a bank's website that answers customers' questions automatically.
3. How does supervised learning work?
Supervised learning works by training a model using labeled data, where the correct answers are already known. The model learns patterns from this data and uses them to make predictions on new data.
4. Define confusion matrix.
A confusion matrix is a table used to compare a machine learning model's predictions with actual results. It helps evaluate the model's performance by showing correct and incorrect predictions through True Positive (TP), True Negative (TN), False Positive (FP), and False Negative (FN).
5. How can businesses use AI?
Businesses can use AI to answer customer questions through chatbots, recommend products, analyze customer data, detect fraud, and improve decision-making.
6. Give one example each of a smart assistant and a recommendation system.
Smart Assistant: Google Assistant helps users answer questions and perform tasks through voice commands.
Recommendation System: YouTube recommends videos based on users' interests and viewing history.
7. What kind of data is used in unsupervised learning?
Unsupervised learning uses unlabeled data, which has no predefined labels or correct answers. The computer finds similarities and groups similar data on its own.
Example: Giving a computer pictures of different animals without names. The computer groups similar animals, such as cats and dogs, based on their features.
Exercise: Long Answer Questions
1. Explain supervised and unsupervised learning with suitable examples.
Already mentioned in the notes.
2. Explain how model performance is evaluated in machine learning using the following metrics:
a) Confusion Matrix
A confusion matrix is a table used to compare a model's predicted results with the actual results. It helps evaluate the performance and quality of a machine learning model.
It contains four values:
True Positive (TP): The model correctly predicts a positive result.
True Negative (TN): The model correctly predicts a negative result.
False Positive (FP): The model predicts a positive result, but the actual result is negative.
False Negative (FN): The model predicts a negative result, but the actual result is positive.
b) Accuracy
Accuracy measures the percentage of all predictions that are correct. It is calculated by dividing the number of correct predictions by the total number of predictions and multiplying by 100.
Formula:
Accuracy = (TP + TN) / (TP + TN + FP + FN) × 100
c) Precision
Precision measures how many of the positive predictions made by a model are actually positive. It helps determine how reliable the model's positive predictions are.
Formula:
Precision = TP / (TP + FP) × 100
3. Numerical Problem: Confusion Matrix and Accuracy
A model predicts whether students will pass (1) or fail (0). Out of 20 students, the results are:
True Positives (TP) = 8
True Negatives (TN) = 6
False Positives (FP) = 4
False Negatives (FN) = 2
(a) Fill the Confusion Matrix
The confusion matrix is completed by placing the given values according to the predicted and actual results.
Predicted Results
Actual Results
Pass (1)
Fail (0)
Pass (1)
TP = 8
FP = 4
Fail (0)
FN = 2
TN = 6
(b) Calculate Accuracy
Formula:
Accuracy = (TP + TN) / (TP + TN + FP + FN) × 100
Step 1: Substitute the values.
Accuracy = (8 + 6) / (8 + 6 + 4 + 2) × 100
Step 2: Add the values.
Accuracy = 14 / 20 × 100
Step 3: Calculate the percentage.
Accuracy = 0.7 × 100
Final Answer: Accuracy = 70%
Result: The model correctly predicts the results for 14 out of 20 students, giving an accuracy of 70%.
Class 10 Computer Science Chapter 6 MCQs: Introduction to AI and Machine Learning
1. What is Artificial Intelligence (AI)?
a. A technology that enables machines to perform tasks requiring human intelligence
b. A method of repairing computer hardware
c. A type of computer storage
d. A programming language
Answer: a. A technology that enables machines to perform tasks requiring human intelligence
2. What does AI stand for?
a. Automated Internet
b. Artificial Intelligence
c. Advanced Information
d. Automatic Integration
Answer: b. Artificial Intelligence
3. What does ML stand for?
a. Machine Learning
b. Manual Logic
c. Modern Language
d. Memory Location
Answer: a. Machine Learning
4. What is Machine Learning (ML)?
a. A method of manually entering all instructions for every situation
b. A branch of AI that allows computers to learn from data
c. A technique for manufacturing computer parts
d. A method of connecting printers
Answer: b. A branch of AI that allows computers to learn from data
5. What is the relationship between AI and ML?
a. AI is a branch of ML
b. Both are exactly the same
c. ML is a branch of AI
d. Neither is related to computers
Answer: c. ML is a branch of AI
6. Which of the following is an example of AI?
a. A basic wooden table
b. A voice assistant that understands spoken commands
c. A simple notebook
d. A manual pencil sharpener
Answer: b. A voice assistant that understands spoken commands
7. Which of the following is a smart voice assistant?
a. Microsoft Paint
b. Notepad
c. Siri
d. WordPad
Answer: c. Siri
8. What is a common use of AI in recommendation systems?
a. Suggesting content based on user interests
b. Increasing the size of a monitor
c. Replacing computer keyboards
d. Repairing damaged hardware
Answer: a. Suggesting content based on user interests
9. Which platform uses recommendations to suggest videos?
a. Notepad
b. Paint
c. WordPad
d. YouTube
Answer: d. YouTube
10. What is the purpose of a chatbot?
a. To repair damaged hardware
b. To answer questions and assist users
c. To increase screen brightness only
d. To store electricity
Answer: b. To answer questions and assist users
11. What is bias in AI?
a. When an AI system produces unfair results
b. When a computer starts normally
c. When data is stored correctly
d. When a printer prints a document
Answer: a. When an AI system produces unfair results
12. What can cause bias in an AI system?
a. Using suitable and diverse training data
b. Using incomplete or unbalanced training data
c. Turning off a monitor
d. Increasing keyboard speed
Answer: b. Using incomplete or unbalanced training data
13. Why is data privacy important in AI?
a. It protects personal information from misuse
b. It makes computers heavier
c. It increases the size of files
d. It removes the need for software
Answer: a. It protects personal information from misuse
14. Who is responsible for designing, testing, and fixing AI systems?
a. Printers
b. Speakers
c. Developers
d. Monitors
Answer: c. Developers
15. What is supervised learning?
a. Learning from unlabeled data only
b. Learning without using data
c. Learning only from computer hardware
d. Learning from labeled data
Answer: d. Learning from labeled data
16. What is labeled data?
a. Data that cannot be stored
b. Data with known answers or categories
c. Data used only for printing
d. Data without any information
Answer: b. Data with known answers or categories
17. What is unsupervised learning?
a. Learning from unlabeled data to discover patterns
b. Learning from labeled data only
c. Learning without examining data
d. Learning by following fixed answers for every example
Answer: a. Learning from unlabeled data to discover patterns
18. Which learning method uses labeled data?
a. Unsupervised learning
b. Manual data entry
c. Supervised learning
d. Random grouping only
Answer: c. Supervised learning
19. Which learning method discovers patterns in unlabeled data?
a. Supervised learning
b. Manual programming only
c. Data printing
d. Unsupervised learning
Answer: d. Unsupervised learning
20. Which of the following is a supervised learning algorithm?
a. Linear Regression
b. K-Means Clustering
c. Manual file copying
d. Random data sorting without labels
Answer: a. Linear Regression
21. What is the main purpose of Linear Regression?
a. To create computer hardware
b. To predict numerical values
c. To delete data automatically
d. To design web pages only
Answer: b. To predict numerical values
22. Which example is suitable for Linear Regression?
a. Grouping customers without predefined categories
b. Turning a computer on
c. Predicting exam scores from study hours
d. Formatting a document
Answer: c. Predicting exam scores from study hours
23. What is a Decision Tree?
a. A physical tree connected to a computer
b. A type of computer cable
c. A tool used only for drawing pictures
d. An algorithm that makes predictions using questions and conditions
Answer: d. An algorithm that makes predictions using questions and conditions
24. Which structure does a Decision Tree use?
a. Tree-like structure
b. Keyboard layout
c. Network cable structure
d. Circular storage structure only
Answer: a. Tree-like structure
25. Which of the following is an unsupervised learning algorithm?
a. Linear Regression
b. Decision Trees
c. K-Means Clustering
d. Logistic Regression
Answer: c. K-Means Clustering
26. What is the main purpose of K-Means Clustering?
a. To predict numerical values using a straight line
b. To group similar data points into clusters
c. To repair computer hardware
d. To create passwords automatically
Answer: b. To group similar data points into clusters
27. Which is an example of K-Means Clustering?
a. Predicting exam scores from study hours
b. Calculating a percentage manually
c. Printing a report
d. Grouping customers according to shopping habits
Answer: d. Grouping customers according to shopping habits
28. What is model performance evaluation?
a. Checking how accurately a model makes predictions
b. Checking the physical size of a computer
c. Measuring the length of a keyboard
d. Installing an operating system
Answer: a. Checking how accurately a model makes predictions
29. What is a confusion matrix?
a. A device used to store files
b. A programming language
c. A table that compares predicted results with actual results
d. A tool used to connect computers
Answer: c. A table that compares predicted results with actual results
30. What is the purpose of a confusion matrix?
a. To increase computer memory
b. To check model performance and identify correct and incorrect predictions
c. To create database tables only
d. To improve internet speed directly
Answer: b. To check model performance and identify correct and incorrect predictions
31. What does TP stand for in a confusion matrix?
a. Total Prediction
b. Tested Program
c. Training Process
d. True Positive
Answer: d. True Positive
32. What does TN stand for in a confusion matrix?
a. True Negative
b. Total Number
c. Training Network
d. Tested Number
Answer: a. True Negative
33. What does FP stand for in a confusion matrix?
a. Final Prediction
b. False Positive
c. First Program
d. Fixed Process
Answer: b. False Positive
34. What does FN stand for in a confusion matrix?
a. Final Number
b. Fixed Network
c. False Negative
d. First Name
Answer: c. False Negative
35. When does a True Positive (TP) occur?
a. The model predicts positive, and the actual result is positive
b. The model predicts negative, and the actual result is positive
c. The model predicts positive, and the actual result is negative
d. The model predicts negative, and the actual result is negative
Answer: a. The model predicts positive, and the actual result is positive
36. When does a False Positive (FP) occur?
a. The model predicts positive, and the actual result is positive
b. The model predicts negative, and the actual result is negative
c. The model predicts negative, and the actual result is positive
d. The model predicts positive, but the actual result is negative
Answer: d. The model predicts positive, but the actual result is negative
37. What does accuracy measure in machine learning?
a. The number of computers in a lab
b. The percentage of all predictions that are correct
c. The amount of data stored on a disk
d. The speed of a keyboard
Answer: b. The percentage of all predictions that are correct
39. A model makes 85 correct predictions out of 100. What is its accuracy?
a. 85%
b. 65%
c. 75%
d. 95%
Answer: a. 85%
40. In a confusion matrix, what does a False Negative (FN) mean?
a. The model predicts positive, and the actual result is positive
b. The model predicts negative, and the actual result is negative
c. The model predicts positive, and the actual result is negative
d. The model predicts negative, but the actual result is positive
Answer: d. The model predicts negative, but the actual result is positive
Test Yourself: Interactive MCQs (AI and Machine Learning)
Class 10 Computer Science Chapter 6 MCQs: Introduction to AI and Machine Learning
1. What is Artificial Intelligence (AI)?
2. What is Machine Learning (ML)?
3. Which of the following is an example of AI?
4. Which of the following is a smart assistant?
5. What is a common use of smart assistants?
6. Which technology helps YouTube recommend videos?
7. What is the purpose of a recommendation system?
8. Which platform uses recommendation systems?
9. What is a chatbot?
10. What is image recognition?
11. What does AI bias mean?
12. What can cause bias in an AI system?
13. What does data privacy mean?
14. Which practice helps protect personal data?
15. Who should help ensure an AI system is designed responsibly?
16. What is Machine Learning mainly used for?
17. What is supervised learning?
18. What is unsupervised learning?
19. What is labeled data?
20. Which type of learning uses unlabeled data?
21. Which is an example of supervised learning?
22. Which is an example of unsupervised learning?
23. What is a machine learning algorithm?
24. What does Linear Regression predict?
25. Which is an example of Linear Regression?
26. What is a Decision Tree?
27. Which problem can a Decision Tree help solve?
28. What is clustering?
29. K-Means is an example of which type of algorithm?
30. What is the purpose of K-Means Clustering?
31. What is model performance evaluation?
32. What is a confusion matrix?
33. What does True Positive (TP) mean?
34. What does True Negative (TN) mean?
35. What does False Positive (FP) mean?
36. What does False Negative (FN) mean?
37. Which formula is used to calculate accuracy?
38. A model makes 85 correct predictions out of 100. What is its accuracy?
39. If TP = 40, TN = 45, FP = 10, and FN = 5, how many predictions are correct?
40. Using TP = 40, TN = 45, FP = 10, and FN = 5, what is the model's accuracy?
FAQs
Class 10 Computer Science Chapter 6: AI and Machine Learning FAQs
Artificial Intelligence (AI) is a technology that enables computers and machines to perform tasks that normally require human intelligence, such as understanding language, recognizing images, and solving problems.
Machine Learning (ML) is a branch of AI that allows computers to learn from data, identify patterns, and make predictions or decisions.
AI enables machines to perform tasks that require human intelligence, while ML is a branch of AI that helps machines learn from data and improve their predictions.
Common applications of AI include smart assistants, chatbots, image recognition, recommendation systems, and voice recognition.
Smart assistants are AI-powered tools that understand voice commands and help users perform tasks. Examples include Siri, Google Assistant, and Alexa.
A recommendation system suggests videos, products, music, or other content based on users' interests and activities. Examples include YouTube, Netflix, and Daraz.
AI bias occurs when an AI system produces unfair results for certain people or groups, often because of incomplete or unbalanced training data.
Data privacy is important because AI systems may use personal information. Protecting this information helps prevent unauthorized access and misuse.
Supervised learning is a type of machine learning that uses labeled data, where the correct answers are already known. For example, predicting student marks using study hours and previous scores.
Unsupervised learning is a type of machine learning that identifies patterns and groups similar data without predefined labels. For example, grouping customers by their shopping habits.
Linear Regression is a machine learning algorithm used to predict numerical values based on the relationship between variables. For example, predicting student marks from study hours.
A Decision Tree is a machine learning model that makes predictions by following a tree-like structure of questions and conditions. For example, it can predict whether a student will pass or fail.
K-Means Clustering is an unsupervised learning algorithm that divides data into groups based on similarities between data points.
A confusion matrix is a table that compares actual results with predicted results. It helps evaluate a machine learning model by showing correct and incorrect predictions using TP, TN, FP, and FN.
Model accuracy measures the percentage of predictions a model gets correct. It is calculated using the formula: Accuracy = (TP + TN) / (TP + TN + FP + FN) × 100, where TP is True Positive, TN is True Negative, FP is False Positive, and FN is False Negative.