
In this chapter, students will learn the fundamentals of data and analysis and their importance in modern computing. They will explore the basics of data science and understand different types of data, including structured and unstructured data, along with methods of data collection and storage. The chapter introduces machine learning as a way for systems to learn from data and make decisions. The chapter explains how to evaluate model performance using measures like accuracy, precision, recall, and F1-score, and how to improve models through validation and tuning. Finally, the students will be introduced to common tools such as Excel, R, and Python used in data science and machine learning.
Data science is a field that focuses on collecting, analyzing, and using data to find useful information. It helps convert raw data into meaningful knowledge. Data science uses tools and methods to analyze large amounts of data. It supports decision-making in many areas of life. Data science also helps predict future trends. It is widely used in business, education, and healthcare. Modern technology depends heavily on data science. Tidbit: many organizations use data science to support decision making. It helps understand trends and patterns hidden in data.
Data science means the study of data to discover patterns and useful information. It involves collecting data from different sources. The data is cleaned and organized before analysis. After analysis, the results are interpreted carefully. Data science helps answer questions using facts and data. It reduces guesswork in decision-making. The complete workflow of Data Science is shown in Figure 6.1. Data science turns data into knowledge. This knowledge helps solve real-world problems.
Data science combines knowledge from different subjects. It uses mathematics to work with numbers and calculations. Statistics helps in analyzing and summarizing data. Computer science provides tools and programming skills. Domain knowledge is needed to understand real problems. Communication skills help explain results clearly. Because of this combination, data science is called interdisciplinary. Each field supports the other. Together, they make data analysis more effective.
اس باب میں طلبہ ڈیٹا اور تجزیے کے بنیادی اصول اور جدید کمپیوٹنگ میں ان کی اہمیت سیکھیں گے۔ وہ ڈیٹا سائنس کی بنیادی باتیں دیکھیں گے اور ڈیٹا کی مختلف اقسام سمجھیں گے، جن میں اسٹرکچرڈ اور ان اسٹرکچرڈ ڈیٹا شامل ہے، ساتھ ڈیٹا اکٹھا کرنے اور ذخیرہ کرنے کے طریقے۔ باب مشین لرننگ کو ایک طریقے کے طور پر متعارف کراتا ہے جس سے سسٹمز ڈیٹا سے سیکھ کر فیصلے کرتے ہیں۔ باب بتاتا ہے کہ درستگی، پریسیژن، ریکال اور F1-اسکور جیسے پیمانوں سے ماڈل کی کارکردگی کیسے جانچی جائے، اور توثیق اور ٹیوننگ سے ماڈلز کیسے بہتر بنائے جائیں۔ آخر میں طلبہ کو ڈیٹا سائنس اور مشین لرننگ میں استعمال ہونے والے عام ٹولز جیسے Excel، R اور Python سے متعارف کرایا جائے گا۔
ڈیٹا سائنس ایک شعبہ ہے جو مفید معلومات ڈھونڈنے کے لیے ڈیٹا اکٹھا کرنے، تجزیہ کرنے اور استعمال کرنے پر توجہ دیتا ہے۔ یہ خام ڈیٹا کو بامعنی علم میں تبدیل کرنے میں مدد دیتا ہے۔ ڈیٹا سائنس بڑی مقدار میں ڈیٹا کا تجزیہ کرنے کے لیے ٹولز اور طریقے استعمال کرتا ہے۔ یہ زندگی کے کئی شعبوں میں فیصلہ سازی کی حمایت کرتا ہے۔ ڈیٹا سائنس مستقبل کے رجحانات کی پیش گوئی میں بھی مدد دیتا ہے۔ یہ کاروبار، تعلیم اور صحت میں بڑے پیمانے پر استعمال ہوتا ہے۔ جدید ٹیکنالوجی ڈیٹا سائنس پر بہت زیادہ انحصار کرتی ہے۔ دلچسپ بات: کئی تنظیمیں فیصلہ سازی کی حمایت کے لیے ڈیٹا سائنس استعمال کرتی ہیں۔ یہ ڈیٹا میں چھپے رجحانات اور پیٹرن سمجھنے میں مدد دیتا ہے۔
ڈیٹا سائنس کا مطلب ڈیٹا کا مطالعہ کرنا ہے تاکہ پیٹرن اور مفید معلومات دریافت ہوں۔ اس میں مختلف ذرائع سے ڈیٹا اکٹھا کرنا شامل ہے۔ تجزیے سے پہلے ڈیٹا صاف اور منظم کیا جاتا ہے۔ تجزیے کے بعد نتائج کو احتیاط سے سمجھا جاتا ہے۔ ڈیٹا سائنس حقائق اور ڈیٹا سے سوالات کا جواب دینے میں مدد دیتا ہے۔ یہ فیصلہ سازی میں اندازے کم کرتا ہے۔ ڈیٹا سائنس کا مکمل ورک فلو فگر 6.1 میں دکھایا گیا ہے۔ ڈیٹا سائنس ڈیٹا کو علم میں بدلتا ہے۔ یہ علم حقیقی دنیا کے مسائل حل کرنے میں مدد دیتا ہے۔
ڈیٹا سائنس مختلف مضامین کے علم کو یکجا کرتا ہے۔ یہ اعداد اور حسابات کے لیے ریاضی استعمال کرتا ہے۔ شماریات ڈیٹا کا تجزیہ اور خلاصہ کرنے میں مدد دیتی ہے۔ کمپیوٹر سائنس ٹولز اور پروگرامنگ مہارتیں دیتی ہے۔ حقیقی مسائل سمجھنے کے لیے ڈومین نالج درکار ہے۔ مواصلاتی مہارتیں نتائج واضح طور پر بیان کرنے میں مدد دیتی ہیں۔ اس ترکیب کی وجہ سے ڈیٹا سائنس کو انٹر ڈسپلنری کہا جاتا ہے۔ ہر شعبہ دوسرے کی حمایت کرتا ہے۔ مل کر وہ ڈیٹا تجزیہ زیادہ مؤثر بناتے ہیں۔
Data is the foundation of Data Science. Data is a collection of raw facts and values to produce information. It can be in the form of numbers, text, images, audio or video. Data is produced every day through different activities. Understanding data is important before analysis. Different types of data need different handling methods. Proper data understanding helps in obtaining correct results. Poor data understanding can lead to errors. Data must be accurate and reliable to produce accurate results. Tidbit: data quality strongly affects final results. Poor data can lead to incorrect conclusions.
Types of Data — Structured and Unstructured: structured data is organized in a clear format, such as tables or spreadsheets. It has rows and columns that are easy to understand. Examples include students' mark sheets and databases. Unstructured data does not follow a fixed format (as shown in Figure 6.2). Examples include emails, images, audio, and videos. Unstructured data is difficult to analyze directly. Special tools are needed to process it. Both types of data are important. Modern systems use both structured and unstructured data.
Data Sources and Data Collection Methods: data can be collected from many sources. Common sources include surveys, interviews, forms, sensors, and online platforms (such as blogs, social websites, and others). Manual data collection involves human effort, whereas automatic data collection uses machines and software. Data can be collected in real time or stored over time. The method depends on the purpose of the analysis. Good data sources and accurate data collections improve analysis quality.
Data Storage and Management Concepts: data storage refers to saving data for future use. Data can be stored in files, databases, or cloud systems. Proper storage helps protect data from loss. Data management involves organizing and maintaining data. It ensures data is easy to find and use. Security is an important part of data management. Backup systems help prevent data loss. Well-managed data improves efficiency. Data management supports long-term data use. Do You Know? Proper understanding of data type is very important before analysis of data.
ڈیٹا ڈیٹا سائنس کی بنیاد ہے۔ ڈیٹا معلومات پیدا کرنے کے لیے خام حقائق اور اقدار کا مجموعہ ہے۔ یہ اعداد، متن، تصاویر، آڈیو یا ویڈیو کی شکل میں ہو سکتا ہے۔ ڈیٹا ہر روز مختلف سرگرمیوں سے پیدا ہوتا ہے۔ تجزیے سے پہلے ڈیٹا سمجھنا اہم ہے۔ ڈیٹا کی مختلف اقسام کو مختلف طریقوں سے سنبھالنے کی ضرورت ہوتی ہے۔ ڈیٹا کی مناسب سمجھ درست نتائج حاصل کرنے میں مدد دیتی ہے۔ ڈیٹا کی خراب سمجھ غلطیوں کا باعث بن سکتی ہے۔ درست نتائج پیدا کرنے کے لیے ڈیٹا درست اور قابل اعتماد ہونا چاہیے۔ دلچسپ بات: ڈیٹا کا معیار حتمی نتائج پر بہت اثر ڈالتا ہے۔ خراب ڈیٹا غلط نتائج کا باعث بن سکتا ہے۔
ڈیٹا کی اقسام — اسٹرکچرڈ اور ان اسٹرکچرڈ: اسٹرکچرڈ ڈیٹا واضح فارمیٹ میں منظم ہوتا ہے، جیسے جدولیں یا اسپریڈ شیٹس۔ اس میں قطاریں اور کالم ہوتے ہیں جو سمجھنے میں آسان ہیں۔ مثالوں میں طلبہ کی مارک شیٹس اور ڈیٹا بیسز شامل ہیں۔ ان اسٹرکچرڈ ڈیٹا کسی مقررہ فارمیٹ پر عمل نہیں کرتا (جیسا کہ فگر 6.2 میں دکھایا گیا ہے)۔ مثالوں میں ای میلز، تصاویر، آڈیو اور ویڈیوز شامل ہیں۔ ان اسٹرکچرڈ ڈیٹا کا براہ راست تجزیہ مشکل ہے۔ اسے پروسیس کرنے کے لیے خاص ٹولز درکار ہیں۔ ڈیٹا کی دونوں اقسام اہم ہیں۔ جدید سسٹمز دونوں اسٹرکچرڈ اور ان اسٹرکچرڈ ڈیٹا استعمال کرتے ہیں۔
ڈیٹا کے ذرائع اور ڈیٹا اکٹھا کرنے کے طریقے: ڈیٹا کئی ذرائع سے اکٹھا کیا جا سکتا ہے۔ عام ذرائع میں سروے، انٹرویوز، فارمز، سینسرز اور آن لائن پلیٹ فارمز (جیسے بلاگز، سوشل ویب سائٹس وغیرہ) شامل ہیں۔ دستی ڈیٹا اکٹھا کرنے میں انسانی محنت شامل ہوتی ہے، جبکہ خودکار ڈیٹا اکٹھا کرنا مشینیں اور سافٹ ویئر استعمال کرتا ہے۔ ڈیٹا حقیقی وقت میں اکٹھا کیا جا سکتا ہے یا وقت کے ساتھ ذخیرہ کیا جا سکتا ہے۔ طریقہ تجزیے کے مقصد پر منحصر ہے۔ اچھے ڈیٹا ذرائع اور درست ڈیٹا اکٹھا کرنا تجزیے کا معیار بہتر کرتا ہے۔
ڈیٹا اسٹوریج اور مینجمنٹ کے تصورات: ڈیٹا اسٹوریج کا مطلب مستقبل کے استعمال کے لیے ڈیٹا محفوظ کرنا ہے۔ ڈیٹا فائلوں، ڈیٹا بیسز یا کلاؤڈ سسٹمز میں ذخیرہ کیا جا سکتا ہے۔ مناسب اسٹوریج ڈیٹا کو نقصان سے بچانے میں مدد دیتا ہے۔ ڈیٹا مینجمنٹ ڈیٹا کو منظم اور برقرار رکھنے سے متعلق ہے۔ یہ یقینی بناتا ہے کہ ڈیٹا ڈھونڈنا اور استعمال کرنا آسان ہو۔ سیکیورٹی ڈیٹا مینجمنٹ کا اہم حصہ ہے۔ بیک اپ سسٹمز ڈیٹا کے نقصان کو روکنے میں مدد دیتے ہیں۔ اچھی طرح منظم ڈیٹا مؤثریت بہتر کرتا ہے۔ ڈیٹا مینجمنٹ طویل مدتی ڈیٹا استعمال کی حمایت کرتا ہے۔ کیا آپ جانتے ہیں؟ ڈیٹا کے تجزیے سے پہلے ڈیٹا کی قسم کی مناسب سمجھ بہت اہم ہے۔
Machine learning is a subfield of Data Science that enables systems to improve from experience without explicit programming. It involves analyzing patterns in data to make predictions or decisions. Large datasets are used to train models, which adapt and improve over time as new data is introduced. This technique is widely applied in modern applications, supporting automation and intelligent systems.
Instead of predefined rules, machine learning allows systems to learn from examples, identifying patterns that guide predictions. As the system processes more data, it becomes more accurate and efficient, powering smart applications and reducing manual work.
Learning From Data: learning from data means using past information to improve decisions. In this process, data is given as input to a learning model, which studies relationships in it. Errors are reduced through repeated training, and data becomes more accurate. Learning from data is continuous because the models update when new data is available. This process helps systems become smarter.
Difference Between Traditional Programming and Machine Learning: traditional programming uses fixed rules written by programmers. The output is produced by following these rules. Machine learning uses data instead of fixed rules. The system learns rules automatically from data. In traditional programming, changes require new code. In machine learning, changes happen through new data. Machine learning handles complex problems better. It adapts to new situations. Figure 6.3 shows traditional programming vs machine learning.
مشین لرننگ ڈیٹا سائنس کا ایک ذیلی شعبہ ہے جو سسٹمز کو واضح پروگرامنگ کے بغیر تجربے سے بہتر ہونے کے قابل بناتا ہے۔ اس میں پیش گوئیاں یا فیصلے کرنے کے لیے ڈیٹا میں پیٹرن کا تجزیہ شامل ہے۔ ماڈلز کو تربیت دینے کے لیے بڑے ڈیٹا سیٹس استعمال ہوتے ہیں، جو نیا ڈیٹا آنے پر وقت کے ساتھ ڈھلتے اور بہتر ہوتے ہیں۔ یہ تکنیک جدید ایپلی کیشنز میں بڑے پیمانے پر استعمال ہوتی ہے، جو آٹومیشن اور ذہین سسٹمز کی حمایت کرتی ہے۔
پہلے سے طے شدہ قواعد کے بجائے مشین لرننگ سسٹمز کو مثالوں سے سیکھنے دیتی ہے، ایسے پیٹرن پہچان کر جو پیش گوئیاں رہنمائی کرتے ہیں۔ جیسے جیسے سسٹم زیادہ ڈیٹا پروسیس کرتا ہے، یہ زیادہ درست اور مؤثر ہوتا جاتا ہے، سمارٹ ایپلی کیشنز کو طاقت دیتا ہے اور دستی کام کم کرتا ہے۔
ڈیٹا سے سیکھنا: ڈیٹا سے سیکھنے کا مطلب ماضی کی معلومات کو فیصلے بہتر بنانے کے لیے استعمال کرنا ہے۔ اس عمل میں ڈیٹا لرننگ ماڈل کو ان پٹ کے طور پر دیا جاتا ہے، جو اس میں تعلقات کا مطالعہ کرتا ہے۔ بار بار تربیت سے غلطیاں کم ہوتی ہیں، اور ڈیٹا زیادہ درست ہوتا جاتا ہے۔ ڈیٹا سے سیکھنا مسلسل ہے کیونکہ نیا ڈیٹا دستیاب ہونے پر ماڈلز اپ ڈیٹ ہوتے ہیں۔ یہ عمل سسٹمز کو ہوشیار بنانے میں مدد دیتا ہے۔
روایتی پروگرامنگ اور مشین لرننگ میں فرق: روایتی پروگرامنگ پروگرامروں کے لکھے مقررہ قواعد استعمال کرتی ہے۔ آؤٹ پٹ ان قواعد پر عمل کر کے پیدا ہوتا ہے۔ مشین لرننگ مقررہ قواعد کے بجائے ڈیٹا استعمال کرتی ہے۔ سسٹم ڈیٹا سے قواعد خود بخود سیکھتا ہے۔ روایتی پروگرامنگ میں تبدیلیوں کے لیے نیا کوڈ درکار ہوتا ہے۔ مشین لرننگ میں تبدیلیاں نئے ڈیٹا سے ہوتی ہیں۔ مشین لرننگ پیچیدہ مسائل بہتر طریقے سے سنبھالتی ہے۔ یہ نئی صورتحال کے مطابق ڈھلتی ہے۔ فگر 6.3 روایتی پروگرامنگ بمقابلہ مشین لرننگ دکھاتی ہے۔
Machine learning mechanisms describe how systems learn from data. Different mechanisms are used for different problems. Some methods use labeled data, while others do not (as shown in Figure 6.4). Labeled data: data with labels (outputs) that tell us what the data is — e.g. images labeled Apple, Banana, Orange, Grapes — used in supervised learning (classification, regression). Unlabeled data: data without labels; we don't know what the data is — used in unsupervised learning (clustering, association).
Certain methods are learned through feedback and experience. Each mechanism follows a different learning process. Choosing the correct mechanism is important. The quality of learning depends on the method used. These mechanisms support intelligent decision-making. Machine learning systems rely on proper mechanisms to work effectively. Some kinds of machine learning are discussed below:
Supervised Machine Learning: supervised machine learning uses labeled data for training. Each data item has an input and a correct output. The system learns by comparing its output with the correct answer. Supervised learning needs large labelled datasets, such as emails labelled as spam or not spam, images labelled as cat or dog, or medical scans labelled as normal or abnormal. Its accuracy usually improves when the model is trained on more high-quality examples. It is widely used in real applications, such as face recognition, disease detection, speech recognition, fraud detection, and recommendation systems. This method is used for prediction tasks. Examples include email spam detection and exam result prediction.
Unsupervised Machine Learning: unsupervised machine learning works with unlabeled data. The system finds patterns without guidance. It groups similar data together and makes clusters. This method is useful for discovering hidden structures. No correct output is provided. Learning depends on data similarity. Unsupervised learning helps understand data behavior. It is useful for data exploration. Examples include customer grouping and data clustering.
Reinforcement Machine Learning: reinforcement machine learning learns through experience and mimics the human learning. The system interacts with an environment. It receives rewards or penalties for actions. Positive rewards encourage correct behavior. The system improves decision making over time. This method is used in robotics and games. Learning continues through trial and error. The goal is to maximize rewards. Examples of reinforcement learning include a robot learning to navigate a maze through rewards and penalties, AlphaGo improving its strategy by playing Go, an autonomous car optimizing its driving decisions, and a movie recommendation system adjusting its suggestions based on user feedback.
مشین لرننگ میکانزمز بتاتے ہیں کہ سسٹمز ڈیٹا سے کیسے سیکھتے ہیں۔ مختلف مسائل کے لیے مختلف میکانزمز استعمال ہوتے ہیں۔ کچھ طریقے لیبل شدہ ڈیٹا استعمال کرتے ہیں، جبکہ دیگر نہیں (جیسا کہ فگر 6.4 میں دکھایا گیا ہے)۔ لیبل شدہ ڈیٹا: لیبلز (آؤٹ پٹس) والا ڈیٹا جو بتاتا ہے کہ ڈیٹا کیا ہے — مثلاً Apple، Banana، Orange، Grapes لیبل والی تصاویر — زیر نگرانی لرننگ (درجہ بندی، ریگریشن) میں استعمال ہوتا ہے۔ بغیر لیبل ڈیٹا: بغیر لیبلز والا ڈیٹا؛ ہم نہیں جانتے کہ ڈیٹا کیا ہے — غیر زیر نگرانی لرننگ (کلسٹرنگ، ایسوسی ایشن) میں استعمال ہوتا ہے۔
کچھ طریقے فیڈ بیک اور تجربے سے سیکھے جاتے ہیں۔ ہر میکانزم مختلف لرننگ عمل کی پیروی کرتا ہے۔ درست میکانزم چننا اہم ہے۔ لرننگ کا معیار استعمال شدہ طریقے پر منحصر ہے۔ یہ میکانزمز ذہین فیصلہ سازی کی حمایت کرتے ہیں۔ مشین لرننگ سسٹمز مؤثر طریقے سے کام کرنے کے لیے مناسب میکانزمز پر انحصار کرتے ہیں۔ مشین لرننگ کی کچھ اقسام ذیل میں زیر بحث ہیں:
زیر نگرانی مشین لرننگ: زیر نگرانی مشین لرننگ تربیت کے لیے لیبل شدہ ڈیٹا استعمال کرتی ہے۔ ہر ڈیٹا آئٹم کا ایک ان پٹ اور ایک درست آؤٹ پٹ ہوتا ہے۔ سسٹم اپنے آؤٹ پٹ کا درست جواب سے موازنہ کر کے سیکھتا ہے۔ زیر نگرانی لرننگ کو بڑے لیبل شدہ ڈیٹا سیٹس درکار ہوتے ہیں، جیسے اسپیم یا نان اسپیم لیبل والی ای میلز، بلی یا کتے لیبل والی تصاویر، یا نارمل یا غیر معمولی لیبل والی میڈیکل اسکینز۔ اس کی درستگی عام طور پر بہتر ہوتی ہے جب ماڈل کو زیادہ اعلیٰ معیار کی مثالوں پر تربیت دی جائے۔ یہ حقیقی ایپلی کیشنز میں بڑے پیمانے پر استعمال ہوتی ہے، جیسے چہرے کی پہچان، بیماری کی تشخیص، تقریر کی پہچان، دھوکہ دہی کی تشخیص، اور سفارشی نظام۔ یہ طریقہ پیش گوئی کے کاموں کے لیے استعمال ہوتا ہے۔ مثالوں میں ای میل اسپیم تشخیص اور امتحانی نتائج کی پیش گوئی شامل ہیں۔
غیر زیر نگرانی مشین لرننگ: غیر زیر نگرانی مشین لرننگ بغیر لیبل ڈیٹا سے کام کرتی ہے۔ سسٹم بغیر رہنمائی کے پیٹرن ڈھونڈتا ہے۔ یہ ملتے جلتے ڈیٹا کو ایک ساتھ گروپ کر کے کلسٹرز بناتا ہے۔ یہ طریقہ چھپی ہوئی ساخت دریافت کرنے کے لیے مفید ہے۔ کوئی درست آؤٹ پٹ فراہم نہیں کیا جاتا۔ لرننگ ڈیٹا کی مماثلت پر منحصر ہے۔ غیر زیر نگرانی لرننگ ڈیٹا کے رویے کو سمجھنے میں مدد دیتی ہے۔ یہ ڈیٹا کی کھوج کے لیے مفید ہے۔ مثالوں میں گاہکوں کی گروپ بندی اور ڈیٹا کلسٹرنگ شامل ہیں۔
تقویت مشین لرننگ: تقویت مشین لرننگ تجربے سے سیکھتی ہے اور انسانی لرننگ کی نقل کرتی ہے۔ سسٹم ماحول سے رابطہ کرتا ہے۔ یہ اعمال کے لیے انعامات یا سزائیں وصول کرتا ہے۔ مثبت انعامات درست رویے کی حوصلہ افزائی کرتے ہیں۔ سسٹم وقت کے ساتھ فیصلہ سازی بہتر کرتا ہے۔ یہ طریقہ روبوٹکس اور گیمز میں استعمال ہوتا ہے۔ لرننگ آزمائش اور غلطی سے جاری رہتی ہے۔ مقصد انعامات کو زیادہ سے زیادہ کرنا ہے۔ تقویت لرننگ کی مثالوں میں روبوٹ کا انعامات اور سزاؤں سے بھول بھلیاں میں راستہ سیکھنا، AlphaGo کا Go کھیل کر اپنی حکمت عملی بہتر کرنا، خودکار کار کا اپنے ڈرائیونگ فیصلے بہتر کرنا، اور فلمی سفارشی نظام کا صارف کے فیڈ بیک سے اپنی تجاویز ایڈجسٹ کرنا شامل ہیں۔
Machine learning is used in many areas of modern life. It helps organizations analyze large amounts of data quickly, including Healthcare, Business, Education, and Daily Life (as shown in Figure 6.5). Many systems work automatically using learned patterns. It reduces human effort and saves time.
Use of Machine Learning in Healthcare: in healthcare, machine learning helps analyze medical data and supports disease detection and diagnosis. For example, it can help detect cancerous cells in medical images, identify early signs of Alzheimer's disease or dementia, and assist in the diagnosis of cardiovascular diseases. Doctors can use these results to plan better and more timely treatments.
Use of Machine Learning in Business: businesses use machine learning to understand customer behavior. It helps predict sales and market trends. Businesses use it for inventory management. Examples include detecting fraud in financial systems, customer services through robots or chatbots, and suggesting products to customers. Marketing strategies become more effective using machine learning. Business decisions become data-driven. This improves profit and efficiency.
Use of Machine Learning in Education: in education, machine learning improves learning systems. It helps track students' performance to improve their grades. Personalized learning content is provided. Attendance and assessment systems become smarter. Learning outcomes improve.
Everyday Applications of Machine Learning: machine learning is used in daily life activities. Mobile phones use it for face recognition. Voice assistants understand spoken commands. Social media shows personalized content. Email services filter spam messages. Navigation apps suggest routes. Online platforms recommend videos and music. Smart devices use machine learning and daily tasks become easier and faster.
مشین لرننگ جدید زندگی کے کئی شعبوں میں استعمال ہوتی ہے۔ یہ تنظیموں کو بڑی مقدار میں ڈیٹا جلدی تجزیہ کرنے میں مدد دیتی ہے، جن میں صحت، کاروبار، تعلیم اور روزمرہ زندگی شامل ہیں (جیسا کہ فگر 6.5 میں دکھایا گیا ہے)۔ کئی سسٹمز سیکھے ہوئے پیٹرن سے خودکار طور پر کام کرتے ہیں۔ یہ انسانی محنت کم کرتی ہے اور وقت بچاتی ہے۔
صحت میں مشین لرننگ کا استعمال: صحت میں مشین لرننگ میڈیکل ڈیٹا کا تجزیہ کرنے اور بیماری کی تشخیص اور تشخیص میں مدد دیتی ہے۔ مثلاً یہ میڈیکل تصاویر میں کینسر کے خلیات ڈھونڈنے، الزائمر کی بیماری یا ڈیمینشیا کی ابتدائی علامات پہچاننے، اور قلبی امراض کی تشخیص میں مدد کر سکتی ہے۔ ڈاکٹر ان نتائج کو بہتر اور زیادہ بروقت علاج کی منصوبہ بندی کے لیے استعمال کر سکتے ہیں۔
کاروبار میں مشین لرننگ کا استعمال: کاروبار گاہکوں کے رویے کو سمجھنے کے لیے مشین لرننگ استعمال کرتے ہیں۔ یہ فروخت اور مارکیٹ کے رجحانات کی پیش گوئی میں مدد دیتی ہے۔ کاروبار اسے انوینٹری مینجمنٹ کے لیے استعمال کرتے ہیں۔ مثالوں میں مالیاتی سسٹمز میں دھوکہ دہی کی تشخیص، روبوٹس یا چیٹ بوٹس سے گاہکوں کی خدمات، اور گاہکوں کو مصنوعات تجویز کرنا شامل ہیں۔ مشین لرننگ سے مارکیٹنگ حکمت عملیاں زیادہ مؤثر ہو جاتی ہیں۔ کاروباری فیصلے ڈیٹا پر مبنی ہو جاتے ہیں۔ یہ منافع اور مؤثریت بہتر کرتا ہے۔
تعلیم میں مشین لرننگ کا استعمال: تعلیم میں مشین لرننگ لرننگ سسٹمز بہتر کرتی ہے۔ یہ طلبہ کی کارکردگی ٹریک کرنے میں مدد دیتی ہے تاکہ ان کے گریڈ بہتر ہوں۔ ذاتی نوعیت کا لرننگ مواد فراہم کیا جاتا ہے۔ حاضری اور تشخیص کے نظام ہوشیار ہو جاتے ہیں۔ لرننگ نتائج بہتر ہوتے ہیں۔
مشین لرننگ کے روزمرہ اطلاقات: مشین لرننگ روزمرہ زندگی کی سرگرمیوں میں استعمال ہوتی ہے۔ موبائل فون اسے چہرے کی پہچان کے لیے استعمال کرتے ہیں۔ وائس اسسٹنٹس بولی ہوئی کمانڈز سمجھتے ہیں۔ سوشل میڈیا ذاتی نوعیت کا مواد دکھاتا ہے۔ ای میل سروسز اسپیم پیغامات فلٹر کرتی ہیں۔ نیویگیشن ایپس راستے تجویز کرتی ہیں۔ آن لائن پلیٹ فارمز ویڈیوز اور موسیقی تجویز کرتے ہیں۔ سمارٹ ڈیوائسز مشین لرننگ استعمال کرتی ہیں اور روزمرہ کام آسان اور تیز ہو جاتے ہیں۔
Building a machine learning model involves several clear steps (as shown in Figure 6.6). A simple example of machine learning is student grade prediction. In this example, data about students is first collected, such as attendance, quiz marks, assignment scores, study hours, and previous exam results. The data is then cleaned and prepared so that it can be used for learning. Important values, also called features, are selected because they help the model understand factors that affect student performance. After this, the machine learning model is trained using the prepared data. Once trained, the model can predict a student's possible grade based on new input data. This helps teachers identify students who may need extra support before the final examination. Tidbit: building a model involves selecting data and features carefully. Training data teaches the model patterns. Testing data checks performance. Feature selection improves results. A well-built model gives reliable predictions.
Example: students' exam scores are often affected by the number of hours they study. The purpose of the following program is to build a simple linear regression model that predicts exam scores based on study hours. The dataset contains examples of hours studied and corresponding exam scores. The data is divided into training and testing sets, the model is trained using the training data, and its performance is evaluated using Mean Squared Error (MSE). Finally, the actual data points and the predicted regression line are plotted to show the relationship between study hours and exam scores.
# Import necessary libraries
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
# Example data (Hours studied vs. Exam scores)
X = np.array([[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) # Hours studied
y = np.array([1, 2, 2, 3, 4, 5, 6, 7]) # Exam scores
# Step 1: Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Step 2: Create and train the model
model = LinearRegression()
model.fit(X_train, y_train)
# Step 3: Make predictions
y_pred = model.predict(X_test)
# Step 4: Evaluate the model
mse = mean_squared_error(y_test, y_pred)
print("Mean Squared Error:", mse)
# Step 5: Plotting the results
plt.scatter(X, y, color='blue') # Actual data points
plt.plot(X, model.predict(X), color='red') # Predicted line
plt.xlabel('Hours Studied')
plt.ylabel('Exam Scores')
plt.title('Linear Regression: Hours vs. Scores')
plt.show()
Book-faithful note: as printed, the code's X has 10 values but the printed y-array has only 8 — sklearn requires X and y to have the same length, so typed exactly as printed this code will error. The book's own plot (Figure 6.7) shows 10 points — (1,1), (2,2), (3,2), (4,3), (5,3), (6,4), (7,5), (8,5), (9,6), (10,7) — so use those ten y-values to run it. The book's reported output is: Mean Squared Error: 0.1484; Model equation: Exam Score = 0.6552 × Hours Studied + 0.1466.
Data Preparation: the X values represent hours studied, and y values represent the corresponding exam scores (as shown in Figure 6.7). Model Training: a linear regression model is created and trained on the training data (X_train, y_train). Testing: the model is tested on the test data (X_test) and the mean squared error (MSE) is calculated to evaluate its performance. A lower MSE indicates better model performance because it means the predicted values are closer to the actual values. Improvement: as more data is gathered or adjusted, the model's accuracy improves.
Selecting Features and Target Values: features are input values used by the model. Target values are outputs to be predicted. Correct feature selection improves learning. Unnecessary features can reduce accuracy. Features must be relevant to the problem. Target values must be clearly defined. Example: when predicting student marks, study hours would be the feature, and the target value would be the marks.
Feature Engineering Basics: feature engineering means improving data for better learning. It includes selecting, modifying, and creating features. Raw data is often not ready for models. Data may need cleaning and scaling. Feature engineering improves model performance. It helps highlight important information. Good features produce better predictions. This step requires an understanding of data. Feature engineering strengthens the model. Example: in predicting student marks, feature engineering might involve cleaning raw data like study hours, scaling it, and creating new features like "study hours per day" to improve model performance and make better predictions.
Train-Test Split Of Data: data is divided into training and testing sets. Training data teaches the model patterns. Testing data checks model performance as it uses unseen data. Results show real performance. This split prevents overfitting. Common splits include 80 percent training and 20 percent testing.
Building a Simple Predictive Model: a simple predictive model uses basic algorithms to learn from training data. It analyses the data to understand patterns and then makes predictions for new, unseen data. These models are easy to understand and are especially helpful for beginners. Their performance is measured using test data and the results guide improvements.
مشین لرننگ ماڈل بنانے میں کئی واضح مراحل شامل ہیں (جیسا کہ فگر 6.6 میں دکھایا گیا ہے)۔ مشین لرننگ کی ایک سادہ مثال طلبہ کے گریڈ کی پیش گوئی ہے۔ اس مثال میں پہلے طلبہ کے بارے میں ڈیٹا اکٹھا کیا جاتا ہے، جیسے حاضری، کوئز نمبر، اسائنمنٹ اسکور، مطالعے کے گھنٹے، اور پچھلے امتحانی نتائج۔ پھر ڈیٹا صاف اور تیار کیا جاتا ہے تاکہ اسے لرننگ کے لیے استعمال کیا جا سکے۔ اہم اقدار، جنہیں فیچرز بھی کہا جاتا ہے، منتخب کی جاتی ہیں کیونکہ وہ ماڈل کو ان عوامل کو سمجھنے میں مدد دیتی ہیں جو طلبہ کی کارکردگی پر اثر ڈالتے ہیں۔ اس کے بعد تیار شدہ ڈیٹا سے مشین لرننگ ماڈل کو تربیت دی جاتی ہے۔ ایک بار تربیت یافتہ ہونے پر ماڈل نئے ان پٹ ڈیٹا کی بنیاد پر طالب علم کے ممکنہ گریڈ کی پیش گوئی کر سکتا ہے۔ یہ اساتذہ کو ان طلبہ کی نشاندہی کرنے میں مدد دیتا ہے جنہیں حتمی امتحان سے پہلے اضافی مدد کی ضرورت ہو سکتی ہے۔ دلچسپ بات: ماڈل بنانے میں ڈیٹا اور فیچرز کا احتیاط سے انتخاب شامل ہے۔ ٹریننگ ڈیٹا ماڈل کو پیٹرن سکھاتا ہے۔ ٹیسٹنگ ڈیٹا کارکردگی چیک کرتا ہے۔ فیچر انتخاب نتائج بہتر کرتا ہے۔ اچھی طرح بنایا گیا ماڈل قابل اعتماد پیش گوئیاں دیتا ہے۔
مثال: طلبہ کے امتحانی اسکور اکثر ان کے مطالعے کے گھنٹوں سے متاثر ہوتے ہیں۔ درج ذیل پروگرام کا مقصد ایک سادہ لینیئر ریگریشن ماڈل بنانا ہے جو مطالعے کے گھنٹوں کی بنیاد پر امتحانی اسکور کی پیش گوئی کرتا ہے۔ ڈیٹا سیٹ میں مطالعے کے گھنٹوں اور متعلقہ امتحانی اسکور کی مثالیں ہیں۔ ڈیٹا کو ٹریننگ اور ٹیسٹنگ سیٹس میں تقسیم کیا جاتا ہے، ماڈل کو ٹریننگ ڈیٹا سے تربیت دی جاتی ہے، اور اس کی کارکردگی Mean Squared Error (MSE) سے جانچی جاتی ہے۔ آخر میں اصل ڈیٹا پوائنٹس اور پیش گوئی کی گئی ریگریشن لائن پلاٹ کی جاتی ہے تاکہ مطالعے کے گھنٹوں اور امتحانی اسکور کے درمیان تعلق دکھایا جا سکے۔
# ضروری لائبریریز درآمد کریں
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
X = np.array([[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) # مطالعے کے گھنٹے
y = np.array([1, 2, 2, 3, 4, 5, 6, 7]) # امتحانی اسکور
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
model = LinearRegression()
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
mse = mean_squared_error(y_test, y_pred)
print("Mean Squared Error:", mse)
plt.scatter(X, y, color='blue')
plt.plot(X, model.predict(X), color='red')
plt.xlabel('Hours Studied')
plt.ylabel('Exam Scores')
plt.title('Linear Regression: Hours vs. Scores')
plt.show()
کتاب کے مطابق نوٹ: جیسا کہ چھپا ہے، کوڈ میں X کی 10 قدریں ہیں لیکن چھپی y-ایری کی صرف 8 — sklearn کو X اور y کی لمبائی برابر چاہیے، اس لیے بالکل چھپے مطابق ٹائپ کرنے پر یہ کوڈ غلطی دے گا۔ کتاب کا اپنا پلاٹ (فگر 6.7) 10 پوائنٹس دکھاتا ہے — (1,1)، (2,2)، (3,2)، (4,3)، (5,3)، (6,4)، (7,5)، (8,5)، (9,6)، (10,7) — اس لیے چلانے کے لیے وہ دس y-قدریں استعمال کریں۔ کتاب کا رپورٹ شدہ آؤٹ پٹ ہے: Mean Squared Error: 0.1484؛ ماڈل مساوات: Exam Score = 0.6552 × Hours Studied + 0.1466۔
ڈیٹا کی تیاری: X قدریں مطالعے کے گھنٹے ظاہر کرتی ہیں، اور y قدریں متعلقہ امتحانی اسکور ظاہر کرتی ہیں (جیسا کہ فگر 6.7 میں دکھایا گیا ہے)۔ ماڈل ٹریننگ: ایک لینیئر ریگریشن ماڈل بنایا جاتا ہے اور ٹریننگ ڈیٹا (X_train, y_train) پر تربیت دی جاتی ہے۔ ٹیسٹنگ: ماڈل کو ٹیسٹ ڈیٹا (X_test) پر جانچا جاتا ہے اور اس کی کارکردگی جانچنے کے لیے مین اسکوائرڈ ایرر (MSE) نکالا جاتا ہے۔ کم MSE بہتر ماڈل کارکردگی ظاہر کرتا ہے کیونکہ اس کا مطلب ہے کہ پیش گوئی شدہ قدریں اصل قدروں کے قریب ہیں۔ بہتری: جیسے جیسے زیادہ ڈیٹا اکٹھا یا ایڈجسٹ کیا جاتا ہے، ماڈل کی درستگی بہتر ہوتی ہے۔
فیچرز اور ٹارگٹ ویلیوز کا انتخاب: فیچرز ماڈل کے استعمال کردہ ان پٹ ویلیوز ہیں۔ ٹارگٹ ویلیوز وہ آؤٹ پٹس ہیں جن کی پیش گوئی کرنی ہے۔ فیچر کا درست انتخاب لرننگ بہتر کرتا ہے۔ غیر ضروری فیچرز درستگی کم کر سکتے ہیں۔ فیچرز مسئلے سے متعلق ہونے چاہئیں۔ ٹارگٹ ویلیوز واضح طور پر طے ہونے چاہئیں۔ مثال: طلبہ کے نمبر کی پیش گوئی کرتے وقت مطالعے کے گھنٹے فیچر ہوں گے، اور ٹارگٹ ویلیو نمبر ہوں گے۔
فیچر انجینئرنگ کی بنیادی باتیں: فیچر انجینئرنگ کا مطلب بہتر لرننگ کے لیے ڈیٹا بہتر کرنا ہے۔ اس میں فیچرز منتخب کرنا، تبدیل کرنا اور بنانا شامل ہے۔ خام ڈیٹا اکثر ماڈلز کے لیے تیار نہیں ہوتا۔ ڈیٹا کو صفائی اور اسکیلنگ کی ضرورت ہو سکتی ہے۔ فیچر انجینئرنگ ماڈل کی کارکردگی بہتر کرتی ہے۔ یہ اہم معلومات نمایاں کرنے میں مدد دیتی ہے۔ اچھے فیچرز بہتر پیش گوئیاں دیتے ہیں۔ اس مرحلے میں ڈیٹا کی سمجھ درکار ہے۔ فیچر انجینئرنگ ماڈل کو مضبوط کرتی ہے۔ مثال: طلبہ کے نمبر کی پیش گوئی میں فیچر انجینئرنگ میں مطالعے کے گھنٹے جیسے خام ڈیٹا کی صفائی، اسے اسکیل کرنا، اور "روزانہ مطالعے کے گھنٹے" جیسے نئے فیچرز بنانا شامل ہو سکتا ہے تاکہ ماڈل کی کارکردگی بہتر ہو اور بہتر پیش گوئیاں ہوں۔
ڈیٹا کا ٹرین-ٹیسٹ اسپلٹ: ڈیٹا کو ٹریننگ اور ٹیسٹنگ سیٹس میں تقسیم کیا جاتا ہے۔ ٹریننگ ڈیٹا ماڈل کو پیٹرن سکھاتا ہے۔ ٹیسٹنگ ڈیٹا ماڈل کی کارکردگی چیک کرتا ہے کیونکہ یہ ان دیکھا ڈیٹا استعمال کرتا ہے۔ نتائج حقیقی کارکردگی دکھاتے ہیں۔ یہ تقسیم اوور فٹنگ روکتی ہے۔ عام تقسیموں میں 80 فیصد ٹریننگ اور 20 فیصد ٹیسٹنگ شامل ہیں۔
سادہ پیش گوئی ماڈل بنانا: ایک سادہ پیش گوئی ماڈل ٹریننگ ڈیٹا سے سیکھنے کے لیے بنیادی الگورتھم استعمال کرتا ہے۔ یہ ڈیٹا کا تجزیہ کر کے پیٹرن سمجھتا ہے اور پھر نئے، ان دیکھے ڈیٹا کے لیے پیش گوئیاں کرتا ہے۔ یہ ماڈلز سمجھنے میں آسان ہیں اور خاص طور پر نئے سیکھنے والوں کے لیے مددگار ہیں۔ ان کی کارکردگی ٹیسٹ ڈیٹا سے ناپی جاتی ہے اور نتائج بہتری کی رہنمائی کرتے ہیں۔
Model evaluation is a process of checking how well a machine learning model performs. It measures the quality of predictions made by the model using test data that was not used during training. This helps in identifying the strengths and weaknesses of the model. Performance metrics are measures used to evaluate how well a model is working. Different metrics are used depending on the type of problem, discussed below. Do You Know? A model with high accuracy may still give wrong results in some cases. That is why other measures like precision and recall are used. Proper evaluation helps understand the real performance of a model.
Accuracy and Error: accuracy shows how many predictions are correct out of the total predictions. It is measured as a percentage. High accuracy means better performance. The error shows incorrect predictions. Error rate is the opposite of accuracy. Accuracy alone may be misleading sometimes. Balanced data gives better accuracy results. Error analysis helps find mistakes. Both measures are important for evaluation. The accuracy equation is: Accuracy = (TP + TN) / (TP + TN + FP + FN), where TP (True Positives): number of correctly predicted positive instances; TN (True Negatives): number of correctly predicted negative instances; FP (False Positives): number of incorrectly predicted positive instances; FN (False Negatives): number of incorrectly predicted negative instances.
Precision and Recall: precision measures how many predicted positive results are actually correct. Recall measures how many actual positive cases are correctly identified. Precision focuses on correctness, recall focuses on completeness. High precision reduces false results. High recall reduces missed cases. Precision Equation: Precision = TP / (TP + FP). Recall Equation: Recall = TP / (TP + FN).
F1-Score: F1-score is the balance between precision and recall. It gives a single performance score. F-measure is useful when the data is unbalanced. It balances correctness and completeness. A higher F-measure means better performance. It avoids relying on accuracy alone. F1-score is commonly used in evaluation. It gives a fair comparison. F1-Score Equation: F1-Score = 2 × (Precision × Recall) / (Precision + Recall).
Example: suppose we are given the following values: TP (True Positives) = 40, TN (True Negatives) = 50, FP (False Positives) = 10, FN (False Negatives) = 5. Now, let's calculate Precision, Recall, and F1-Score based on these values. Precision: Precision = TP / (TP + FP) = 40 / (40 + 10) = 40/50 = 0.8. Recall: Recall = TP / (TP + FN) = 40 / (40 + 5) = 40/45 = 0.8889. F1-Score: F1-Score = 2 × (Precision × Recall) / (Precision + Recall) = 2 × (0.8 × 0.8889) / (0.8 + 0.8889) = 2 × 0.7111 / 1.6889 = 0.8421. Final Results: Precision = 0.8, Recall = 0.8889, F1-Score = 0.8421.
ماڈل کی جانچ یہ چیک کرنے کا عمل ہے کہ مشین لرننگ ماڈل کتنا اچھا کام کرتا ہے۔ یہ ٹیسٹ ڈیٹا سے ماڈل کی پیش گوئیوں کے معیار کو ناپتا ہے جو تربیت کے دوران استعمال نہیں ہوا تھا۔ یہ ماڈل کی طاقتوں اور کمزوریوں کی نشاندہی کرنے میں مدد دیتا ہے۔ کارکردگی کے پیمانے وہ پیمانے ہیں جو یہ جانچنے کے لیے استعمال ہوتے ہیں کہ ماڈل کتنا اچھا کام کر رہا ہے۔ مسئلے کی قسم کے لحاظ سے مختلف پیمانے استعمال ہوتے ہیں، جن پر ذیل میں بحث ہے۔ کیا آپ جانتے ہیں؟ زیادہ درستگی والا ماڈل بھی بعض صورتوں میں غلط نتائج دے سکتا ہے۔ اسی لیے پریسیژن اور ریکال جیسے دیگر پیمانے استعمال ہوتے ہیں۔ مناسب جانچ ماڈل کی حقیقی کارکردگی سمجھنے میں مدد دیتی ہے۔
درستگی اور غلطی: درستگی دکھاتی ہے کہ کل پیش گوئیوں میں سے کتنی درست ہیں۔ یہ فیصد کے طور پر ناپی جاتی ہے۔ زیادہ درستگی کا مطلب بہتر کارکردگی ہے۔ غلطی غلط پیش گوئیاں دکھاتی ہے۔ غلطی کی شرح درستگی کی الٹ ہے۔ صرف درستگی بعض اوقات گمراہ کن ہو سکتی ہے۔ متوازن ڈیٹا بہتر درستگی کے نتائج دیتا ہے۔ غلطی کا تجزیہ غلطیاں ڈھونڈنے میں مدد دیتا ہے۔ دونوں پیمانے جانچ کے لیے اہم ہیں۔ درستگی کی مساوات ہے: Accuracy = (TP + TN) / (TP + TN + FP + FN)، جہاں TP (True Positives): درست طور پر پیش گوئی شدہ مثبت مثالوں کی تعداد؛ TN (True Negatives): درست طور پر پیش گوئی شدہ منفی مثالوں کی تعداد؛ FP (False Positives): غلط طور پر پیش گوئی شدہ مثبت مثالوں کی تعداد؛ FN (False Negatives): غلط طور پر پیش گوئی شدہ منفی مثالوں کی تعداد۔
پریسیژن اور ریکال: پریسیژن ناپتا ہے کہ پیش گوئی شدہ مثبت نتائج میں سے کتنے واقعی درست ہیں۔ ریکال ناپتا ہے کہ اصل مثبت کیسز میں سے کتنے درست طور پر پہچانے گئے۔ پریسیژن درستگی پر توجہ دیتا ہے، ریکال مکملیت پر۔ زیادہ پریسیژن غلط نتائج کم کرتا ہے۔ زیادہ ریکال چھوٹے ہوئے کیسز کم کرتا ہے۔ پریسیژن مساوات: Precision = TP / (TP + FP)۔ ریکال مساوات: Recall = TP / (TP + FN)۔
F1-اسکور: F1-اسکور پریسیژن اور ریکال کے درمیان توازن ہے۔ یہ ایک واحد کارکردگی اسکور دیتا ہے۔ F-measure اس وقت مفید ہے جب ڈیٹا غیر متوازن ہو۔ یہ درستگی اور مکملیت میں توازن رکھتا ہے۔ زیادہ F-measure کا مطلب بہتر کارکردگی ہے۔ یہ صرف درستگی پر انحصار سے بچاتا ہے۔ F1-اسکور جانچ میں عام طور پر استعمال ہوتا ہے۔ یہ منصفانہ موازنہ دیتا ہے۔ F1-اسکور مساوات: F1-Score = 2 × (Precision × Recall) / (Precision + Recall)۔
مثال: فرض کریں ہمیں درج ذیل قدریں دی گئی ہیں: TP (True Positives) = 40، TN (True Negatives) = 50، FP (False Positives) = 10، FN (False Negatives) = 5۔ اب ان قدروں کی بنیاد پر پریسیژن، ریکال اور F1-اسکور نکالتے ہیں۔ پریسیژن: Precision = TP / (TP + FP) = 40 / (40 + 10) = 40/50 = 0.8۔ ریکال: Recall = TP / (TP + FN) = 40 / (40 + 5) = 40/45 = 0.8889۔ F1-اسکور: F1-Score = 2 × (Precision × Recall) / (Precision + Recall) = 2 × (0.8 × 0.8889) / (0.8 + 0.8889) = 2 × 0.7111 / 1.6889 = 0.8421۔ حتمی نتائج: Precision = 0.8، Recall = 0.8889، F1-Score = 0.8421۔
Validation is used to check how well a model works on new data. It is done after training and testing to confirm model reliability. It prevents models from memorizing data. Validation supports fair evaluation. Model improvement uses feedback from validation results. Weak areas are identified and corrected. Validation is important before real use. Tidbit: validation checks how a model works on new data. It prevents overfitting. Model improvement uses tuning and adjustments. Good validation increases reliability. Strong models perform well in real conditions.
Validation Data Set Preparation: a validation dataset is separate from training and testing data that is used to check model performance. Validation data must be clean and accurate to represent real conditions. The model does not learn from validation data. Validation helps detect overfitting and improves evaluation. Balanced data gives better results. This step increases model confidence.
Model Robustness and Reliability: robustness means a model performs well in different situations. A reliable model gives consistent results. Robust models handle noise in data. They do not fail easily with small changes. Reliability is important for real-world use. Testing under different conditions checks robustness. Strong models maintain accuracy. Reliability builds trust in systems. Robust models are more useful.
Improving Models Using Hyperparameter Tuning: hyperparameter tuning adjusts model settings. These settings control learning behavior. It helps improve accuracy. It reduces errors in predictions. Parameters are tested with different values. Validation data guides tuning. Proper tuning improves performance. Poor tuning reduces effectiveness.
Simple Analogy — Adjusting the Volume of a Speaker: hyperparameter tuning is like adjusting the volume of a speaker. If the volume is too high, the sound becomes distorted and unclear. If the volume is too low, the sound cannot be heard properly. However, when the volume is set at the right level, the sound becomes clear and balanced. Similarly, in machine learning, if hyperparameters are not set properly, the model may perform poorly. The correct hyperparameter values help the model learn better and produce more accurate results.
توثیق یہ چیک کرنے کے لیے استعمال ہوتی ہے کہ ماڈل نئے ڈیٹا پر کتنا اچھا کام کرتا ہے۔ یہ تربیت اور ٹیسٹنگ کے بعد ماڈل کی قابل اعتمادیت کی تصدیق کے لیے کی جاتی ہے۔ یہ ماڈلز کو ڈیٹا رٹنے سے روکتی ہے۔ توثیق منصفانہ جانچ کی حمایت کرتی ہے۔ ماڈل کی بہتری توثیقی نتائج کے فیڈ بیک سے ہوتی ہے۔ کمزور علاقوں کی نشاندہی اور اصلاح کی جاتی ہے۔ حقیقی استعمال سے پہلے توثیق اہم ہے۔ دلچسپ بات: توثیق چیک کرتی ہے کہ ماڈل نئے ڈیٹا پر کیسے کام کرتا ہے۔ یہ اوور فٹنگ روکتی ہے۔ ماڈل کی بہتری ٹیوننگ اور ایڈجسٹمنٹ سے ہوتی ہے۔ اچھی توثیق قابل اعتمادیت بڑھاتی ہے۔ مضبوط ماڈلز حقیقی حالات میں اچھا کام کرتے ہیں۔
توثیقی ڈیٹا سیٹ کی تیاری: توثیقی ڈیٹا سیٹ ٹریننگ اور ٹیسٹنگ ڈیٹا سے الگ ہوتا ہے جو ماڈل کی کارکردگی چیک کرنے کے لیے استعمال ہوتا ہے۔ توثیقی ڈیٹا حقیقی حالات کی نمائندگی کے لیے صاف اور درست ہونا چاہیے۔ ماڈل توثیقی ڈیٹا سے نہیں سیکھتا۔ توثیق اوور فٹنگ ڈھونڈنے اور جانچ بہتر کرنے میں مدد دیتی ہے۔ متوازن ڈیٹا بہتر نتائج دیتا ہے۔ یہ مرحلہ ماڈل کا اعتماد بڑھاتا ہے۔
ماڈل کی مضبوطی اور قابل اعتمادیت: مضبوطی کا مطلب ہے کہ ماڈل مختلف صورتحال میں اچھا کام کرے۔ قابل اعتماد ماڈل مستقل نتائج دیتا ہے۔ مضبوط ماڈلز ڈیٹا میں شور سنبھال لیتے ہیں۔ وہ چھوٹی تبدیلیوں سے آسانی سے ناکام نہیں ہوتے۔ حقیقی دنیا کے استعمال کے لیے قابل اعتمادیت اہم ہے۔ مختلف حالات میں ٹیسٹنگ مضبوطی چیک کرتی ہے۔ مضبوط ماڈلز درستگی برقرار رکھتے ہیں۔ قابل اعتمادیت سسٹمز میں اعتماد بناتی ہے۔ مضبوط ماڈلز زیادہ مفید ہیں۔
ہائپر پیرامیٹر ٹیوننگ سے ماڈلز بہتر کرنا: ہائپر پیرامیٹر ٹیوننگ ماڈل کی سیٹنگز ایڈجسٹ کرتی ہے۔ یہ سیٹنگز لرننگ رویے کو کنٹرول کرتی ہیں۔ یہ درستگی بہتر کرنے میں مدد دیتی ہے۔ یہ پیش گوئیوں میں غلطیاں کم کرتی ہے۔ پیرامیٹرز مختلف قدروں سے جانچے جاتے ہیں۔ توثیقی ڈیٹا ٹیوننگ کی رہنمائی کرتا ہے۔ مناسب ٹیوننگ کارکردگی بہتر کرتی ہے۔ خراب ٹیوننگ مؤثریت کم کرتی ہے۔
سادہ مثال — اسپیکر کی آواز ایڈجسٹ کرنا: ہائپر پیرامیٹر ٹیوننگ اسپیکر کی آواز ایڈجسٹ کرنے جیسی ہے۔ اگر آواز بہت زیادہ ہو تو آواز بگڑ جاتی ہے اور غیر واضح ہو جاتی ہے۔ اگر آواز بہت کم ہو تو آواز ٹھیک سے سنی نہیں جا سکتی۔ تاہم جب آواز درست سطح پر سیٹ ہو تو آواز واضح اور متوازن ہو جاتی ہے۔ اسی طرح مشین لرننگ میں اگر ہائپر پیرامیٹرز ٹھیک سے سیٹ نہ ہوں تو ماڈل خراب کام کر سکتا ہے۔ درست ہائپر پیرامیٹر قدریں ماڈل کو بہتر سیکھنے اور زیادہ درست نتائج دینے میں مدد دیتی ہیں۔
Predictive modeling uses data to predict future outcomes. Machine learning models analyze past data patterns. These patterns help estimate what may happen next. Predictive models are used in many fields. They support planning and decision making. Predictions are based on probability. They do not always explain reasons. Understanding causality is also important. Both concepts are used together in analysis.
Predictive Outcomes in Machine Learning: predictive outcomes are results produced by a trained model. The model uses past data to make predictions. These outcomes estimate future values or events. Prediction accuracy depends on data quality. Good training improves predictions. For example, businesses use predictions for forecasting the market or product selling trends. Healthcare uses predictions for diagnosis. Predictions support better decisions.
Understanding Causality: causality explains why an event happens. It shows a cause-and-effect relationship. One factor directly influences another. Causality is important in scientific studies to understand real reasons behind events. Data alone may not show causality but experiments often identify causes. Causal understanding improves decisions and avoids false assumptions.
Difference Between Prediction and Causation: prediction estimates what may happen based on historical data. It focuses on forecasting outcomes, where the model uses past information to estimate future values or events. For example, a model may predict a student's final grade by analysing previous marks, attendance, and study hours. Similarly, a weather model may predict tomorrow's temperature by using past weather records. A model can make accurate predictions without necessarily understanding the underlying causes. This makes prediction useful in areas such as sales forecasting, stock trend analysis, disease risk prediction, and student performance estimation. Causation, on the other hand, explains why something happens by identifying cause-and-effect relationships between variables. It seeks to uncover the reasons behind events and how one factor directly influences another. For example, if regular study hours directly improve exam performance, then study time may be considered a cause of better grades. Similarly, if smoking directly increases the risk of lung disease, this shows a causal relationship. Understanding causality is important for decision-making because it helps avoid false assumptions and provides deeper insight into real-world problems.
پیش گوئی ماڈلنگ مستقبل کے نتائج کی پیش گوئی کے لیے ڈیٹا استعمال کرتی ہے۔ مشین لرننگ ماڈلز ماضی کے ڈیٹا پیٹرن کا تجزیہ کرتے ہیں۔ یہ پیٹرن اندازہ لگانے میں مدد دیتے ہیں کہ آگے کیا ہو سکتا ہے۔ پیش گوئی ماڈلز کئی شعبوں میں استعمال ہوتے ہیں۔ یہ منصوبہ بندی اور فیصلہ سازی کی حمایت کرتے ہیں۔ پیش گوئیاں امکان پر مبنی ہوتی ہیں۔ یہ ہمیشہ وجوہات نہیں بتاتیں۔ وجہ کو سمجھنا بھی اہم ہے۔ دونوں تصورات تجزیے میں ایک ساتھ استعمال ہوتے ہیں۔
مشین لرننگ میں پیش گوئی نتائج: پیش گوئی نتائج تربیت یافتہ ماڈل سے پیدا شدہ نتائج ہیں۔ ماڈل پیش گوئیاں کرنے کے لیے ماضی کا ڈیٹا استعمال کرتا ہے۔ یہ نتائج مستقبل کی قدروں یا واقعات کا اندازہ لگاتے ہیں۔ پیش گوئی کی درستگی ڈیٹا کے معیار پر منحصر ہے۔ اچھی تربیت پیش گوئیاں بہتر کرتی ہے۔ مثلاً کاروبار مارکیٹ یا مصنوعات کی فروخت کے رجحانات کی پیش گوئی کے لیے پیش گوئیاں استعمال کرتے ہیں۔ صحت تشخیص کے لیے پیش گوئیاں استعمال کرتی ہے۔ پیش گوئیاں بہتر فیصلوں کی حمایت کرتی ہیں۔
وجہ کو سمجھنا: وجہ بتاتی ہے کہ کوئی واقعہ کیوں ہوتا ہے۔ یہ وجہ اور اثر کا تعلق دکھاتی ہے۔ ایک عنصر دوسرے پر براہ راست اثر ڈالتا ہے۔ وجہ سائنسی مطالعات میں واقعات کے پیچھے حقیقی وجوہات سمجھنے کے لیے اہم ہے۔ صرف ڈیٹا وجہ نہیں دکھا سکتا لیکن تجربات اکثر وجوہات پہچان لیتے ہیں۔ وجہ کی سمجھ فیصلے بہتر کرتی ہے اور غلط مفروضوں سے بچاتی ہے۔
پیش گوئی اور وجہ میں فرق: پیش گوئی تاریخی ڈیٹا کی بنیاد پر اندازہ لگاتی ہے کہ کیا ہو سکتا ہے۔ یہ نتائج کی پیش گوئی پر توجہ دیتی ہے، جہاں ماڈل مستقبل کی قدروں یا واقعات کا اندازہ لگانے کے لیے ماضی کی معلومات استعمال کرتا ہے۔ مثلاً ایک ماڈل پچھلے نمبر، حاضری اور مطالعے کے گھنٹوں کا تجزیہ کر کے طالب علم کے حتمی گریڈ کی پیش گوئی کر سکتا ہے۔ اسی طرح موسمی ماڈل ماضی کے موسمی ریکارڈ استعمال کر کے کل کے درجہ حرارت کی پیش گوئی کر سکتا ہے۔ ایک ماڈل بنیادی وجوہات کو لازمی سمجھے بغیر درست پیش گوئیاں کر سکتا ہے۔ یہ پیش گوئی کو فروخت کی پیش گوئی، اسٹاک رجحان تجزیہ، بیماری کے خطرے کی پیش گوئی، اور طلبہ کی کارکردگی کے اندازے جیسے شعبوں میں مفید بناتا ہے۔ دوسری طرف وجہ بتاتی ہے کہ کچھ کیوں ہوتا ہے، متغیرات کے درمیان وجہ اور اثر کے تعلقات کی نشاندہی کر کے۔ یہ واقعات کے پیچھے وجوہات اور یہ کہ ایک عنصر دوسرے پر براہ راست کیسے اثر ڈالتا ہے، اسے دریافت کرنے کی کوشش کرتی ہے۔ مثلاً اگر باقاعدہ مطالعے کے گھنٹے براہ راست امتحانی کارکردگی بہتر کرتے ہیں، تو مطالعے کا وقت بہتر گریڈ کی وجہ سمجھا جا سکتا ہے۔ اسی طرح اگر تمباکو نوشی براہ راست پھیپھڑوں کی بیماری کا خطرہ بڑھاتی ہے، تو یہ وجہ کا تعلق دکھاتا ہے۔ فیصلہ سازی کے لیے وجہ کو سمجھنا اہم ہے کیونکہ یہ غلط مفروضوں سے بچنے میں مدد دیتا ہے اور حقیقی دنیا کے مسائل میں گہری بصیرت دیتا ہے۔
Machine learning uses different tools for data analysis and modeling. Tools help collect, process, and analyze data. Some tools are simple and beginner-friendly, while others support advanced machine learning tasks. Choosing the right tool is important. Each tool has specific strengths. Tools improve efficiency and accuracy and build strong foundations. These platforms support modern data science work. Machine learning tools and platforms include: Excel for data analysis; R for data science; Python and Jupyter notebooks for machine learning.
Using Excel for Data Analysis: Excel is widely used for basic data analysis by organizing the data in rows and columns. Excel supports sorting, filtering, and data visualization using charts. Charts help visualize data. Simple formulas perform calculations. Excel is easy to learn and is useful for small datasets. Beginners often start with Excel, and it supports early data understanding.
Introduction to R for Data Science: R is a programming language for data analysis that is widely used in research. It provides strong graphical tools to visualize data. R handles large datasets efficiently. Many packages support data science tasks. Learning R improves analytical skills that support machine learning basics.
Python and Jupyter Notebooks for Machine Learning: Python is a popular programming language for machine learning. It has many useful libraries such as Pandas, NumPy, and others. Python supports data analysis and modeling. Jupyter notebooks provide an interactive environment. Code and results appear together on Jupyter notebook. This helps learning and testing the code on an interactive Integrated Development Environment (IDE). Python supports advanced machine learning and is widely used in industry.
مشین لرننگ ڈیٹا تجزیہ اور ماڈلنگ کے لیے مختلف ٹولز استعمال کرتی ہے۔ ٹولز ڈیٹا اکٹھا کرنے، پروسیس کرنے اور تجزیہ کرنے میں مدد دیتے ہیں۔ کچھ ٹولز سادہ اور نئے سیکھنے والوں کے لیے موزوں ہیں، جبکہ دیگر جدید مشین لرننگ کاموں کی حمایت کرتے ہیں۔ درست ٹول چننا اہم ہے۔ ہر ٹول کی مخصوص طاقتیں ہیں۔ ٹولز مؤثریت اور درستگی بہتر کرتے ہیں اور مضبوط بنیادیں بناتے ہیں۔ یہ پلیٹ فارمز جدید ڈیٹا سائنس کام کی حمایت کرتے ہیں۔ مشین لرننگ ٹولز اور پلیٹ فارمز میں شامل ہیں: ڈیٹا تجزیے کے لیے Excel؛ ڈیٹا سائنس کے لیے R؛ مشین لرننگ کے لیے Python اور Jupyter نوٹ بکس۔
ڈیٹا تجزیے کے لیے Excel کا استعمال: Excel ڈیٹا کو قطاروں اور کالموں میں منظم کر کے بنیادی ڈیٹا تجزیے کے لیے بڑے پیمانے پر استعمال ہوتا ہے۔ Excel چارٹس سے ترتیب، فلٹرنگ اور ڈیٹا وژولائزیشن کی حمایت کرتا ہے۔ چارٹس ڈیٹا کو دیکھنے میں مدد دیتے ہیں۔ سادہ فارمولے حسابات کرتے ہیں۔ Excel سیکھنا آسان ہے اور چھوٹے ڈیٹا سیٹس کے لیے مفید ہے۔ نئے سیکھنے والے اکثر Excel سے شروع کرتے ہیں، اور یہ ابتدائی ڈیٹا سمجھ کی حمایت کرتا ہے۔
ڈیٹا سائنس کے لیے R کا تعارف: R ڈیٹا تجزیے کی ایک پروگرامنگ زبان ہے جو تحقیق میں بڑے پیمانے پر استعمال ہوتی ہے۔ یہ ڈیٹا دیکھنے کے لیے مضبوط گرافیکل ٹولز دیتی ہے۔ R بڑے ڈیٹا سیٹس مؤثر طریقے سے سنبھالتا ہے۔ کئی پیکجز ڈیٹا سائنس کاموں کی حمایت کرتے ہیں۔ R سیکھنا تجزیاتی مہارتیں بہتر کرتا ہے جو مشین لرننگ کی بنیادی باتوں کی حمایت کرتی ہیں۔
مشین لرننگ کے لیے Python اور Jupyter نوٹ بکس: Python مشین لرننگ کی ایک مقبول پروگرامنگ زبان ہے۔ اس میں Pandas، NumPy اور دیگر کئی مفید لائبریریز ہیں۔ Python ڈیٹا تجزیہ اور ماڈلنگ کی حمایت کرتا ہے۔ Jupyter نوٹ بکس ایک انٹرایکٹو ماحول دیتے ہیں۔ کوڈ اور نتائج Jupyter نوٹ بک میں ایک ساتھ ظاہر ہوتے ہیں۔ یہ انٹرایکٹو انٹیگریٹڈ ڈویلپمنٹ انوائرمنٹ (IDE) پر کوڈ سیکھنے اور جانچنے میں مدد دیتا ہے۔ Python جدید مشین لرننگ کی حمایت کرتا ہے اور صنعت میں بڑے پیمانے پر استعمال ہوتا ہے۔
Answer key (from the book): 1–B, 2–B, 3–C, 4–B, 5–C, 6–C, 7–B, 8–C, 9–B, 10–B.
Answer key (from the book): 1–B, 2–B, 3–C, 4–B, 5–C, 6–C, 7–B, 8–C, 9–B, 10–B.
Answer: (b) — Data science collects, analyzes, and uses data to find useful information.
Answer: (b) — Structured data is organized in a clear format, such as tables or spreadsheets.
Answer: (c) — Images, videos, emails, and audio do not follow a fixed format.
Answer: (b) — ML systems improve from experience without explicit programming.
Answer: (c) — Supervised learning trains on labeled data (input + correct output).
Answer: (c) — Reinforcement learning learns through experience, rewards, and penalties.
Answer: (b) — Feature engineering selects, modifies, and creates features for better learning.
Answer: (c) — Accuracy = correct predictions out of total predictions.
Answer: (b) — Training data teaches patterns; testing data checks performance on unseen data.
Answer: (b) — Python (with Pandas, NumPy) is widely used in industry for ML.
جوابی کلید (کتاب سے): 1–B، 2–B، 3–C، 4–B، 5–C، 6–C، 7–B، 8–C، 9–B، 10–B۔
1. Data science is mainly concerned with:
2. Data organised in rows and columns is called:
3. An example of unstructured data is:
4. Machine learning allows systems to:
5. The type of machine learning that uses labelled data is:
6. The machine learning method that learns through rewards and penalties is:
7. Feature engineering is used to:
8. The metric that measures the overall correctness of a model is:
9. Train-test split is used to:
10. A commonly used tool for machine learning and data analysis is:
1۔ ڈیٹا سائنس بنیادی طور پر متعلق ہے:
2۔ قطاروں اور کالموں میں منظم ڈیٹا کہلاتا ہے:
3۔ ان اسٹرکچرڈ ڈیٹا کی مثال ہے:
4۔ مشین لرننگ سسٹمز کو اجازت دیتی ہے:
5۔ لیبل شدہ ڈیٹا استعمال کرنے والی مشین لرننگ کی قسم ہے:
6۔ انعامات اور سزاؤں سے سیکھنے والی مشین لرننگ کا طریقہ ہے:
7۔ فیچر انجینئرنگ استعمال ہوتی ہے:
8۔ ماڈل کی مجموعی درستگی ناپنے والا پیمانہ ہے:
9۔ ٹرین-ٹیسٹ اسپلٹ استعمال ہوتا ہے:
10۔ مشین لرننگ اور ڈیٹا تجزیے کے لیے عام طور پر استعمال ہونے والا ٹول ہے:
1. What is data science?
Data science is a field that focuses on collecting, analyzing, and using data to find useful information. It converts raw data into meaningful knowledge, supports decision-making, and helps predict future trends; it is widely used in business, education, and healthcare.
2. What are the two main types of data?
Structured data (organized in a clear format — tables/spreadsheets with rows and columns, e.g. mark sheets and databases) and unstructured data (no fixed format — emails, images, audio, videos), which is difficult to analyze directly and needs special tools.
3. What is the difference between structured and unstructured data?
Structured data follows a clear, fixed format (rows and columns, easy to understand and analyze); unstructured data does not follow a fixed format (text, images, audio, video) and is difficult to analyze directly, requiring special tools. Modern systems use both.
4. Name two common data collection methods.
Any two: surveys, interviews, forms, sensors, online platforms (blogs, social websites). Manual collection uses human effort; automatic collection uses machines and software; data can be collected in real time or stored over time.
5. What is machine learning?
Machine learning is a subfield of Data Science that enables systems to improve from experience without explicit programming — analyzing patterns in data to make predictions or decisions, trained on large datasets, adapting and improving as new data arrives.
6. What is supervised learning?
Supervised machine learning uses labeled data for training — each data item has an input and a correct output, and the system learns by comparing its output with the correct answer (e.g. emails labelled spam/not spam, images labelled cat/dog). It is used for prediction tasks like spam detection and exam result prediction.
7. What is the purpose of feature selection in machine learning?
Features are input values used by the model; correct feature selection improves learning (features must be relevant to the problem, e.g. study hours when predicting marks), while unnecessary features can reduce accuracy. Target values (outputs to be predicted, e.g. marks) must be clearly defined.
8. What does accuracy measure in a model?
Accuracy shows how many predictions are correct out of the total predictions, measured as a percentage: Accuracy = (TP + TN) / (TP + TN + FP + FN). High accuracy means better performance, but accuracy alone may be misleading — hence precision, recall, and F1-score are also used.
9. What is the difference between prediction and causality?
Prediction estimates what may happen based on historical data (e.g. predicting a grade from past marks, attendance, study hours) without necessarily understanding causes. Causation explains why something happens through cause-and-effect relationships (e.g. regular study hours directly improving grades; smoking increasing lung disease risk) — avoiding false assumptions and giving deeper insight.
10. Name any one tool used for machine learning.
Any one: Python (with Pandas, NumPy, Jupyter notebooks — popular for ML, widely used in industry); R (data analysis, research, strong graphics); Excel (basic data analysis, rows/columns, charts, small datasets).
1. Explain the concept of data science and discuss its importance in modern applications.
Data science is the study of data to discover patterns and useful information: collecting data from different sources, cleaning and organizing it, analyzing it, and interpreting results carefully to answer questions using facts and data. It reduces guesswork in decision-making and turns data into knowledge that solves real-world problems. It is interdisciplinary — mathematics for numbers, statistics for analysis, computer science for tools and programming, domain knowledge for real problems, communication skills for clear results. Importance: supports decision-making in many areas of life, predicts future trends, and is widely used in business, education, and healthcare; modern technology depends heavily on it. Workflow: Data Collection (gathering & processing) → Data Analysis (exploring & cleaning) → Modeling (training & testing) → Decision Making (insights & actions), with a feedback loop.
2. Describe different types of data and explain various data sources and collection methods.
Types: structured data — organized in a clear format (tables, spreadsheets, rows and columns, easy to understand; e.g. mark sheets, databases); unstructured data — no fixed format (emails, images, audio, videos), difficult to analyze directly, needs special tools; modern systems use both. Data must be accurate and reliable — poor data leads to incorrect conclusions. Sources and methods: surveys, interviews, forms, sensors, online platforms (blogs, social websites); manual collection uses human effort, automatic collection uses machines and software; data can be collected in real time or stored over time; the method depends on the purpose of the analysis. Storage and management: files, databases, or cloud systems; proper storage protects from loss; management organizes and maintains data so it is easy to find and use; security and backups prevent loss and support long-term use.
3. Explain the concept of machine learning and describe its different mechanisms, including supervised, unsupervised, reinforcement, and rule-based learning.
Machine learning is a subfield of Data Science enabling systems to improve from experience without explicit programming, by analyzing patterns in data to make predictions or decisions; large datasets train models that adapt as new data arrives. Learning from data: past information improves decisions; the model studies relationships, errors reduce through repeated training, and models update continuously. Mechanisms: supervised — labeled data (input + correct output), e.g. spam/not spam emails, cat/dog images; used for prediction (spam detection, exam results). Unsupervised — unlabeled data, finds patterns without guidance, groups similar data into clusters; used for data exploration (customer grouping, clustering). Reinforcement — learns through experience with rewards/penalties (robot maze navigation, AlphaGo, autonomous cars, recommendation feedback), goal: maximize rewards. "Rule-based learning" in the question refers to the contrast with traditional programming: fixed rules written by programmers, output by following rules, changes requiring new code — as opposed to ML, which learns rules automatically from data and changes through new data.
4. Discuss the applications of machine learning in healthcare, business, education, and daily life.
Healthcare: analyzes medical data, supports disease detection and diagnosis — cancerous cells in medical images, early Alzheimer's/dementia signs, cardiovascular disease diagnosis — helping doctors plan better, more timely treatments. Business: understands customer behavior, predicts sales and market trends, inventory management, fraud detection in financial systems, chatbot customer service, product suggestions; marketing becomes more effective and decisions data-driven, improving profit and efficiency. Education: improves learning systems, tracks student performance to improve grades, personalized content, smarter attendance and assessment systems, better learning outcomes. Daily life: face recognition on phones, voice assistants understanding commands, personalized social media content, spam filtering, navigation route suggestions, video/music recommendations, smart devices making daily tasks easier and faster.
5. Explain the steps involved in building a machine learning model, including feature selection, feature engineering, and train-test split.
Steps (grade-prediction example): collect student data (attendance, quiz marks, assignment scores, study hours, previous exam results); clean and prepare it; select features — input values relevant to the problem (study hours), with the target value clearly defined (marks); feature engineering — improving data for better learning (selecting, modifying, creating features; cleaning and scaling; e.g. creating "study hours per day"); train-test split — divide data into training (teaches patterns) and testing (checks performance on unseen data) sets, commonly 80/20, which prevents overfitting; train the model (e.g. LinearRegression fit on X_train, y_train); test and evaluate (MSE — lower is better); plot actual points vs predicted line; improve as more data is gathered. Book example: hours studied vs exam scores, MSE 0.1484, equation Exam Score = 0.6552 × Hours Studied + 0.1466.
6. Describe model evaluation techniques and explain accuracy, precision, recall, and F1-score.
Model evaluation checks how well a model performs using test data not used in training, identifying strengths and weaknesses. Accuracy = (TP + TN)/(TP + TN + FP + FN) — proportion of correct predictions; error rate is its opposite; accuracy alone may mislead (especially with unbalanced data). Precision = TP/(TP + FP) — how many predicted positives are actually correct (correctness; high precision reduces false results). Recall = TP/(TP + FN) — how many actual positives are correctly identified (completeness; high recall reduces missed cases). F1-score = 2 × (Precision × Recall)/(Precision + Recall) — balance of the two, a single score useful for unbalanced data, avoiding reliance on accuracy alone. Worked example (TP=40, TN=50, FP=10, FN=5): Precision = 40/50 = 0.8; Recall = 40/45 = 0.8889; F1 = 2 × 0.7111/1.6889 = 0.8421.
7. Explain validation in machine learning and discuss how models can be improved using parameter tuning.
Validation checks how well a model works on new data, done after training and testing to confirm reliability; it prevents models from memorizing data (overfitting) and supports fair evaluation. A validation dataset is separate from training and testing data, must be clean and accurate to represent real conditions, and the model does not learn from it; balanced data gives better results and increases confidence. Robustness and reliability: a robust model performs well in different situations, handles noise, does not fail easily with small changes, and gives consistent results — tested under different conditions; reliability builds trust. Hyperparameter tuning adjusts model settings that control learning behavior: parameters are tested with different values, guided by validation data; proper tuning improves accuracy and reduces prediction errors, poor tuning reduces effectiveness. Analogy: like adjusting a speaker's volume — too high distorts, too low cannot be heard, the right level is clear and balanced; likewise correct hyperparameters help the model learn better and produce more accurate results.
8. Discuss predictive modeling and causality, and explain the importance of model interpretation in real-world use cases.
Predictive modeling uses data to predict future outcomes: models analyze past data patterns to estimate what may happen next (based on probability), supporting planning and decision making — businesses forecasting markets/sales trends, healthcare predicting diagnosis. Predictions do not always explain reasons. Causality explains why an event happens through cause-and-effect relationships (one factor directly influencing another), identified often by experiments; e.g. regular study hours directly improving exam performance (study time as a cause of better grades), smoking increasing lung disease risk. Difference: prediction forecasts (grade from past marks/attendance/study hours; tomorrow's temperature from past records) and can be accurate without understanding causes; causation uncovers reasons. Importance of interpretation: understanding causality avoids false assumptions, gives deeper insight into real-world problems, and supports better, trustworthy decisions — prediction alone can mislead if a correlation is mistaken for a cause.
This chapter covers data science end to end: what data is, how machines learn, where ML is used, how to build a model, how to measure it with accuracy, precision, recall and F1, how to validate and improve it, and the difference between prediction and causation. Work the metrics example with numbers until it is fluent.
یہ باب data science کو شروع سے آخر تک cover کرتا ہے — data کیا ہے, machine کیسے سیکھتی ہے, ML کہاں استعمال ہوتا ہے, model کیسے بنتا ہے, accuracy, precision, recall اور F1 سے ناپنا, validate اور بہتر کرنا, اور prediction vs causation کا فرق. Metrics کی مثال numbers کے ساتھ اتنی practise کرو کہ روانی آ جائے.
Revision guidance: Revise in this order: (1) read each section and say its idea in one sentence, (2) cover the answers and redo all 20 MCQs, (3) write the 10 short answers from memory, then (4) plan — not just read — two long answers. Revisit any section whose figure you cannot explain without looking.
دہرائی کی رہنمائی: اس ترتیب سے revise کرو: (1) ہر section پڑھ کر اسکا idea ایک جملے میں بتاؤ, (2) جواب چھپا کر 20 MCQs دوبارہ حل کرو, (3) 10 short answers ذہن سے لکھو, پھر (4) دو long answers صرف پڑھنا نہیں, ان کا plan بناؤ. جس section کی figure بغیر دیکھے سمجہ نہ سکو, اسے دوبارہ پڑھو.
Chapter-wise tests, fresh random papers اور instant score کے لیے PunjabTest.com کا میں test section دیکھو:
PunjabTest.com — Complete Guide Book • FSc Part 2 Computer Science, Chapter 6 (New Book, Session 2026–27) • English + Urdu