This reading copy is protected. Use the official PDF download for offline access.
FUL BookBank
Browse Materials
Success BlogStudy strategy, exam preparation, academic recovery, fieldwork and career guides.
AchieversStudent excellence stories and academic success interviews.
Computing ₦100.00 PDF download
Download
DTS 201
INTRODUCTION TO DATA SCIENCE
Course Code: DTS 201
Course Title: Introduction to Data Science
Published by: Book Bank Team
Material: Book Bank Material

CHAPTER ONE

Fundamentals of Data Science

Key Terminology:

Term Meaning
Data Recorded facts, observations, measurements or representations that can be processed and analysed.
Information Data that has been processed, organized or interpreted so that it conveys meaning.
Data Science An interdisciplinary field concerned with extracting knowledge, insights and useful information from data using scientific, statistical, mathematical and computational methods.
Data Analytics The systematic examination of data to discover patterns, generate insights and support conclusions or decisions.
Statistics The discipline concerned with collecting, organizing, analysing, interpreting and communicating data.
Algorithm A finite sequence of well-defined instructions for solving a problem or performing a computational task.
Machine Learning A branch of computing and Artificial Intelligence concerned with methods that enable systems to learn patterns from data and use those patterns to make predictions or decisions.
Dataset An organized collection of related data, commonly represented as records, observations, variables or features.
Data Visualization The graphical or visual representation of data to make patterns, relationships, trends and comparisons easier to understand.

1.1 Meaning and Definition of Data Science

Data Science is an interdisciplinary field concerned with collecting, preparing, analysing, modelling, interpreting and communicating knowledge and insights from data using scientific, statistical, mathematical and computational methods.

The word interdisciplinary is particularly important in this definition. Data Science does not belong exclusively to one academic discipline. It brings together concepts and techniques from several areas, including statistics, mathematics, computer science, information systems, domain-specific knowledge and, increasingly, Artificial Intelligence and machine learning.

For example, suppose a university wants to understand the factors associated with student academic performance. The university may collect information about students' course registrations, examination scores, attendance, study patterns and other relevant variables. A Data Science approach would involve determining what data should be collected, preparing the data, examining statistical relationships, developing appropriate models, interpreting the results and communicating useful findings to university administrators.

In this example, statistics may be used to describe the data and determine whether relationships are statistically meaningful. Mathematics provides the foundations for many models and algorithms. Computer Science provides programming, algorithms, databases and computational infrastructure. Machine Learning may be used to develop predictive models. Knowledge of education helps ensure that the findings are interpreted appropriately within the university environment.

A Practical Definition:

In practical terms, Data Science can be understood as the disciplined process of turning data into useful knowledge for understanding, prediction and decision-making.

The process can be represented conceptually as:

Data → Preparation → Analysis → Modelling → Interpretation → Insight → Decision

This sequence should not be interpreted as a rigid process in which every project follows exactly the same order. Data Science projects are often iterative. A data scientist may discover during analysis that additional data is required, that the original question needs refinement or that the chosen model is inappropriate. The workflow may therefore move repeatedly between different stages.

1.2 What Is Data?

Data refers to recorded facts, measurements, observations, symbols or representations that can be stored and processed.

Data may take many forms. It can consist of numbers, text, dates, images, audio, video, sensor readings, geographical coordinates, transaction records or other digital representations.

Consider the following student records:

Student Age Study Hours/Week Score
A 20 12 74
B 22 8 61
C 19 15 82

The values in the table constitute data. By themselves, they are individual observations. When they are analysed, however, they may provide information about study behaviour and academic performance.

Example: If the university analyses the records of thousands of students and discovers that students who consistently study for more hours tend, on average, to obtain higher scores, that finding represents an insight derived from the data. It does not automatically prove that study hours alone cause higher scores, because other factors may also influence academic performance.

1.3 Data, Information, Knowledge and Insight

Students often use the terms data, information, knowledge and insight interchangeably. They are related, but they are not identical.

Data consists of recorded observations or values. Information is data that has been processed or organized so that it conveys meaning. Knowledge involves understanding relationships, principles or patterns revealed through information and experience. Insight refers to a useful understanding that can inform interpretation, action or decision-making.

Example: Individual sales transactions are data. A monthly sales report is information. Understanding that sales consistently increase during particular periods represents knowledge. Recognizing that increasing inventory before those periods could reduce stock shortages represents a potential business insight.

The distinction is important because the purpose of Data Science is not merely to store data. Its broader purpose is to use appropriate methods to obtain reliable and useful understanding from data.

1.4 Nature of Data Science

The nature of Data Science can be understood by examining the characteristics that distinguish it as an academic and professional field.

Interdisciplinary: Data Science combines knowledge from statistics, mathematics, computer science, domain-specific disciplines and other fields. A Data Scientist working in healthcare, for example, needs more than programming skills; an understanding of medical data and the context in which the data is generated is also important.

Data-driven: Data Science uses evidence contained in data to investigate questions and support decisions. The quality of the conclusions therefore depends heavily on the quality and relevance of the data.

Computational: Modern Data Science relies extensively on computational tools because many datasets are too large or complex to process manually. Programming, databases, algorithms and computational infrastructure are therefore important components of the discipline.

Statistical: Data Science relies on statistical concepts for summarizing data, measuring uncertainty, identifying relationships, estimating quantities and evaluating evidence.

Mathematical: Mathematics provides the theoretical foundation for many Data Science techniques, including linear algebra, probability, optimization and mathematical modelling.

Analytical: Data Science involves examining data to identify patterns, relationships, anomalies, trends and other structures that may answer a particular question.

Predictive: Some Data Science applications use historical data to develop models that estimate future or unknown outcomes. Examples include demand forecasting, risk estimation and predictive maintenance.

Communicative: Data Science does not end when a model produces a result. Findings must be communicated clearly through reports, visualizations, dashboards or other forms of presentation so that appropriate users can understand and act on them.

Iterative: Data Science projects commonly involve repeated refinement. Initial analysis may reveal missing data, poor assumptions, inappropriate variables or limitations in the original question.

1.5 Evolution of Data Science

Data Science did not emerge as a completely new discipline at one particular moment. It developed gradually from the convergence of several older fields and the increasing availability of digital data and computational power.

Early Statistical and Mathematical Foundations:

Long before the modern term Data Science became widely used, researchers used mathematics and statistics to collect, summarize and analyse information. Statistics developed methods for dealing with variation, uncertainty, sampling, estimation and inference.

Mathematical methods provided the foundations for probability, optimization, modelling and quantitative analysis. These ideas later became essential to computational data analysis.

Development of Electronic Computing:

The development of electronic computers transformed data processing. Tasks that previously required extensive manual calculation could increasingly be automated. Computers enabled researchers and organizations to process larger datasets and perform more complicated calculations.

The growth of programming languages, databases and statistical software further expanded the ability to work with data.

Growth of Databases and Information Systems:

As organizations adopted computerized information systems, large quantities of structured data began to accumulate. Banks, universities, hospitals, government agencies and businesses increasingly relied on databases to store and retrieve information.

This created a growing need for methods capable of extracting useful patterns and relationships from stored data.

Data Mining and Statistical Computing:

During the development of modern computing, researchers increasingly explored automated methods for discovering patterns in large datasets. Fields such as statistical computing, pattern recognition, machine learning and data mining contributed important techniques.

These developments helped establish the idea that computers could be used not only to store and retrieve information but also to discover patterns and support prediction.

The Emergence of the Modern Data Scientist:

The term Data Science became increasingly prominent as organizations began requiring professionals who could combine statistical reasoning, programming, data management, visualization and domain knowledge.

The modern Data Scientist therefore emerged as a professional who works across traditional disciplinary boundaries rather than remaining exclusively within statistics, computer science or business analysis.

Big Data and Modern Computing:

The growth of the Internet, social media, mobile devices, sensors, digital transactions and connected systems produced enormous volumes of data. This development is commonly associated with the Big Data era.

Modern Data Science increasingly deals with data that may be large in volume, generated rapidly, structurally diverse or distributed across multiple systems. Cloud computing, distributed processing and scalable databases have helped organizations manage such data.

Artificial Intelligence and Machine Learning:

Advances in machine learning and Artificial Intelligence have become increasingly important to Data Science. Modern Data Science projects may use machine learning models for classification, prediction, recommendation, anomaly detection, natural language processing and computer vision.

Recent advances in computing hardware, large datasets and machine learning methods have expanded the range of problems that can be approached computationally.

Important principle: The evolution of Data Science should not be understood as the replacement of statistics or mathematics by computers. Modern Data Science builds on these disciplines while adding computational methods, large-scale data management and advanced analytical techniques.

1.6 Major Stages in the Development of Data Science

Period/Stage Major Development Contribution to Data Science
Early quantitative analysis Development of mathematics, probability and statistics Provided methods for reasoning about data and uncertainty
Electronic computing Development of programmable computers Enabled large-scale automated computation
Database era Growth of computerized information systems Enabled systematic storage and retrieval of organizational data
Data mining era Automated discovery of patterns in large datasets Expanded computational approaches to data analysis
Big Data era Growth of high-volume, high-speed and diverse digital data Created demand for scalable storage and analysis
Modern Data Science Integration of statistics, computing, machine learning and domain knowledge Supports descriptive, predictive and increasingly automated decision systems

1.7 Scope of Data Science

The scope of Data Science refers to the range of activities, techniques, technologies and applications involved in obtaining useful knowledge from data.

Data Science encompasses much more than statistical analysis. A typical project may involve data collection, database management, data cleaning, exploratory analysis, visualization, statistical modelling, machine learning, evaluation, deployment and communication.

Data collection: Data may be obtained from databases, surveys, sensors, websites, transaction systems, experiments, applications, scientific instruments and other sources. The method of collection must be appropriate to the question being investigated.

Data management: Data must be stored, organized and retrieved efficiently. This may involve databases, data warehouses, cloud storage and distributed data systems.

Data cleaning: Real-world data frequently contains missing values, duplicate records, inconsistent formats, incorrect entries and other quality problems. Data cleaning seeks to identify and appropriately address these issues.

Exploratory Data Analysis: Exploratory analysis uses numerical summaries and visualizations to understand the structure of a dataset, identify patterns and detect unusual observations.

Statistical analysis: Statistical methods are used to summarize data, estimate quantities, test hypotheses, examine relationships and quantify uncertainty.

Machine learning: Machine learning methods can be used to build models for prediction, classification, clustering, recommendation and other tasks.

Data visualization: Graphs, charts, maps and dashboards help analysts and decision-makers understand complex information.

Communication: Results must be communicated accurately to technical and non-technical audiences. A technically correct analysis can have little practical value if its findings are poorly communicated.

Deployment and monitoring: When a Data Science model is used in a real system, it may need to be deployed, monitored and periodically updated. Changes in the underlying data can affect model performance over time.

1.8 The Data Science Lifecycle

A Data Science project can be viewed as a lifecycle consisting of interconnected stages. The exact terminology varies among organizations, but the following stages provide a useful general framework.

1. Define the Problem
Identify the question, objective and decision that the project is intended to support.
2. Collect Data
Obtain relevant data from appropriate sources.
3. Prepare Data
Clean, transform and organize the data for analysis.
4. Explore Data
Use statistics and visualization to understand patterns and relationships.
5. Model
Develop appropriate statistical or computational models when required.
6. Evaluate
Determine whether the analysis or model produces reliable results.
7. Communicate
Present findings clearly to the intended audience.
8. Deploy and Monitor
Put useful models or analytical outputs into practical use and monitor their performance.

These stages are not necessarily completed only once. A project may return to an earlier stage when new information becomes available or when problems are discovered.

Example: A supermarket wants to predict demand for a product. The Data Science team must first define what “demand” means and what period should be predicted. It then collects historical sales data, cleans the records, explores seasonal patterns, develops a forecasting model, evaluates the predictions and communicates the results. If the model performs poorly because important variables were missing, the team may return to data collection or preparation.

1.9 Importance of Data Science

Data Science has become increasingly important because organizations generate and collect large quantities of data and require reliable methods for turning that data into useful knowledge.

Improved decision-making: Data Science can provide evidence that supports decisions rather than relying entirely on intuition or assumptions.

Prediction and forecasting: Data-driven models can be used to estimate future demand, identify potential risks, forecast sales and anticipate equipment failures.

Operational efficiency: Organizations can analyse processes to identify delays, waste, bottlenecks and opportunities for improvement.

Personalization: Data Science can help organizations tailor products, recommendations and services to different users based on observed patterns of behaviour.

Scientific discovery: Researchers use Data Science to analyse large datasets generated by experiments, simulations, sensors, medical studies and other scientific activities.

Risk management: Financial institutions, insurers and other organizations can use data-driven methods to identify and quantify certain forms of risk.

Healthcare improvement: Data Science can support medical research, disease surveillance, patient management, medical imaging and resource planning.

Public administration: Governments can analyse demographic, economic, transportation, health and other data to support planning and public service delivery.

Innovation: Data can reveal unmet needs, emerging trends and opportunities for developing new products and services.

1.10 Data Science in Different Fields

Field Examples of Data Science Applications
Healthcare Medical research, disease prediction, patient monitoring, medical imaging and hospital resource planning.
Banking and Finance Fraud detection, credit risk analysis, financial forecasting and customer analysis.
Education Student performance analysis, learning analytics, enrollment forecasting and educational research.
Manufacturing Predictive maintenance, quality control, process optimization and production forecasting.
Agriculture Crop monitoring, yield prediction, weather analysis, soil analysis and precision agriculture.
Transportation Traffic prediction, route optimization, demand forecasting and fleet management.
Retail Customer segmentation, recommendation systems, demand forecasting and inventory optimization.
Government Population analysis, public health monitoring, economic analysis and service planning.
Engineering Predictive maintenance, simulation, quality analysis, optimization and sensor-data analysis.
Sports Performance analysis, injury-risk analysis, player evaluation and tactical analysis.

1.11 Relationship Between Data Science and Statistics

Statistics is one of the foundational disciplines of Data Science. It provides methods for collecting, summarizing, analysing and interpreting data while accounting for variation and uncertainty.

Statistical thinking is important because data almost always contains variation. Two samples drawn from the same population may not be identical. Measurements may contain uncertainty, and observed relationships may occur for reasons other than the relationship initially suspected.

Data Scientists use statistical concepts such as descriptive statistics, probability, sampling, estimation, hypothesis testing, correlation, regression and experimental design.

Example: Suppose a company wants to determine whether a new advertising campaign is associated with increased sales. Simply observing that sales increased after the campaign does not necessarily prove that the campaign caused the increase. Statistical reasoning can help examine the evidence and consider alternative explanations.

Key idea: Statistics helps Data Science answer questions such as What happened? How much variation exists? How strong is the evidence? How uncertain is the conclusion?

1.12 Relationship Between Data Science and Mathematics

Mathematics provides much of the theoretical language used to formulate and understand Data Science methods.

Probability: Probability provides a framework for reasoning about uncertainty and random events.

Linear algebra: Vectors and matrices are fundamental to many Data Science and machine learning methods. Large datasets are often represented mathematically as matrices or related structures.

Calculus: Calculus is used in optimization and in understanding how mathematical functions change. Many machine learning algorithms rely on optimization procedures that use derivatives.

Optimization: Data Science frequently involves finding parameter values that minimize error or maximize an objective function.

Discrete mathematics: Concepts from discrete mathematics support algorithms, graphs, logic, combinatorics and computer science.

Mathematics therefore provides the theoretical foundation, while computational methods allow many mathematical procedures to be applied efficiently to large datasets.

1.13 Relationship Between Data Science and Computer Science

Computer Science is concerned with computation, algorithms, programming, computer systems, software and the principles underlying computational processes.

Data Science makes extensive use of Computer Science. Programming languages allow Data Scientists to manipulate and analyse data. Algorithms provide systematic methods for solving computational problems. Databases provide mechanisms for storing and retrieving data. Computer networks and cloud systems provide infrastructure for processing and sharing data.

However, Data Science and Computer Science are not identical disciplines.

Computer Science Data Science
Broadly studies computation and computational systems. Focuses strongly on extracting knowledge and insights from data.
Includes algorithms, operating systems, computer architecture, programming languages and networks. Includes data preparation, statistical analysis, modelling, visualization and machine learning.
May study systems that do not primarily involve data analysis. Uses computational systems extensively to solve data-related problems.

A student of Data Science therefore benefits greatly from Computer Science knowledge, particularly programming, algorithms, databases and computational thinking.

1.14 Relationship Between Data Science and Artificial Intelligence

Artificial Intelligence (AI) is a broad field concerned with developing computational systems capable of performing tasks that commonly require capabilities associated with human intelligence, such as learning, reasoning, perception, language processing and decision-making.

Data Science and AI overlap significantly, particularly through machine learning. Machine learning systems often require data for training, evaluation and improvement, while Data Science provides methods for preparing and analysing that data.

However, AI is not simply another name for Data Science.

Data Science may involve descriptive statistics, visualization, database analysis and statistical inference without using AI. Conversely, some AI systems may involve areas such as robotics, planning or knowledge representation that are not primarily Data Science activities.

Relationship: Data Science often provides the data, analytical processes and evaluation methods needed by machine learning systems, while AI and machine learning provide powerful computational techniques that can be used within Data Science projects.

1.15 Relationship Between Data Science and Data Analytics

Data Analytics refers broadly to the systematic examination of data to identify patterns, generate insights and support conclusions or decisions.

Data Analytics is therefore closely related to Data Science and may be considered an important component of Data Science practice. The distinction between the terms is not universally fixed, and organizations may use them differently.

In a broad academic sense, Data Science generally encompasses a wider range of activities, including data collection, data engineering, statistical analysis, machine learning, modelling, visualization and deployment. Data Analytics often focuses more directly on examining existing data to understand what happened, why it happened and what the data indicates.

Aspect Data Analytics Data Science
Primary emphasis Examining data to generate insights. Broader process of obtaining knowledge from data.
Methods Statistics, visualization, reporting and analytical techniques. Statistics, programming, machine learning, modelling, data engineering and visualization.
Typical questions What happened? Why did it happen? What happened? Why? What may happen? What should be done?

1.16 The Relationship Among the Major Disciplines

Data Science can be understood more clearly by viewing its relationship with the disciplines that contribute to it.

Data Science as a Multidisciplinary Field:

Statistics → uncertainty, inference, statistical reasoning

Mathematics → probability, linear algebra, calculus, optimization

Computer Science → programming, algorithms, databases, computing systems

Artificial Intelligence → machine learning, intelligent systems, prediction

Data Analytics → examination, interpretation and communication of data

↓

DATA SCIENCE

Domain knowledge + data + appropriate methods → useful knowledge and informed decisions

No single discipline completely defines Data Science. A successful Data Science project may require mathematical reasoning to formulate a model, statistical reasoning to quantify uncertainty, programming to implement the analysis, database technologies to manage the data, machine learning to build a predictive model and domain knowledge to interpret the results correctly.

1.17 A Simple Example of Data Science in Practice

Consider an online retail company that wants to reduce the number of customers who stop purchasing from the company.

Step 1 — Define the problem: The company defines customer retention as the outcome it wants to improve and establishes a measurable objective.

Step 2 — Collect data: The company gathers relevant records such as purchase history, frequency of purchases, customer interactions and subscription information.

Step 3 — Prepare the data: Duplicate records are removed, inconsistent values are corrected and relevant variables are selected.

Step 4 — Explore the data: Analysts examine customer behaviour using statistical summaries and visualizations.

Step 5 — Model: A suitable predictive model may be developed to estimate which customers are at higher risk of leaving.

Step 6 — Evaluate: The model is tested using appropriate evaluation procedures to determine whether its predictions are sufficiently reliable.

Step 7 — Communicate: The results are presented to management in a form that explains the major factors associated with customer retention.

Step 8 — Apply the findings: The organization may use the results to design appropriate customer-retention strategies.

This example demonstrates that Data Science is not simply the act of building a machine learning model. The model is only one component of a larger process.

1.18 Common Misconceptions About Data Science

1. “Data Science is just programming.” Programming is important, but Data Science also requires statistical reasoning, mathematical understanding, data management, communication and domain knowledge.

2. “Data Science is the same as Data Analytics.” The fields overlap substantially, but Data Science is generally used in a broader sense that includes activities such as modelling, machine learning, data engineering and computational methods.

3. “Every Data Science project must use Artificial Intelligence.” This is incorrect. A Data Science project may use descriptive statistics, visualization or statistical inference without using AI or machine learning.

4. “More data always produces better results.” Large quantities of poor-quality or irrelevant data do not necessarily produce useful results. Data quality, relevance, representativeness and appropriate analysis are critical.

5. “Correlation proves causation.” A statistical association between two variables does not by itself establish that one variable causes the other.

6. “A model is automatically correct because a computer produced it.” Computational output must be evaluated. Models can be based on poor data, inappropriate assumptions, biased samples or unsuitable methods.

7. “Data Science is only useful for technology companies.” Data Science has applications in healthcare, agriculture, education, manufacturing, banking, government, transportation, engineering, scientific research and many other areas.

1.19 Common Student Mistakes

Confusing data with information: Students should remember that raw observations and processed, meaningful results are related but conceptually different.

Equating Data Science with machine learning: Machine learning is an important tool within modern Data Science, but Data Science includes many activities that do not involve machine learning.

Ignoring data quality: A sophisticated analytical method cannot automatically correct fundamentally poor, irrelevant or biased data.

Focusing only on technical skills: Data Science also requires the ability to formulate questions, interpret results, understand context and communicate findings.

Assuming statistical relationships are causal: Students must distinguish between association and causation and understand that causal conclusions require appropriate evidence and study designs.

Believing that a model is the final product: A model is useful only when it addresses a meaningful problem and produces sufficiently reliable results for its intended application.

1.20 Key Points

  • Data Science is an interdisciplinary field concerned with extracting knowledge and useful insights from data.
  • Data Science combines statistics, mathematics, computer science, analytical methods, domain knowledge and increasingly machine learning and Artificial Intelligence.
  • Data may consist of numerical values, text, images, audio, video, sensor measurements and many other forms of recorded observations.
  • Data Science is broader than simply programming or using statistical software.
  • The field developed gradually from statistics, mathematics, computing, databases, data mining and machine learning.
  • Modern Data Science has been strongly influenced by the growth of digital data, cloud computing and advanced computational methods.
  • The Data Science lifecycle commonly involves problem definition, data collection, preparation, exploration, modelling, evaluation, communication and deployment.
  • Statistics provides methods for understanding variation, uncertainty and evidence.
  • Mathematics provides theoretical foundations for probability, linear algebra, calculus and optimization.
  • Computer Science provides programming, algorithms, databases and computational infrastructure.
  • Artificial Intelligence and machine learning provide computational techniques that can be used to learn patterns and make predictions from data.
  • Data Analytics is closely related to Data Science and is often regarded as an important component of broader Data Science practice.
  • Data Science has applications in healthcare, education, finance, agriculture, engineering, manufacturing, government, transportation, retail and scientific research.
  • Large quantities of data do not guarantee useful results; data quality, appropriate methods and sound interpretation are essential.

1.21 Chapter Summary

Data Science is an interdisciplinary field concerned with obtaining useful knowledge and insights from data through the application of scientific, statistical, mathematical and computational methods. It combines several areas of knowledge rather than belonging exclusively to one discipline.

The field has developed gradually from the foundations of mathematics and statistics, through the development of electronic computing, databases, statistical computing and data mining, to modern Big Data, cloud computing, machine learning and Artificial Intelligence. Its evolution reflects the increasing ability of humans and machines to collect, store, process and analyse data.

The scope of Data Science includes defining problems, collecting data, managing and cleaning data, exploratory analysis, statistical analysis, modelling, machine learning, visualization, communication, deployment and monitoring. These activities are often iterative rather than strictly linear.

Data Science is important because it can support evidence-based decision-making, prediction, risk management, operational improvement, scientific discovery and innovation. Its applications extend across virtually every major sector of modern society.

Statistics provides the tools for reasoning about data and uncertainty, while mathematics provides the theoretical foundations for many analytical and computational methods. Computer Science contributes programming, algorithms, databases and computational infrastructure. Artificial Intelligence and machine learning provide techniques for building systems that can learn patterns from data. Data Analytics focuses strongly on examining data to generate useful insights and is closely related to Data Science.

The central lesson of this chapter is that Data Science is much more than analysing numbers or writing computer programs. It is a systematic and multidisciplinary approach to transforming data into reliable knowledge that can help explain phenomena, make predictions and support informed decisions.

CHAPTER TWO

Data and Data Classification

2.1 Meaning of Data

The word data refers to facts, observations, measurements, records or representations collected about objects, people, events, processes or phenomena. In data science, data is the raw material from which patterns, relationships, predictions and insights can be obtained.

Data may consist of numbers, words, symbols, images, sounds, videos, locations, dates, sensor readings, transaction records or combinations of these forms.

Example:

Consider the following values recorded for five students:

72, 65, 81, 59, 90

These numbers are data. By themselves, they do not tell us exactly what they represent. If we know that they are examination scores, they become meaningful observations about student performance.

Data therefore does not necessarily mean numbers. A student's name, a photograph of a building, a recorded telephone conversation, a GPS location and a temperature reading are all forms of data.

Data in Data Science:

Within data science, data is generally collected and transformed through a sequence of activities. A simplified process can be represented as:

Data Collection
→
Data Preparation
→
Analysis
→
Insight
→
Decision

The quality of the final result depends substantially on the quality and suitability of the original data.

2.2 Data and Information

Although the terms data and information are sometimes used interchangeably in everyday communication, they have different meanings in information and data science contexts.

Data:

Data consists of recorded facts, observations or measurements. It may require processing, organisation or interpretation before it becomes useful for a particular purpose.

Information:

Information is data that has been processed, organised, summarised or interpreted so that it conveys meaning to a user.

Worked Example: From Data to Information:

Raw data: 45, 60, 72, 80, 91, 52, 68

Suppose these values represent examination scores.

Processing: We calculate the average score.

Calculation:

Average = (45 + 60 + 72 + 80 + 91 + 52 + 68) ÷ 7

Average = 468 ÷ 7 = 66.86

Information: The average examination score is approximately 66.86.

The individual scores constitute data, while the calculated average provides a more meaningful summary of the dataset.

Comparison Between Data and Information:

Data Information
Represents recorded facts or observations. Represents processed or interpreted data.
May have little meaning when viewed alone. Provides meaning and context.
Can be raw and unprocessed. Usually results from processing, organisation or interpretation.
May include numbers, text, images, sound and other representations. Is presented in a form useful for understanding or decision-making.

2.3 Importance of Data

Data has become a strategic resource in modern society. Governments, universities, hospitals, banks, manufacturers, retailers and technology companies rely on data to understand situations, monitor performance, identify problems and make decisions.

1. Decision-Making:

Data provides evidence that can support decisions. For example, a university can examine enrolment data to determine which programmes are experiencing increasing demand.

2. Prediction:

Historical data can be used to develop models that estimate future outcomes. For example, financial institutions may analyse historical transactions to identify unusual activity.

3. Performance Measurement:

Organisations can use data to measure performance against defined objectives. Sales records, production quantities, examination results and customer satisfaction scores are examples.

4. Scientific Research:

Scientific investigations depend on observations and measurements. Data allows researchers to test hypotheses, identify relationships and evaluate theories.

5. Business Intelligence:

Businesses analyse customer, sales, financial and operational data to understand markets and improve processes.

6. Automation and Artificial Intelligence:

Many modern artificial intelligence and machine learning systems require data for training, evaluation and operation. The quality and representativeness of the data can strongly influence model performance.

7. Monitoring and Control:

Sensors continuously generate data in areas such as manufacturing, transportation, environmental monitoring and healthcare. Such data can be used to detect changes and support timely intervention.

Important principle: Data is valuable only when it is appropriate for the intended purpose and can be interpreted correctly. A large quantity of poor-quality data does not automatically produce good decisions.

2.4 Sources of Data

Data can originate from people, organisations, machines, software systems, experiments, observations and publicly available resources. Understanding the source of data is important because the source influences its quality, reliability, scope and intended use.

2.4.1 Primary Data:

Primary data is data collected directly by a researcher or organisation for a specific purpose.

Common methods include:

  • questionnaires;
  • interviews;
  • direct observation;
  • experiments;
  • measurements using instruments;
  • surveys; and
  • sensors and monitoring devices.
Example: A researcher wants to determine the average daily internet usage of undergraduate students at a university. The researcher distributes a questionnaire to selected students and collects their responses. The resulting responses constitute primary data.

2.4.2 Secondary Data:

Secondary data is data that was previously collected by another person, organisation or system and is subsequently used for another purpose.

Examples include:

  • government statistical publications;
  • research papers and published datasets;
  • company records;
  • historical databases;
  • public data portals;
  • institutional reports;
  • financial records; and
  • archived datasets.
Example: A student studying population growth uses population figures published by a national statistical agency. Because the student did not personally collect the population data, it is secondary data for that study.

2.4.3 Human-Generated Data:

This refers to data generated directly through human activity. Examples include social media posts, survey responses, written documents, customer reviews, emails and transaction records.

2.4.4 Machine-Generated Data:

Machine-generated data is produced automatically by devices, software systems or sensors.

Examples include:

  • temperature measurements from sensors;
  • GPS coordinates from mobile devices;
  • web server logs;
  • machine performance readings;
  • network traffic records; and
  • automatically generated transaction logs.

2.4.5 Public and Open Data:

Some organisations make datasets available to the public for research, analysis, transparency or innovation. Such datasets may come from government agencies, scientific institutions, international organisations or other providers.

However, publicly accessible data should not automatically be assumed to be accurate or suitable. A data scientist must examine its source, definitions, collection methods, coverage, quality and licensing conditions.

2.5 Structured Data

Structured data is data organised according to a predefined structure. It commonly appears in rows and columns, with each column representing a particular attribute and each row representing a record or observation.

Relational database tables are a common example of structured data.

Student ID Name Age Programme Score
ST001 Amina 21 Computer Science 78
ST002 David 23 Data Science 84
ST003 Grace 20 Mathematics 69

In this table, each row represents a student record. Each column represents an attribute of the student.

Characteristics of Structured Data:

  • It follows a predefined schema or organisational structure.
  • Fields and records can be clearly identified.
  • It is usually easy to store in relational databases.
  • It can be queried efficiently using database systems.
  • Data types can often be specified for individual fields.
  • It is generally convenient for statistical and computational analysis.

Examples of Structured Data:

  • student registration records;
  • bank transaction tables;
  • employee payroll records;
  • inventory databases;
  • customer databases;
  • sales records; and
  • examination results.

Advantages:

Structured data is relatively easy to store, search, sort, filter and analyse. Because its structure is predefined, software systems can efficiently process individual fields and records.

Limitations:

Strict structures may be unsuitable for information that does not naturally fit into predefined fields. Photographs, videos, free-form text and complex documents cannot always be represented efficiently using a simple relational table.

2.6 Semi-Structured Data

Semi-structured data is data that does not conform to a rigid relational table structure but contains organisational features that provide information about its elements and relationships.

Such organisational features may include tags, keys, attributes, labels or metadata.

Example: JSON:

{
  "student_id": "ST001",
  "name": "Amina",
  "age": 21,
  "programme": "Data Science",
  "courses": [
    "DTS 201",
    "MAT 201"
  ]
}

The example does not look like a conventional database table, but the keys such as student_id, name, age and programme provide structure that allows software to interpret the information.

Examples of Semi-Structured Data:

  • JSON documents;
  • XML documents;
  • HTML documents;
  • emails containing headers and message bodies;
  • application programming interface responses;
  • log files with identifiable fields; and
  • some forms of document metadata.

Characteristics:

  • It has some organisational structure but does not necessarily follow a fixed table.
  • Different records may contain different fields.
  • Tags, keys or metadata can describe individual elements.
  • It is commonly encountered in web and software systems.
  • It is often more flexible than rigidly structured relational data.
Important distinction: Semi-structured data is not simply "messy structured data." Its defining characteristic is that it contains some organisational information, even though it does not conform to a rigid tabular schema.

2.7 Unstructured Data

Unstructured data refers to data that does not have a predefined tabular or rigid organisational structure that can be easily represented using conventional database fields.

A large proportion of modern digital information exists in forms that are unstructured or contain substantial unstructured components.

Examples:

  • photographs;
  • video recordings;
  • audio recordings;
  • free-form text documents;
  • social media posts;
  • emails and messages;
  • scanned documents;
  • medical images;
  • satellite imagery; and
  • customer reviews written in natural language.

Consider a photograph taken by a smartphone. The image itself is not naturally organised as a table of student IDs, names and scores. Nevertheless, the photograph may contain valuable information. A data scientist may use computer vision techniques to analyse it.

Characteristics of Unstructured Data:

  • It does not naturally conform to a fixed table.
  • Its content may be highly variable.
  • It often requires specialised processing techniques.
  • Natural language processing can be used for textual data.
  • Computer vision techniques can be applied to images and videos.
  • Speech and audio processing techniques can be applied to sound recordings.

Why Unstructured Data Matters in Data Science:

Traditional database techniques are highly effective for structured data, but many modern analytical problems involve text, images, audio and video. Consequently, data science uses techniques such as natural language processing, machine learning, computer vision and deep learning to extract useful information from unstructured sources.

2.8 Comparing Structured, Semi-Structured and Unstructured Data

Feature Structured Semi-Structured Unstructured
Organisation Highly organised Partially organised No predefined rigid structure
Schema Usually predefined Flexible or partially defined Generally absent
Common representation Rows and columns Keys, tags, attributes Documents, images, audio, video
Examples SQL tables, spreadsheets JSON, XML, HTML Images, videos, free-form text
Typical processing Database queries and statistical analysis Parsing and specialised processing NLP, computer vision, audio processing and machine learning

2.9 Qualitative Data

Qualitative data describes qualities, characteristics, categories, opinions, perceptions or attributes rather than quantities expressed primarily as numerical measurements.

Qualitative data is often used when the objective is to understand what kind, which category, what people think or how something is described.

Examples:

  • gender category;
  • blood group;
  • marital status;
  • type of occupation;
  • customer opinion;
  • colour of a product;
  • type of vehicle;
  • student's programme; and
  • description of a patient's symptoms.

For example, suppose a survey asks students to state their preferred programming language. Responses such as Python, Java, C++ and JavaScript are qualitative categorical data.

Qualitative Does Not Mean "Unimportant":

A common mistake is to assume that qualitative data is less useful because it is not primarily numerical. This is incorrect. Qualitative information can provide essential context that numerical measurements alone cannot provide.

For example, a customer satisfaction score of 3 out of 5 gives a numerical measurement, but a written response explaining that the customer experienced delayed delivery may provide the reason behind the score.

2.10 Types of Qualitative Data

2.10.1 Nominal Data:

Nominal data consists of categories that have names or labels but no inherent ranking.

Examples include:

  • blood group: A, B, AB, O;
  • colour: red, blue, green;
  • department: Engineering, Medicine, Law;
  • religion categories;
  • country of residence; and
  • type of vehicle.

There is no meaningful mathematical ordering between the categories. For example, it would not make sense to say that blood group A is greater than blood group B.

2.10.2 Ordinal Data:

Ordinal data consists of categories that can be arranged in a meaningful order or rank, although the numerical distance between categories may not be known or equal.

Examples include:

  • poor, fair, good, very good, excellent;
  • low, medium, high;
  • first, second, third;
  • strongly disagree to strongly agree; and
  • small, medium, large.
Important distinction: Ordinal categories have an order, but the difference between adjacent categories cannot automatically be assumed to be equal.

2.11 Quantitative Data

Quantitative data represents quantities and is expressed using numerical values. It can generally be counted or measured.

Examples include:

  • age;
  • height;
  • weight;
  • temperature;
  • income;
  • number of students;
  • examination score;
  • distance travelled;
  • electricity consumption; and
  • number of products sold.

Quantitative data allows mathematical operations and statistical techniques to be applied, although the appropriate operations depend on the nature and measurement scale of the variable.

Example:

Suppose the number of books borrowed by five students in one month is:

2, 5, 3, 7, 4

These values represent counts and therefore constitute quantitative data.

2.12 Discrete and Continuous Data

Quantitative data can be further divided into discrete and continuous data.

2.12.1 Discrete Data:

Discrete data consists of countable values. It commonly arises from counting objects or events.

Examples include:

  • number of students in a classroom;
  • number of cars in a parking lot;
  • number of defects in a product batch;
  • number of books in a library;
  • number of customer complaints; and
  • number of computers in a laboratory.

A classroom may contain 40 students, but normally it would not contain 40.6 students. The number of students is therefore discrete.

2.12.2 Continuous Data:

Continuous data can take any value within a range, depending on the precision of measurement.

Examples include:

  • height;
  • weight;
  • temperature;
  • time;
  • distance;
  • pressure;
  • voltage; and
  • speed.

A person's height may be recorded as 1.70 m, 1.705 m or 1.7048 m, depending on the measuring instrument and required precision.

Rule of thumb: If the value results primarily from counting, it is usually discrete. If it results from measurement and can theoretically take intermediate values, it is usually continuous.

2.13 Comparison of Qualitative and Quantitative Data

Feature Qualitative Data Quantitative Data
Nature Descriptive or categorical Numerical or measurable
Typical question What type? Which category? What opinion? How many? How much? How large?
Examples Colour, occupation, opinion Age, height, income, score
Common subdivisions Nominal and ordinal Discrete and continuous
Common analysis Categorisation, frequency analysis and qualitative interpretation Statistical and mathematical analysis

2.14 A Variable Can Be Classified in More Than One Way

Students sometimes assume that a variable must belong to only one category. In data science, however, different classification systems describe different properties of the same data.

For example, consider the variable age.

  • It is quantitative because it represents a numerical quantity.
  • It can be continuous when recorded with sufficient measurement precision.
  • It can be represented in a structured dataset as a numerical column.

Now consider student programme.

  • It is qualitative because it represents categories.
  • It is usually nominal because programmes do not have an inherent numerical ranking.
  • It can still appear in a structured database table.

This illustrates an important principle: data classification depends on the property being considered. Structure classification and statistical classification are not the same thing.

Variable Qualitative/Quantitative Further Classification Possible Structure
Age Quantitative Continuous Structured
Number of children Quantitative Discrete Structured
Blood group Qualitative Nominal Structured
Satisfaction level Qualitative Ordinal Structured or semi-structured
Customer review Qualitative Textual Unstructured
Photograph Not normally classified as qualitative/quantitative in the same simple variable sense Image data Unstructured

2.15 Data Classification in a Data Science Workflow

Classification is not merely an academic exercise. It influences the techniques used throughout a data science project.

Data Type → Storage → Preparation → Analysis → Visualisation:

The nature of data helps determine how it should be stored, cleaned, transformed, analysed and communicated.

Example: University Student Dataset:

Suppose a university has the following fields:

Variable Example Value Classification
Student ID DTS001 Categorical identifier; structured
Age 21 Quantitative; potentially continuous
Programme Data Science Qualitative; nominal
Number of courses 6 Quantitative; discrete
Average score 74.5 Quantitative; continuous
Student comment “The laboratory facilities are good.” Qualitative text; potentially unstructured

A single project can therefore contain several types of data simultaneously. A data scientist must recognise these differences before choosing analytical methods.

2.16 Data Quality and Classification

Classification tells us what kind of data we have, but classification alone does not tell us whether the data is good. Data quality must also be considered.

Important dimensions of data quality include:

Accuracy:

Accuracy concerns whether the recorded value correctly represents the real-world value.

Completeness:

Completeness concerns whether required observations or fields are present.

Consistency:

Consistency concerns whether data follows compatible definitions and formats across records and systems.

Timeliness:

Timeliness concerns whether the data is sufficiently current for the intended purpose.

Validity:

Validity concerns whether data conforms to the rules or constraints that define acceptable values.

Example: A database may contain a student's age as 250 years. The value is numerical and therefore quantitative, but it is almost certainly invalid for a normal student record. Classification does not guarantee quality.

2.17 Common Mistakes and Misconceptions

Mistake 1: Assuming that all data is numerical:

Data can be numerical, textual, visual, auditory or represented in other digital forms. Names, photographs, videos and customer comments are also data.

Mistake 2: Assuming that a number is automatically quantitative:

Numbers can sometimes function as labels rather than quantities. For example, a student ID such as 20260125 is a numerical-looking identifier, but mathematical operations on student IDs are meaningless. It should be treated as an identifier rather than a measured quantity.

Mistake 3: Confusing structured data with quantitative data:

Structured and unstructured describe the organisation of data, whereas qualitative and quantitative describe the nature of variables or observations. A structured table can contain qualitative text such as names or departments.

Mistake 4: Assuming all text is unstructured:

Text can appear in structured data. For example, a database column containing student names is textual but may be part of a highly structured relational table.

Mistake 5: Treating ordinal values as equally spaced measurements:

If customer satisfaction is recorded as poor, fair, good and excellent, the categories have an order, but the numerical distance between them cannot automatically be assumed to be equal.

Mistake 6: Assuming public data is automatically reliable:

Public availability does not guarantee accuracy, completeness, representativeness or suitability. The source and methodology should be examined.

Mistake 7: Confusing discrete and continuous data:

The number of students is discrete because it is counted. Height is continuous because it is measured and can take intermediate values.

2.18 Practical Classification Examples

Example 1: Student Age:

Value: 22 years

Classification: Quantitative.

Further classification: Continuous when age is treated as a measured quantity rather than only an integer count of completed years.

Example 2: Number of Computers:

Value: 45 computers

Classification: Quantitative.

Further classification: Discrete because computers are counted.

Example 3: Department:

Value: Mechanical Engineering

Classification: Qualitative.

Further classification: Nominal because departments are categories without an inherent ranking.

Example 4: Satisfaction Rating:

Values: Poor, Fair, Good, Very Good, Excellent

Classification: Qualitative.

Further classification: Ordinal because the categories have an ordered relationship.

Example 5: Temperature:

Value: 28.6°C

Classification: Quantitative.

Further classification: Continuous because temperature is measured and can take intermediate values.

Example 6: Customer Review:

Value: “The product arrived quickly, but the packaging was damaged.”

Classification: Qualitative textual data.

Likely structure: Unstructured when stored as free-form text, although metadata associated with the review may be structured or semi-structured.

2.19 Key Points

  • Data consists of recorded facts, observations, measurements or representations that can be processed and analysed.
  • Information is data that has been processed, organised or interpreted to provide meaning.
  • Data is important for decision-making, prediction, research, performance measurement, automation and artificial intelligence.
  • Primary data is collected directly for a specific purpose, while secondary data was previously collected and is reused.
  • Structured data follows a predefined organisation, commonly rows and columns.
  • Semi-structured data has organisational features such as keys, tags or metadata without requiring a rigid tabular structure.
  • Unstructured data does not follow a predefined rigid structure and commonly includes text, images, audio and video.
  • Qualitative data describes categories, qualities, opinions and attributes.
  • Quantitative data represents quantities that can be counted or measured.
  • Qualitative data may be nominal or ordinal.
  • Quantitative data may be discrete or continuous.
  • A variable can be classified in more than one way because different classification systems describe different characteristics.
  • A numerical-looking value is not necessarily quantitative; identifiers may contain numbers without representing measurable quantities.
  • Data classification helps determine appropriate methods for storage, processing, analysis and visualisation.
  • Data classification should be distinguished from data quality. A dataset can be correctly classified but still contain inaccurate, incomplete or invalid values.

2.20 Chapter Summary

Data is the foundation of data science. It consists of facts, observations, measurements and representations collected about people, objects, processes and events. Data may exist in many forms, including numbers, text, images, audio, video and sensor readings. When data is processed and interpreted so that it conveys useful meaning, it becomes information.

Data can originate from many sources. Primary data is collected directly for a particular purpose, while secondary data is obtained from existing sources. Data may also be generated by humans or automatically by machines and software systems. Public and open datasets provide additional resources for research and analysis, but their quality and suitability must always be evaluated.

One important classification is based on the structure of data. Structured data follows a predefined organisation, such as rows and columns in a relational database. Semi-structured data does not follow a rigid table but contains organisational features such as keys, tags and metadata. Unstructured data lacks a predefined rigid structure and commonly includes free-form text, images, audio and video.

Another important classification distinguishes qualitative from quantitative data. Qualitative data represents categories, qualities and descriptions, while quantitative data represents numerical quantities. Qualitative data may be nominal or ordinal, whereas quantitative data may be discrete or continuous.

These classifications are fundamental to data science because the nature and structure of data influence how data should be stored, prepared, analysed and interpreted. A competent data scientist must therefore be able to identify the characteristics of a dataset before selecting appropriate analytical methods.

Core Idea to Remember

Data is not simply “numbers.” It is a broad collection of facts and representations. Understanding what the data represents, where it came from, how it is structured and what type of variable it contains is one of the first essential skills of a data scientist.

CHAPTER FOUR

The Data Science Lifecycle

4.1 What Is the Data Science Lifecycle?

The data science lifecycle is a structured framework for carrying out a data science project. It describes the major activities required to transform a real-world problem into a data-driven solution.

A simplified representation is:

Problem Definition → Data Acquisition → Data Preparation → Exploration → Analysis & Modelling → Evaluation → Communication/Deployment

These stages should not be understood as isolated activities. They are interconnected. For example, exploratory analysis may reveal that important variables are missing, requiring the data scientist to return to the data acquisition stage. Similarly, model evaluation may show that the original problem definition needs to be reconsidered.

Important: A data science lifecycle is a framework for systematic problem solving, not a rigid sequence that must always be followed from beginning to end without repetition.

4.2 Stage One: Problem Definition

The first stage of a data science project is to understand and clearly define the problem. This stage is sometimes overlooked because attention is often focused on data, programming and machine learning. However, a technically sophisticated analysis can still be useless if it addresses the wrong problem.

Defining the Problem:

A problem should be expressed in terms that identify:

  • the situation or decision that requires attention;
  • the objective of the analysis;
  • the people or organization affected by the problem;
  • the information required to address it;
  • the expected outcome; and
  • constraints such as time, cost, data availability and privacy.

Example:

Suppose a university observes that many students withdraw from courses before completion.

A poorly defined problem might be:

“Analyse student data.”

A better problem definition would be:

“Identify factors associated with student withdrawal so that the university can identify students who may require academic support.”

The second statement provides a clear purpose for the data analysis and gives direction to subsequent stages.

4.3 Stage Two: Data Acquisition

Once the problem has been defined, appropriate data must be obtained. Data acquisition refers to the process of collecting or obtaining data required for analysis.

Data may originate from internal organizational systems, public databases, surveys, sensors, experiments, transaction records, websites, application programming interfaces (APIs), or other legitimate sources.

Common Sources of Data:

Source Example
Organizational records Sales transactions, student records, hospital records
Surveys Customer satisfaction questionnaires
Sensors Temperature, pressure and machine-performance measurements
Public datasets Government statistics and research datasets
Web and APIs Publicly available information retrieved through authorized interfaces

Data acquisition must also consider data quality, legality, privacy, security, consent and relevance. More data is not automatically better data. A large dataset that does not measure the phenomenon of interest may be less useful than a smaller, carefully collected dataset.

4.4 Stage Three: Data Preparation and Cleaning

Raw data is rarely ready for immediate analysis. It may contain missing values, duplicate records, inconsistent formats, typing errors, impossible values or irrelevant variables. Data preparation involves transforming the raw data into a form suitable for analysis.

Common Data Preparation Tasks:

  • removing duplicate records;
  • correcting inconsistent formats;
  • handling missing values;
  • identifying unusual or potentially erroneous observations;
  • converting variables into appropriate data types;
  • standardizing categorical values;
  • combining data from multiple sources; and
  • creating variables needed for analysis.

Example: Inconsistent Categories:

Consider a dataset containing the following values for gender:

Male, M, male, Female, F, female, M, Male

Although these values may represent only two categories, inconsistent labels can cause problems during analysis. A data preparation process may standardize them as:

Male, Male, Male, Female, Female, Female, Male, Male

The principle is simple: data should be made consistent without changing its meaning.

Common mistake: Cleaning data blindly can be dangerous. Removing unusual observations simply because they look different may eliminate genuine and important cases. A data scientist should investigate unusual observations before deciding how to treat them.

4.5 Stage Four: Exploratory Data Analysis

Exploratory Data Analysis (EDA) involves examining data systematically to understand its structure, distributions, relationships, patterns and unusual observations.

EDA helps the data scientist answer questions such as:

  • What variables are present?
  • How are numerical values distributed?
  • Are there missing observations?
  • Are there unusual values?
  • Do two variables appear to be related?
  • Are there important differences between groups?
  • Are there patterns that require further investigation?

Common EDA Techniques:

  • frequency tables;
  • mean, median and mode;
  • range and measures of variability;
  • histograms;
  • bar charts;
  • box plots;
  • scatter plots; and
  • correlation analysis.

Example:

Suppose a university records the examination scores of ten students:

42, 55, 61, 63, 68, 70, 72, 75, 81, 93

A data scientist could calculate the average score, examine the distribution, identify unusually low or high scores, and compare the results with other variables such as attendance or previous academic performance.

EDA does not necessarily provide the final answer to a problem. Instead, it helps the data scientist understand what the data contains and determines which analytical approaches may be appropriate.

4.6 Stage Five: Analysis and Modelling

After understanding the data, the data scientist may apply statistical techniques, mathematical methods or computational models to answer the research or business question.

The appropriate method depends on the objective and the nature of the data.

Purpose Typical Approach Example
Description Descriptive statistics and visualization Summarizing monthly sales
Prediction Regression or machine-learning models Predicting future demand
Classification Classification algorithms Classifying a transaction as potentially fraudulent
Grouping Clustering methods Grouping customers according to purchasing behaviour

A model is not valuable merely because it is mathematically sophisticated. It must be appropriate to the problem, supported by suitable data, evaluated properly and interpretable enough for its intended use.

4.7 Training and Testing in Predictive Modelling

When a dataset is used to develop a predictive model, it is important to determine whether the model can perform well on data that it has not previously seen.

A common approach is to divide the available data into separate portions, such as:

  • Training data: used to develop or fit the model.
  • Validation data: may be used to select or tune model settings during development.
  • Test data: used to provide an independent assessment of the final model.

The exact strategy depends on the problem, the amount of data available and the modelling method.

Why Is This Necessary?:

Suppose a model is developed using examination records from 1,000 students. If the model is evaluated only on those same records, a high level of performance does not necessarily mean that it will perform well for new students.

This problem is related to overfitting, where a model learns the training data too closely, including patterns that do not generalize well to new observations.

Key principle: A useful predictive model should generalize beyond the data used to develop it.

4.8 Stage Six: Model Evaluation

After a model has been developed, its performance must be evaluated using measures appropriate to the problem.

For example, a classification model may be evaluated using measures such as accuracy, precision, recall and related metrics. A regression model may be evaluated using measures such as mean absolute error or root mean squared error.

Evaluation should consider more than a single numerical score. A model may perform well overall but poorly for an important subgroup or under particular operating conditions.

Example:

Suppose a fraud-detection system classifies 1,000 financial transactions. If only a small number of transactions are fraudulent, a model that labels nearly every transaction as legitimate might achieve high overall accuracy while failing at the actual task of detecting fraud.

This demonstrates why the choice of evaluation metric must reflect the purpose of the model.

4.9 Stage Seven: Interpretation and Communication

Data science does not end when a model or statistical analysis has been completed. The results must be interpreted and communicated to the people who need to use them.

Effective communication should answer questions such as:

  • What was discovered?
  • How strong is the evidence?
  • What assumptions were made?
  • What are the limitations?
  • What action should be considered?
  • What uncertainty remains?

A technical analysis may contain sophisticated mathematical procedures, but the final communication should be understandable to its intended audience.

Example:

Instead of telling a university administrator:

“The classification model produced an F1-score of 0.81.”

the data scientist may need to explain:

“The model can identify students who may require additional academic support with reasonably strong performance, but its predictions should be reviewed alongside academic and contextual information.”

The numerical metric remains important, but its practical meaning must also be communicated.

4.10 Stage Eight: Deployment and Monitoring

When a data science solution is intended for operational use, it may need to be deployed. Deployment means making the model, analytical system or data product available within the environment where it will be used.

Examples include:

  • a fraud-detection model integrated into a banking system;
  • a recommendation system used by an online platform;
  • a demand-forecasting model used by a business;
  • a predictive-maintenance system connected to industrial equipment; or
  • a student-support system used by a university.

Deployment does not mean the project is permanently finished. Real-world data can change over time. Customer behaviour, economic conditions, technology and other factors may cause a model's performance to decline.

Consequently, deployed systems may require monitoring, maintenance, retraining and periodic evaluation.

4.11 The Iterative Nature of Data Science

Although the lifecycle is often presented as a sequence of stages, practical data science is usually iterative.

Define → Collect → Prepare → Explore → Model → Evaluate → Communicate → Improve

For example, during data preparation a data scientist may discover that an important variable was not collected. The team may therefore return to the acquisition stage.

Similarly, exploratory analysis may reveal that the original question is too broad. The problem may then need to be reformulated before modelling begins.

This iterative nature is one of the important characteristics that distinguishes practical data science from a simple sequence of computer operations.

4.12 An Integrated Example: Predicting Student Performance

Consider a university that wants to identify students who may be at risk of poor academic performance.

Step 1: Problem Definition:

The university defines the objective as identifying factors associated with academic performance and developing a system that can help identify students who may require additional support.

Step 2: Data Acquisition:

Relevant data might include previous examination scores, attendance, assignment completion, course registration information and other variables that can legitimately be used for the intended purpose.

Step 3: Data Preparation:

The data scientist checks for missing records, duplicate students, inconsistent formats and invalid values. Appropriate preprocessing is then performed.

Step 4: Exploration:

The data scientist examines distributions and relationships. For example, attendance may be compared with examination performance to determine whether an association appears in the available data.

Step 5: Modelling:

A suitable statistical or machine-learning model may be developed to estimate the probability that a student falls into a predefined performance category.

Step 6: Evaluation:

The model is evaluated using appropriate data and metrics. The team checks whether the model performs adequately and whether important groups are treated appropriately.

Step 7: Communication:

The results are presented to university administrators and academic-support personnel in a form that explains both the findings and their limitations.

Step 8: Deployment and Monitoring:

If the system is approved for operational use, it may be integrated into an appropriate university information system. Its performance should then be monitored over time.

Important interpretation: A predictive model should support human decision-making rather than automatically determine a student's academic future. Data-driven predictions are estimates and should be interpreted in their proper context.

4.13 Data Science Lifecycle and Data Quality

Data quality affects almost every stage of the data science lifecycle. Poor-quality data can produce misleading analyses and unreliable predictions.

Important dimensions of data quality include:

  • Accuracy: whether the data correctly represents what it is intended to represent.
  • Completeness: whether necessary information is present.
  • Consistency: whether the same information is represented in compatible ways.
  • Timeliness: whether the data is sufficiently current for its intended use.
  • Relevance: whether the data actually contributes to answering the problem.
  • Validity: whether values conform to the expected rules or formats.

These dimensions are important because a model cannot automatically turn fundamentally unsuitable data into reliable knowledge.

4.14 Ethical Considerations Throughout the Lifecycle

Ethical considerations should not be postponed until the final stage of a data science project. They should be considered from the beginning.

Important questions include:

  • Was the data obtained legitimately?
  • Was appropriate consent obtained where required?
  • Is sensitive information being handled responsibly?
  • Could the analysis produce unfair outcomes?
  • Are the conclusions supported by the evidence?
  • Are the limitations being communicated honestly?
  • Who is responsible for decisions made using the resulting system?

Ethical data science therefore involves not only technical competence but also responsible judgment.

4.15 Common Mistakes in the Data Science Lifecycle

Starting With the Model:

Choosing a machine-learning algorithm before clearly defining the problem can result in solving the wrong problem.

Ignoring Data Quality:

Analysis performed on inaccurate, incomplete or inconsistent data may produce misleading conclusions.

Confusing Correlation With Causation:

An observed relationship between two variables does not automatically demonstrate that one variable causes the other.

Ignoring Generalization:

A model that performs well on training data may perform poorly on new data.

Overlooking Communication:

A technically correct result has limited practical value if decision-makers cannot understand its meaning.

Ignoring Ethics:

Data should not be treated as an unrestricted resource. Privacy, fairness, security and responsible use must be considered.

4.16 Key Points

  • The data science lifecycle provides a structured approach to solving data-driven problems.
  • The major stages include problem definition, data acquisition, preparation, exploration, modelling, evaluation, communication and, where applicable, deployment.
  • Problem definition determines what the data science project is intended to accomplish.
  • Data acquisition involves obtaining appropriate and relevant data.
  • Data preparation addresses issues such as missing values, duplicates, inconsistent formats and invalid observations.
  • Exploratory data analysis helps reveal patterns, relationships, distributions and unusual observations.
  • Statistical and computational models can be used for description, prediction, classification and other analytical purposes.
  • Models must be evaluated using methods appropriate to their intended purpose.
  • A predictive model should be evaluated on data that provides evidence of its ability to generalize beyond its training data.
  • Communication is an essential part of data science because analytical findings must ultimately be understood and used.
  • Deployed data systems may require continuous monitoring and maintenance.
  • The data science lifecycle is iterative rather than strictly linear.
  • Data quality, privacy, fairness, security and ethical considerations should be addressed throughout the lifecycle.

4.17 Chapter Summary

The data science lifecycle describes the major activities involved in transforming a real-world problem into a data-driven solution. The process begins with a clearly defined problem and proceeds through data acquisition, preparation, exploration, analysis and modelling. The resulting models or findings must then be evaluated and communicated appropriately.

When a solution is intended for practical use, it may be deployed and monitored. Because real-world problems and data change over time, data science projects frequently require iteration between stages.

The lifecycle also demonstrates why data science is broader than programming or machine learning. Successful data science requires problem understanding, appropriate data, statistical reasoning, computational skills, critical interpretation, effective communication and responsible use of information.

The Lifecycle at a Glance:

Problem → Data → Preparation → Exploration → Analysis/Model → Evaluation → Communication → Deployment → Monitoring

The stages are connected and may be repeated whenever new evidence requires the data scientist to reconsider an earlier decision.

CHAPTER FOUR

The Data Science Process

4.1 The Data Science Lifecycle

The data science lifecycle is a structured framework for solving problems using data. Although different organizations and textbooks may use different names or numbers of stages, a typical data science project includes:

1
Problem Definition
2
Data Collection
3
Data Preparation
4
Analysis & Modelling
5
Evaluation & Interpretation
6
Communication

These stages should not be interpreted as completely independent. A data scientist may discover during analysis that the original question was poorly defined, that additional data are required, or that the selected model is unsuitable. The process then returns to an earlier stage.

Important idea: The data science lifecycle is iterative. Moving backward to an earlier stage is not necessarily a failure; it is often a normal part of producing a reliable solution.

4.2 Problem Definition

Every data science project should begin with a clearly defined problem. Before collecting data or selecting an algorithm, the data scientist must understand what decision, question or outcome the project is intended to address.

A poorly defined problem can lead to a technically sophisticated analysis that does not solve the actual organizational or scientific need.

Components of a Well-Defined Problem:

A useful problem definition normally identifies:

  • the problem: What needs to be understood, predicted or improved?
  • the objective: What should the analysis accomplish?
  • the target: What specific outcome is being investigated?
  • the stakeholders: Who will use the results?
  • the available resources: What data, computing resources and expertise are available?
  • the constraints: Are there limitations involving time, cost, privacy, regulation or data availability?
  • the success criteria: How will the success of the project be measured?

Example:

Consider a university that wants to identify students who may require additional academic support.

A vague problem statement would be:

Weak: “Use data science to improve student performance.”

A stronger formulation would be:

Better: “Develop a model that uses available academic and engagement data to identify students who are at increased risk of failing a course early enough for appropriate academic support to be considered.”

The second statement is more useful because it identifies the population, objective, approximate timing and intended application of the analysis.

4.3 Data Collection

Once the problem has been defined, the next task is to obtain data relevant to the problem. Data collection involves gathering observations, measurements, records or other forms of evidence from appropriate sources.

Common Sources of Data:

  • surveys and questionnaires;
  • administrative databases;
  • transaction records;
  • scientific experiments;
  • sensors and Internet of Things devices;
  • websites and publicly available datasets;
  • mobile and application logs;
  • government records;
  • business information systems; and
  • research databases.

Primary and Secondary Data:

Type Meaning Example
Primary data Data collected directly for the purpose of the investigation. A university conducting a survey of its students.
Secondary data Data originally collected by another person or organization and subsequently used for a different analysis. Using published government demographic data.

Data collection should consider not only quantity but also relevance, quality, reliability, completeness, representativeness and ethical suitability.

Practical principle: More data does not automatically mean better data. A large dataset containing systematic errors, missing values or irrelevant observations may be less useful than a smaller but carefully collected dataset.

4.4 Data Preparation

Raw data rarely arrive in a form that can immediately be analysed. Data preparation involves organizing, combining, inspecting and transforming collected data into a usable analytical dataset.

For example, a business may store customer information in one database, purchase records in another system and marketing information in a spreadsheet. Before analysis, these sources may need to be integrated.

Common Data Preparation Activities:

  • identifying relevant variables;
  • combining data from multiple sources;
  • checking data types;
  • organizing records and variables;
  • removing duplicate observations;
  • identifying missing values;
  • checking for inconsistent entries;
  • standardizing formats and units; and
  • documenting the meaning and origin of variables.

Example:

Suppose a dataset records Nigerian phone numbers in several formats:

  • 08031234567
  • +2348031234567
  • 234-803-123-4567

Although these values may represent the same underlying information, inconsistent formatting can create problems when the data are analysed or joined with another dataset. Data preparation may therefore involve converting them into a consistent representation.

4.5 Data Preprocessing

Data preprocessing is the systematic transformation of data to improve its suitability for statistical analysis or machine-learning algorithms.

Preprocessing is particularly important because algorithms operate on the data supplied to them. Poor-quality input can lead to misleading models and conclusions.

Major Preprocessing Activities:

Handling Missing Values:

A missing value occurs when an expected observation is unavailable. Missing data may be represented by blanks, NULL, NA or other markers.

Possible approaches include:

  • removing observations when appropriate;
  • removing variables with excessive missingness;
  • replacing missing numerical values using suitable estimates such as a mean or median; and
  • using more advanced imputation methods where justified.

The appropriate method depends on why the data are missing and how the variable is used.

Removing Duplicates:

Duplicate records may occur when information is entered more than once or when datasets are combined. Unrecognized duplicates can distort counts, averages and model training.

Handling Outliers:

An outlier is an observation that is unusually distant from other observations. Outliers should not automatically be deleted. An extreme observation may represent either an error or a genuine event.

For example, a recorded human age of 250 years is likely to be a data-entry error, whereas a legitimate transaction that is ten times larger than typical transactions may represent a genuine business event.

Transformation and Scaling:

Some algorithms perform better when numerical variables are placed on comparable scales. Common transformations include normalization and standardization.

For standardization, a value can be transformed using:

z = (x − μ) / σ

where x is the observed value, μ is the mean and σ is the standard deviation.

Example: If a student's score is 80, the mean score is 70 and the standard deviation is 5:

z = (80 − 70) / 5 = 10 / 5 = 2

The student's score is therefore 2 standard deviations above the mean.

Encoding Categorical Data:

Many machine-learning algorithms require numerical representations. Categorical values such as Male/Female, Urban/Rural or Yes/No may therefore need to be encoded appropriately.

4.6 Data Analysis

Data analysis involves examining data to discover patterns, relationships, trends, differences and other forms of useful evidence.

Analysis may be descriptive, exploratory, statistical or predictive depending on the objective of the project.

Exploratory Data Analysis:

Exploratory Data Analysis (EDA) involves examining a dataset before or alongside formal modelling to understand its structure and identify important patterns or problems.

Common EDA activities include:

  • calculating summary statistics;
  • examining frequency distributions;
  • identifying missing values;
  • examining relationships between variables;
  • visualizing distributions;
  • detecting unusual observations; and
  • checking assumptions relevant to subsequent analysis.

Example:

Suppose a lecturer records the scores of ten students:

45, 52, 61, 61, 68, 72, 74, 80, 83, 94

The mean is:

Mean = (45 + 52 + 61 + 61 + 68 + 72 + 74 + 80 + 83 + 94) / 10

Mean = 690 / 10 = 69

The calculation provides a simple description of the centre of the observations. Further analysis could examine the spread, distribution and relationship between scores and other variables such as attendance.

4.7 Training and Model Development

When a data science project involves machine learning, a model must be developed using appropriate data. The model learns relationships or patterns from historical observations according to the selected learning method.

The dataset is commonly divided into separate subsets so that the model can be trained and evaluated properly.

Dataset Purpose
Training set Used to fit or train the model.
Validation set May be used to tune model choices and hyperparameters during development.
Testing set Used to provide an evaluation on data that were not used to fit the final model.

The precise division depends on the problem, dataset size and modelling method. A simple project might use a training and testing split, whereas a more rigorous project may use training, validation and testing datasets or cross-validation.

Important: A model should not be judged only by how well it performs on the same data used to train it. Evaluation on previously unseen data provides stronger evidence about its ability to generalize.

4.8 Testing and Evaluation

Testing involves evaluating the performance of a developed model or analytical solution using appropriate data that were not used to fit the model.

The evaluation measure depends on the type of problem.

Problem Type Possible Evaluation Measures
Classification Accuracy, precision, recall, F1-score and other appropriate measures.
Regression Mean absolute error, mean squared error, root mean squared error and related measures.
Clustering Appropriate cluster-quality measures and domain-specific evaluation.

Evaluation should also consider the original purpose of the project. A model with a high numerical performance score may still be unsuitable if it is too expensive, too slow, difficult to interpret, unfair to relevant groups or inappropriate for the intended application.

4.9 Interpretation of Results

Obtaining a numerical result is not the same as understanding what that result means. Interpretation connects analytical findings to the original problem.

For example, suppose a model predicts that a customer has a high probability of cancelling a subscription. The data scientist should investigate what factors contributed to the prediction and what the prediction means in the business context.

Interpretation may involve:

  • examining important variables or relationships;
  • considering uncertainty;
  • checking whether the result is consistent with domain knowledge;
  • identifying limitations;
  • distinguishing correlation from causation; and
  • determining whether the finding supports the intended decision.
Correlation is not automatically causation. If two variables change together, this does not by itself establish that one variable causes the other. Interpretation must consider the study design, alternative explanations and relevant domain knowledge.

4.10 Communication of Results

The final purpose of many data science projects is to support understanding or decision-making. Consequently, results must be communicated clearly to the people who will use them.

Effective communication should answer four basic questions:

  1. What was the problem?
  2. What did the analysis reveal?
  3. How reliable are the findings?
  4. What action or decision do the findings support?

Different audiences require different forms of communication. A technical audience may require information about model architecture, assumptions, variables and evaluation metrics. A business executive may need a concise explanation of the major findings, implications, risks and recommended actions.

Common Methods of Communication:

  • reports;
  • data visualizations;
  • dashboards;
  • presentations;
  • technical documentation;
  • research papers; and
  • interactive analytical applications.

A good visualization should make the important pattern easier to understand rather than merely decorate the report.

4.11 An Integrated Example of the Data Science Process

Consider a university that wants to understand factors associated with student withdrawal from courses.

Stage 1: Problem Definition:

The university defines the objective as identifying factors associated with course withdrawal and, where appropriate, developing a model that can identify students who may require early academic intervention.

Stage 2: Data Collection:

Relevant information may include course registration records, assessment results, attendance information, previous academic performance and other legitimately available variables.

Stage 3: Data Preparation:

The datasets are combined. Duplicate records are identified, variable names are standardized and the meaning of each variable is documented.

Stage 4: Data Preprocessing:

Missing values are investigated, categorical variables are appropriately encoded and numerical variables are transformed where necessary.

Stage 5: Analysis and Modelling:

Exploratory analysis is first conducted to identify patterns. If prediction is appropriate, a classification model may then be trained using historical observations.

Stage 6: Testing:

The model is evaluated using data that were not used for training. Appropriate performance measures are selected according to the nature of the prediction problem.

Stage 7: Interpretation:

The results are examined to determine which variables are associated with the predictions and whether the findings make sense in the educational context.

Stage 8: Communication:

The findings are presented to relevant university stakeholders using appropriate charts, tables and explanations. The limitations of the analysis are clearly stated.

If the results reveal that important information was missing, the data scientist may return to the collection stage. If the model performs poorly, the data preparation, feature selection or modelling stage may need to be reconsidered.

4.12 Why the Data Science Process Is Iterative

In a simple diagram, the data science process may appear to move from problem definition to data collection, analysis and communication in a straight line. In real projects, however, the process rarely behaves this way.

For example, a data scientist may discover during preprocessing that a critical variable contains too many missing values. This may require returning to the data collection stage.

Similarly, exploratory analysis may reveal that the original problem was based on an incorrect assumption. The problem may then need to be reformulated.

A model may also perform poorly during testing. The team may respond by obtaining additional data, engineering better features, selecting a different modelling technique or redefining the objective.

Iteration therefore allows the project to improve as new evidence is discovered.

Core principle: Data science is a process of continuous refinement. Each stage provides information that can improve decisions made at other stages.

4.13 Common Problems in the Data Science Process

Problem Possible Consequence
Poorly defined objective The project may produce results that do not solve the actual problem.
Irrelevant data Analysis may fail to provide useful evidence.
Poor data quality Results may be unreliable or misleading.
Data leakage Model performance may appear unrealistically high.
Overfitting A model may perform well on training data but poorly on unseen data.
Poor interpretation Correct analytical results may be misunderstood.
Poor communication Useful findings may fail to influence decisions.

4.14 Common Mistakes to Avoid

1. Starting with an algorithm instead of a problem: A data science project should begin with a meaningful problem rather than the desire to use a particular machine-learning algorithm.

2. Assuming raw data are ready for analysis: Real-world data commonly require preparation and preprocessing.

3. Removing every unusual observation: An outlier may be an error, but it may also represent an important genuine event.

4. Training and testing on the same observations: This can produce an overly optimistic assessment of model performance.

5. Ignoring the context of the data: Statistical patterns should be interpreted in relation to the real-world problem.

6. Confusing prediction with explanation: A model that predicts an outcome effectively does not necessarily establish why that outcome occurs.

7. Presenting results without limitations: Responsible data science requires clear communication of uncertainty, assumptions and limitations.

8. Treating the lifecycle as strictly linear: Data science projects frequently return to earlier stages when new information becomes available.

4.15 Key Points

  • The data science process provides a systematic approach to solving problems using data.
  • A typical lifecycle includes problem definition, data collection, preparation, preprocessing, analysis, modelling, testing, interpretation and communication.
  • Problem definition establishes what the project is intended to accomplish.
  • Data collection involves obtaining relevant and appropriate information.
  • Data preparation organizes raw information into a usable analytical structure.
  • Data preprocessing improves the suitability of data for analysis and modelling.
  • Exploratory data analysis helps reveal patterns, relationships, errors and unusual observations.
  • Training data are used to develop a model, while testing data are used to evaluate its performance on unseen observations.
  • Interpretation connects analytical results to the original real-world problem.
  • Effective communication allows stakeholders to understand and use data science findings.
  • The data science lifecycle is iterative rather than strictly linear.
  • Good data science requires attention to data quality, methodology, context, evaluation and communication.

4.16 Chapter Summary

The data science process is a structured but iterative approach to transforming data into useful knowledge and evidence for decision-making. It begins with a clear definition of the problem and proceeds through the acquisition and preparation of appropriate data.

Raw data must usually be cleaned, organized and transformed before meaningful analysis can be performed. Exploratory analysis helps the data scientist understand the structure and characteristics of the dataset, while statistical and machine-learning techniques may be applied where appropriate to answer questions or make predictions.

When machine learning is involved, training and testing must be separated appropriately so that model performance can be evaluated on data that were not used to fit the model. The resulting findings must then be interpreted in the context of the original problem.

Finally, results must be communicated clearly to the intended audience, including relevant evidence, implications and limitations. Because problems and datasets often become better understood during the investigation, the process may return to earlier stages several times.

The Data Science Process at a Glance:

Problem Definition → Data Collection → Data Preparation → Preprocessing → Analysis/Modelling → Testing → Interpretation → Communication

The arrows should not be understood as permanent one-way movement. Findings at any stage can require the data scientist to revisit an earlier stage and improve the solution.

CHAPTER FIVE

Data Collection and Preprocessing

5.1 Meaning and Importance of Data Collection

Data collection is the systematic process of obtaining observations, measurements, records, responses or other forms of data that are relevant to a particular question or problem.

In data science, collection begins with a clear understanding of what needs to be investigated. A researcher studying student performance, for example, may need examination scores, attendance records, study hours and demographic or institutional variables. Collecting unrelated information can increase cost and complexity without improving the analysis.

Good data collection therefore requires attention to:

  • the purpose of the investigation;
  • the population or group being studied;
  • the variables that need to be measured;
  • the source from which the data will be obtained;
  • the method used to obtain the data;
  • the period covered by the data;
  • ethical and privacy requirements; and
  • the expected quality and format of the resulting dataset.
Important Principle:

The purpose of data collection should determine what data are collected. Collecting more data does not automatically produce better data science.

5.2 Sources of Data

Data can be obtained from many sources. A useful distinction is between primary data and secondary data.

Primary Data:

Primary data are data collected directly for the specific investigation being conducted.

Examples include:

  • responses obtained through a questionnaire;
  • measurements obtained from laboratory experiments;
  • observations recorded by researchers;
  • interviews conducted with participants;
  • sensor readings collected from equipment; and
  • transaction records generated specifically for a study.

Advantage: The researcher can design the collection process around the objectives of the investigation.

Limitation: Primary data collection can require considerable time, money, planning and human resources.

Secondary Data:

Secondary data are data that already exist and were originally collected by another person, organization or system, or for another purpose.

Examples include:

  • government statistical publications;
  • institutional databases;
  • research datasets;
  • company records;
  • publicly available datasets;
  • historical archives;
  • scientific databases; and
  • data obtained through public application programming interfaces.

Secondary data can greatly reduce the time and cost of a project. However, the data scientist must determine whether the source is reliable, whether the variables are appropriate and whether the data are sufficiently current for the intended purpose.

Feature Primary Data Secondary Data
Purpose Collected for the current investigation Already collected for an existing purpose
Control Greater control over collection Limited control over how it was collected
Cost Often higher Often lower
Example Survey conducted by a researcher Published government dataset

5.3 Methods of Data Collection

Surveys and Questionnaires:

Surveys collect responses from individuals using structured questions. They are useful for collecting information such as preferences, opinions, demographic characteristics and self-reported behaviour.

Example: A university may survey students about their preferred methods of learning. Responses may include lecture attendance, use of digital resources and preferred assessment methods.

Interviews:

Interviews involve obtaining information directly from participants through verbal or written interaction. They may be structured, semi-structured or relatively open-ended.

Observation:

Observation involves systematically recording events, behaviours or conditions. It is particularly useful when the behaviour being studied may not be accurately captured through self-reported responses.

Experiments:

Experimental data are generated under controlled conditions in order to investigate relationships between variables. Experiments are common in scientific research, engineering and some areas of social science.

Sensors and Devices:

Modern systems can generate data continuously through sensors and connected devices. Examples include temperature sensors, industrial monitoring systems, GPS devices, wearable devices and environmental monitoring equipment.

Existing Databases and Digital Systems:

Organizations routinely generate data through information systems. Banking transactions, hospital records, university registration systems, websites and retail systems can all provide large datasets for analysis, subject to appropriate authorization and privacy requirements.

5.4 Data Acquisition

Data acquisition refers to the process of obtaining data and bringing them into a form or environment where they can be stored, examined and processed.

Data acquisition may involve:

  • importing a CSV or spreadsheet file;
  • querying a database;
  • retrieving data through an API;
  • collecting readings from sensors;
  • extracting information from approved digital sources; or
  • combining datasets obtained from several sources.

A typical acquisition process can be represented as:

Source → Acquisition → Storage → Inspection → Preprocessing → Analysis

During acquisition, the data scientist should record important information about the source, collection date, variables, units, format and any restrictions associated with the data. This information contributes to data provenance, which helps establish where data came from and how they have been processed.

5.5 Data Quality

Data quality describes how suitable data are for their intended purpose. A dataset may be large but still be unsuitable for analysis if its values are inaccurate, incomplete or inconsistent.

Important dimensions of data quality include:

Dimension Meaning Example of a Problem
Accuracy Values correctly represent what they are intended to measure. Age recorded as 250 instead of 25.
Completeness Required values are present. Many records have no examination score.
Consistency Values and formats agree across records and sources. Gender represented as M/F in one file and Male/Female in another.
Validity Values conform to required rules or formats. A date field contains “banana”.
Timeliness Data are sufficiently current for their intended purpose. Using outdated prices to make current pricing decisions.
Data Quality Principle:

A data scientist should evaluate data quality before performing substantial analysis. Poor-quality input can produce misleading conclusions even when the analytical method itself is correct.

5.6 Missing Data

Missing data occur when a value that should be present is unavailable, unknown or not recorded.

For example:

Student Age Study Hours Score
A 20 8 75
B 21 6 —
C 19 5 68

The missing score for Student B must be handled carefully. Several approaches are possible, depending on why the value is missing and how the data will be used.

Common Approaches to Missing Data:

Deletion: A record or variable may be removed when the amount of missing data is substantial or when retaining the record would not be appropriate.

Imputation: A missing value may be replaced with a reasonable estimated value. For numerical variables, mean or median imputation may sometimes be used; for categorical variables, the mode may sometimes be appropriate.

Special category: For some categorical variables, an explicit category such as “Unknown” may be appropriate if the absence itself carries useful information.

Domain-based replacement: In some applications, knowledge of the data-generating process may provide a justified replacement value.

Common Mistake:

Do not automatically replace every missing numerical value with the mean. The appropriate method depends on the nature, amount and pattern of the missing data and the purpose of the analysis.

5.7 Duplicate Data

Duplicate data occur when the same observation is recorded more than once when it should appear only once.

Consider the following customer dataset:

Customer ID Name Amount
C001Ada₦20,000
C002Tunde₦15,000
C001Ada₦20,000

If the third row is an accidental duplicate of the first row, counting both records would incorrectly inflate the total amount.

However, duplicate-looking records are not always errors. Two transactions involving the same customer may legitimately have identical values. A data scientist should therefore understand the meaning of the records before deleting duplicates.

5.8 Inconsistent Data

Inconsistent data occur when equivalent information is represented differently or when records violate an expected standard.

For example, a gender variable might contain:

Male, M, male, FEMALE, F, Female

These values may represent only two categories, but the inconsistent representations can complicate analysis.

A standardized representation could be:

Male, Male, Male, Female, Female, Female

Other common inconsistencies include:

  • different date formats, such as 12/05/2026 and 2026-05-12;
  • different spellings of the same location;
  • different units, such as kilograms and pounds;
  • different capitalization conventions;
  • leading or trailing spaces in text fields;
  • different currency representations; and
  • values that violate logical relationships between variables.

5.9 Data Cleaning

Data cleaning is the systematic process of identifying problematic data and correcting, removing or appropriately handling those problems.

A practical cleaning process may include:

  1. Inspect the dataset. Examine its structure, variables, data types and basic statistics.
  2. Identify problems. Search for missing values, duplicates, invalid values and inconsistencies.
  3. Determine the cause. Where possible, understand why the problem occurred.
  4. Choose an appropriate treatment. Correct, standardize, remove or otherwise handle the problematic records.
  5. Validate the result. Check that the cleaning operation did not introduce new errors.
  6. Document the changes. Record what was changed and why.

Worked Example: Cleaning a Small Dataset:

Suppose a dataset contains the following records:

ID Age Gender Score
120M72
221Male68
3—F81
420F81
420F81

Possible problems include:

  • Record 3 has a missing age.
  • Gender is represented inconsistently as M, Male and F.
  • Record 4 appears twice and may be a duplicate.

A reasonable cleaning process would investigate the missing age, standardize gender values and verify whether the repeated ID represents a duplicate record before removing it.

5.10 Data Transformation

Data transformation involves changing data into a representation that is more appropriate for analysis while preserving the information required for the intended task.

Common Transformation Techniques:

Scaling: Numerical variables can be transformed so that their values operate on comparable scales.

Normalization: A variable can be rescaled to a specified range, commonly 0 to 1.

One common min-max transformation is:

x′ = (x − xmin) / (xmax − xmin)

where x is the original value, xmin is the minimum value and xmax is the maximum value.

Worked Example: Min-Max Normalization:

Question: A dataset contains examination scores ranging from 40 to 90. Transform a score of 65 to a 0–1 scale using min-max normalization.

Given:

  • x = 65
  • xmin = 40
  • xmax = 90

Formula:

x′ = (x − xmin) / (xmax − xmin)

Solution:

x′ = (65 − 40) / (90 − 40)

x′ = 25 / 50

x′ = 0.50

Answer: The normalized score is 0.50.

This transformation expresses the score relative to the minimum and maximum values in the dataset.

Other Transformations:

Categorical encoding: Text categories may need to be represented numerically for some analytical and machine-learning methods. For example, a binary variable such as Yes/No may be represented as 1/0 where appropriate.

Date transformation: A date such as 2026-08-22 may be separated into year, month and day variables when those components are useful for analysis.

Aggregation: Detailed records may be summarized into meaningful groups. For example, daily sales may be aggregated into monthly sales.

Logarithmic transformation: A logarithmic transformation can sometimes be used to reduce strong right-skewness and compress large numerical values. The suitability of the transformation depends on the nature of the data and the analytical method.

5.11 Preparing Data for Analysis

After data have been acquired and cleaned, they should be prepared for the analytical method that will be applied. Preparation is not identical for every project because different analytical tasks require different data structures.

A prepared dataset should generally have:

  • clearly defined variables;
  • appropriate data types;
  • consistent units and formats;
  • properly handled missing values;
  • duplicates appropriately addressed;
  • valid and consistent categories;
  • meaningful variable names;
  • appropriate numerical representations;
  • documented transformations; and
  • an identifiable relationship between the prepared data and their original source.

For example, a dataset intended to predict student examination performance might contain:

Variable Type Possible Preparation
Study HoursNumericalCheck for missing or impossible values.
AttendanceNumericalCheck that values fall within the expected range.
ProgrammeCategoricalStandardize category names.
Examination ScoreNumericalCheck range, missing values and possible errors.

5.12 A Practical Data Preprocessing Workflow

Although preprocessing is not always strictly linear, a useful workflow for undergraduate data science projects is:

1. Define the Problem
Determine what information is required.
2. Acquire Data
Obtain data from appropriate sources.
3. Inspect
Understand structure, variables and quality.
4. Clean
Handle missing, duplicate and inconsistent data.
5. Transform
Convert variables into suitable forms.
6. Validate
Check that the prepared data remain correct.
7. Document
Record decisions and transformations.

The final step is particularly important in professional data science. A data scientist should be able to explain what was done to the original data and why. Reproducible preprocessing makes it easier for another analyst to verify or repeat the work.

5.13 Common Mistakes in Data Collection and Preprocessing

1. Collecting data without defining the problem. Data collection should be guided by the research or business question.

2. Assuming a large dataset is automatically good. A large dataset can still contain serious errors, bias, missing values and inconsistencies.

3. Deleting all missing records. Removing records without understanding why values are missing can introduce bias or unnecessarily reduce the amount of usable information.

4. Treating every repeated record as a duplicate. Repeated values may represent legitimate separate observations.

5. Changing values without documentation. Data transformations should be recorded so that the analysis remains reproducible.

6. Ignoring units. Combining values expressed in different units can produce incorrect conclusions. For example, temperatures recorded in Celsius should not be combined directly with temperatures recorded in Fahrenheit without appropriate conversion.

7. Cleaning data after analysis instead of before analysis. Serious data-quality problems should be investigated before relying on analytical results.

8. Removing unusual values automatically. An unusual value may be an error, but it may also represent a genuine observation. It should be investigated rather than automatically deleted.

9. Losing the original data. The original dataset should normally be preserved separately from the cleaned or transformed version.

5.14 Key Points

  • Data collection is the systematic acquisition of data for a defined purpose.
  • Primary data are collected directly for the current investigation, while secondary data already exist.
  • Common collection methods include surveys, interviews, observation, experiments, sensors and existing databases.
  • Data acquisition brings data from their sources into an environment where they can be stored and processed.
  • Important aspects of data quality include accuracy, completeness, consistency, validity and timeliness.
  • Missing data require appropriate treatment based on the nature and purpose of the dataset.
  • Duplicate records should be identified carefully because repeated-looking records are not always errors.
  • Inconsistent representations should be standardized where appropriate.
  • Data cleaning identifies and handles problematic observations.
  • Data transformation changes data into forms suitable for analysis.
  • Normalization is one example of numerical transformation.
  • Preprocessing prepares raw data for analysis while attempting to preserve their meaning.
  • Data-processing decisions should be validated and documented.

Chapter Summary

Data collection and preprocessing form a critical foundation for data science. Data may be obtained directly through primary collection or acquired from existing secondary sources. Regardless of their source, data must be examined carefully before they are used for analysis.

Data quality concerns whether the dataset is accurate, complete, consistent, valid and sufficiently current for its intended purpose. Common data-quality problems include missing values, duplicate records and inconsistent representations. These problems must be investigated and handled using methods appropriate to the context rather than through automatic deletion or arbitrary replacement.

Data cleaning removes or corrects problematic information, while data transformation converts variables into representations suitable for analytical procedures. Examples include standardizing categories, encoding variables, aggregating observations and normalizing numerical values.

The central objective of preprocessing is therefore to produce a dataset that is reliable, consistent, meaningful and suitable for analysis. A well-prepared dataset does not guarantee a correct conclusion, but poor-quality data can seriously undermine even the most sophisticated analytical method.

Further Practice

Basic Questions:

  1. Define data collection and explain its importance in data science.
  2. Distinguish between primary and secondary data.
  3. List five sources from which a data scientist can obtain data.
  4. What is data acquisition?
  5. Define data quality.
  6. What are missing data?

Application Questions:

  1. A university wants to determine the factors associated with student academic performance. Identify five variables that could be collected and suggest an appropriate method for obtaining each variable.
  2. A dataset contains the values Male, M, male, Female, F and female. Explain the problem and describe how you would standardize the variable.
  3. A customer appears twice in a database. Explain why the record should not be deleted immediately and identify information that should be checked first.
  4. Explain three possible approaches to handling missing numerical values.
  5. Explain why an unusually large numerical value should be investigated rather than automatically removed.

Calculation and Analytical Questions:

  1. A dataset has a minimum examination score of 30 and a maximum score of 90. Using min-max normalization, transform a score of 60 to a value between 0 and 1.
  2. A dataset contains the values 10, 20, 30, 40 and 50. Calculate the normalized value of 30 using min-max normalization.
  3. A dataset contains the values 5, 10, 15, 20 and 25. Determine the normalized value of 10 using the min-max formula and explain what the result means.

Higher-Order Questions:

  1. Explain why data preprocessing should be considered part of the analytical process rather than merely a technical cleaning exercise.
  2. A company combines customer data from three databases. One database records age in years, another records date of birth, and the third contains ages as text values. Discuss the preprocessing steps required before the datasets can be combined reliably.
  3. A researcher discovers that 35% of the observations for an important variable are missing. Explain the factors that should be considered before deciding whether to delete records, impute values or use another approach.
  4. Discuss how careless data cleaning can introduce bias into a data science project.

CHAPTER SIX

Data Visualization

6.1 Meaning of Data Visualization

Data visualization is the process of representing data graphically or visually so that information contained in the data can be understood, explored and communicated more effectively.

Instead of presenting a dataset only as rows and columns, visualization converts selected aspects of the dataset into visual forms such as bars, lines, points, sectors or other graphical elements.

For example, suppose the number of students enrolled in five programmes is:

Programme Students
Computer Science420
Data Science310
Cybersecurity250
Software Engineering380
Information Systems190

A table provides the exact values, while a bar chart can make the differences between the programmes immediately visible.

Important idea: Visualization does not replace the original data. It provides another representation of the data that makes particular features easier to examine.

6.2 Importance of Data Visualization

Data visualization is important because human beings can often recognize visual patterns more quickly than they can interpret large quantities of numerical information.

6.2.1 Identifying Patterns:

Visualization can reveal patterns that may not be obvious in raw data. For example, a line graph showing monthly electricity consumption may immediately reveal that consumption increases during certain months.

6.2.2 Identifying Trends:

When observations are collected over time, a visualization can show whether a quantity is generally increasing, decreasing or remaining relatively stable.

6.2.3 Comparing Categories:

Charts such as bar charts allow different groups to be compared quickly. For example, a business can compare sales across products, regions or branches.

6.2.4 Identifying Relationships:

Scatter plots can help a data scientist examine whether two numerical variables appear to be related. For example, a scatter plot may be used to examine the relationship between study hours and examination scores.

6.2.5 Detecting Unusual Observations:

Visualization can make unusually high or low observations easier to identify. Such observations may represent genuine unusual cases, measurement errors or data-entry problems.

6.2.6 Communicating Results:

Data scientists frequently communicate findings to people who may not have advanced statistical knowledge. A clear visualization can communicate an important result more effectively than several paragraphs of numerical output.

6.3 Principles of Effective Data Visualization

A good visualization should communicate information clearly without unnecessarily distracting the reader. The following principles are especially important.

6.3.1 Know the Purpose:

Before selecting a chart, determine what the visualization is intended to communicate. A chart designed to compare categories may not be appropriate for showing a trend over time.

6.3.2 Choose the Appropriate Visualization:

The type of data and the question being investigated should influence the choice of visualization.

Purpose Suitable Visualization
Compare categoriesBar chart
Show parts of a wholePie chart or other composition chart
Show change over timeLine graph
Show numerical distributionHistogram
Examine relationship between two numerical variablesScatter plot

6.3.3 Use Clear Labels:

Axes, categories and measurements should be clearly labelled. A reader should not have to guess what the values represent.

6.3.4 Provide an Informative Title:

A good title should communicate what the visualization represents.

Weak title: Sales Chart

Better title: Monthly Sales Revenue of ABC Ltd., January–December 2025

6.3.5 Use Appropriate Scales:

The scale of an axis should represent the data accurately. An inappropriate scale can exaggerate or hide differences.

6.3.6 Avoid Unnecessary Decoration:

Three-dimensional effects, excessive colours, decorative backgrounds and unnecessary graphical elements can make a visualization harder to interpret.

6.3.7 Preserve Proportionality:

The visual size of an element should correspond appropriately to the value it represents. A small numerical difference should not be presented in a way that makes it appear enormous.

6.3.8 Provide Context:

A visualization should contain enough context for the reader to understand what is being shown, when it was collected and what units are being used.

6.4 Tables

A table organizes data into rows and columns. Tables are particularly useful when the exact numerical values are important.

For example:

Month Website Visitors
January12,500
February14,200
March16,800
April15,900

The table shows the exact values. However, a line graph would make the overall movement in website traffic easier to see.

Strength of tables: They preserve precise numerical information.

Limitation: Large tables can make patterns and trends difficult to identify quickly.

6.5 Charts and Graphs

The terms chart and graph are sometimes used interchangeably, although they can have slightly different meanings depending on context. In data science, both are visual methods for representing information.

A graph commonly emphasizes numerical relationships using axes, while a chart is a broader term that includes representations such as bar charts and pie charts.

The appropriate visualization depends on the structure of the data and the analytical question.

6.6 Bar Charts

A bar chart represents categories using rectangular bars. The length or height of each bar corresponds to the numerical value associated with that category.

Bar charts are particularly useful for comparing discrete categories.

Example:

Suppose a supermarket records the following weekly sales:

Product Units Sold
Rice250
Beans180
Oil220
Sugar140

A bar chart would show Rice as the highest category, followed by Oil, Beans and Sugar.

Important Characteristics:

  • Each bar represents a category.
  • Bars should be clearly separated when categories are discrete.
  • The scale should be labelled.
  • The height or length of each bar represents the corresponding value.
  • Bars may be vertical or horizontal.

Common mistake: A bar chart should not be confused with a histogram. Bar charts compare categories, whereas histograms display the distribution of numerical data grouped into intervals.

6.7 Pie Charts

A pie chart represents a whole as a circle divided into sectors. Each sector represents a proportion or percentage of the total.

Pie charts are most appropriate when the categories represent parts of a meaningful whole and there are relatively few categories.

Calculating Pie-Chart Angles:

The angle of a sector can be calculated using:

Sector angle = (Category value ÷ Total value) × 360°

Worked Example:

Question: A university has 1,000 students distributed among four faculties as follows:

  • Science: 300
  • Engineering: 250
  • Arts: 200
  • Social Sciences: 250

Calculate the percentage and sector angle for each faculty.

Given: Total students = 1,000.

Formula:

Percentage = (Category value ÷ Total) × 100

Angle = (Category value ÷ Total) × 360°

Faculty Students Percentage Angle
Science30030%108°
Engineering25025%90°
Arts20020%72°
Social Sciences25025%90°
Total1,000100%360°

Notice that all percentages must add to 100% and all sector angles must add to 360°. These provide useful checks on the calculation.

Limitation: Pie charts become difficult to interpret when there are many categories or when the values are very similar.

6.8 Histograms

A histogram is a graphical representation of the distribution of numerical data. Numerical observations are grouped into intervals, commonly called bins or class intervals.

Unlike a bar chart, the bars of a histogram normally touch because the intervals represent continuous or ordered numerical ranges.

Example:

Suppose the ages of 40 participants are grouped as follows:

Age Interval Frequency
18–226
23–2712
28–3210
33–377
38–425

A histogram constructed from these data would allow the analyst to see where the observations are concentrated and whether the distribution appears symmetric, skewed or otherwise unusual.

Histogram versus Bar Chart:

Feature Bar Chart Histogram
DataCategorical or discrete categoriesNumerical data
PurposeCompare categoriesShow distribution
BarsUsually separatedNormally touch
Horizontal axisCategoriesNumerical intervals

6.9 Line Graphs

A line graph displays data points connected by lines. It is particularly useful for examining how a variable changes over an ordered sequence, especially time.

Example:

Suppose a company's monthly revenue is:

Month Revenue (₦)
January2,000,000
February2,300,000
March2,700,000
April2,500,000

A line graph would show that revenue increased from January through March and then declined in April.

Line graphs are especially useful for:

  • monthly sales;
  • annual population growth;
  • temperature changes;
  • stock prices over time;
  • website traffic;
  • machine performance;
  • electricity consumption; and
  • other time-series data.

Interpretation principle: The slope and direction of a line provide information about how the measured quantity changes between observations. However, a line connecting observations does not automatically prove that every value between them was actually observed.

6.10 Scatter Plots

A scatter plot displays individual observations as points on a coordinate system. It is commonly used to investigate the relationship between two numerical variables.

For example, a researcher may collect the following data:

Student Study Hours Score (%)
A248
B355
C461
D569
E674

Each student would appear as a point whose coordinates correspond to study hours and examination score.

If the points generally rise from left to right, the variables show a positive association. If they generally fall from left to right, they show a negative association. If there is no clear pattern, the relationship may be weak or absent.

Important: A visible association between two variables does not by itself establish that one variable causes the other.

6.11 Interpreting Visual Representations

Creating a graph is only part of the visualization process. A data scientist must also be able to interpret what the visualization communicates.

A systematic interpretation should consider the following:

  1. What is being measured? Identify the variables and their units.
  2. What are the categories or intervals? Determine how the observations have been grouped.
  3. What is the scale? Examine the numerical range and intervals on the axes.
  4. What is the dominant pattern? Identify the largest, smallest, increasing or decreasing values.
  5. Are there unusual observations? Look for possible outliers or unexpected changes.
  6. Are there relationships? For appropriate visualizations, determine whether variables appear to move together.
  7. What conclusion is justified? State only what the visualization supports.

Example of Interpretation:

Suppose a line graph shows the number of customers visiting a website over six months:

January: 2,000; February: 2,500; March: 3,200; April: 3,100; May: 4,000; June: 4,600.

An appropriate interpretation would be:

The number of website visitors generally increased during the six-month period. There was a small decline between March and April, after which visitor numbers increased again. The highest recorded value occurred in June.

This interpretation describes the observed pattern without claiming an unexplained cause for the increase.

6.12 Reading Scales Correctly

One of the most important skills in data visualization is reading the scale correctly. A graph can appear to show a large difference when the numerical difference is actually small, particularly when an axis does not begin at zero.

Example:

Consider two values: 98 and 100. The numerical difference is only 2 units. If a graph displays only the interval from 97 to 101, the difference may appear visually large.

This does not necessarily make the graph invalid. However, the axis should be examined carefully before interpreting the magnitude of the difference.

Warning: Never interpret the visual length of a bar or line without examining the numerical scale on the axis.

6.13 Common Visualization Errors

1. Using the Wrong Chart Type:

A pie chart is not normally the best choice for displaying a long time series, just as a line graph is not normally the best choice for comparing unrelated categories.

2. Missing Axis Labels:

Without labels, readers may not know what the numbers represent.

3. Missing Units:

A value such as 50 could represent kilograms, students, naira, kilometres or another quantity. Units provide essential context.

4. Excessive Categories in a Pie Chart:

A pie chart containing many small sectors becomes difficult to read and compare.

5. Misleading Scales:

An inappropriate scale can exaggerate or minimize apparent differences.

6. Excessive Decoration:

Three-dimensional effects and unnecessary graphics can distract from the actual data.

7. Confusing Correlation with Causation:

A scatter plot may reveal an association between two variables, but visualization alone cannot establish that one variable causes changes in another.

8. Ignoring Missing Data:

Visualizations can sometimes conceal missing observations. Analysts should understand how missing values were handled before drawing conclusions.

6.14 Choosing the Right Visualization

Question Recommended Visualization Reason
Which product has the highest sales? Bar chart Makes category comparison easy.
How did sales change over 12 months? Line graph Shows movement over time.
What percentage of students belong to each faculty? Pie chart Shows parts of a whole.
How are examination scores distributed? Histogram Shows the distribution of numerical observations.
Are study hours associated with examination scores? Scatter plot Shows the relationship between two numerical variables.

6.15 Data Visualization in Data Science

Visualization is used at several stages of the data science process. It is not restricted to the final presentation of results.

Exploratory Data Analysis:

During exploratory data analysis, visualizations help the data scientist understand the structure of a dataset. Histograms can reveal distributions, scatter plots can reveal relationships and bar charts can reveal category frequencies.

Data Quality Investigation:

Visualization can help identify unusual observations, unexpected values and possible data-quality problems.

Model Development:

Data scientists can use visualization to examine relationships between variables and understand patterns that may be useful when developing predictive models.

Model Evaluation:

Graphs can be used to compare predicted and observed values, examine errors and identify patterns in model performance.

Communication:

Visualizations provide an effective way of communicating findings to technical and non-technical audiences.

6.16 Worked Example: Selecting and Interpreting a Visualization

Question: A university wants to investigate the number of applications received each month from January to June. Which visualization should be used, and how should it be interpreted?

Data:

Month Applications
January800
February950
March1,100
April1,050
May1,300
June1,500

Required: Select an appropriate visualization and describe the trend.

Solution: A line graph is appropriate because the observations are ordered by month and the objective is to examine change over time.

The data show a general upward trend in applications from January to June. There is a small decline from March to April, after which applications increase again. June records the highest number of applications.

Additional analysis: The increase from January to June is:

Increase = 1,500 − 800 = 700 applications.

The percentage increase is:

Percentage increase = [(1,500 − 800) ÷ 800] × 100

= (700 ÷ 800) × 100

= 87.5%

Therefore, the number of applications increased by 87.5% from January to June.

6.17 Common Mistakes Students Should Avoid

  • Choosing a visualization without first identifying the question being investigated.
  • Confusing categorical data with continuous numerical data.
  • Using a histogram when a bar chart is required.
  • Assuming that a larger visual element always represents a meaningful statistical difference.
  • Ignoring the scale of an axis.
  • Failing to label axes and units.
  • Using too many colours or decorative elements.
  • Assuming that correlation proves causation.
  • Drawing conclusions that are not supported by the data.
  • Failing to check whether the data contain missing or unusual observations.

6.18 Key Points

  • Data visualization is the graphical representation of data.
  • Visualization helps analysts identify patterns, trends, comparisons, relationships and unusual observations.
  • The choice of visualization should depend on the type of data and the analytical purpose.
  • Tables are useful when exact values are important.
  • Bar charts are primarily used to compare categories.
  • Pie charts represent proportions or parts of a whole.
  • Histograms show the distribution of numerical data grouped into intervals.
  • Line graphs are particularly useful for showing changes over time.
  • Scatter plots are used to examine relationships between two numerical variables.
  • Good visualizations require clear titles, labels, scales, units and appropriate graphical design.
  • A visualization should communicate information accurately rather than merely look attractive.
  • A relationship observed in a visualization does not automatically establish causation.
  • Data visualization is used throughout the data science process, including exploratory analysis, data-quality investigation, modelling and communication.

6.19 Chapter Summary

Data visualization is an essential component of data science because it transforms data into visual representations that make important features easier to identify and communicate. Effective visualization allows analysts to examine patterns, trends, distributions, comparisons and relationships within datasets.

Different visualization techniques serve different purposes. Tables provide precise values; bar charts compare categories; pie charts show parts of a whole; histograms describe the distribution of numerical data; line graphs show changes across an ordered sequence, particularly time; and scatter plots help investigate relationships between numerical variables.

Effective visualization requires more than selecting a chart. The data scientist must consider the purpose of the visualization, select an appropriate representation, use clear labels and scales, provide context and avoid graphical techniques that may distort interpretation.

Visualization is used throughout the data science lifecycle. It supports exploratory data analysis, data-quality assessment, model development, evaluation and communication. A competent data scientist must therefore be able not only to create visualizations but also to interpret them critically and communicate conclusions that are properly supported by the underlying data.

Chapter at a Glance:

Data → Visual representation → Pattern → Interpretation → Insight → Communication

CHAPTER SEVEN

Data Distributions and Probability

Chapter Introduction

Data science rarely deals with perfectly predictable observations. Measurements vary, customers behave differently, experimental results differ, and future events cannot always be known with certainty. Two fundamental ideas help data scientists understand this uncertainty: data distributions and probability.

A distribution describes how values in a dataset are arranged or occur. Probability provides a mathematical framework for describing the likelihood of events. Together, they support statistical analysis, prediction, machine learning, risk assessment and decision-making.

This chapter introduces frequency distributions, variation and range, basic probability concepts, random events and the role of probability distributions in data science.

7.1 Meaning of Data Distributions

A data distribution describes how observations are spread across the possible values of a variable. It shows not only what values occur, but also how frequently those values occur.

Consider the examination scores:

45, 50, 50, 55, 60, 60, 60, 65, 70, 75

The value 60 occurs three times, while 45 occurs once. Therefore, the distribution tells us something about the concentration of scores in the dataset.

Data distributions can be represented using tables, graphs or mathematical models. Understanding a distribution is important because the same average can occur in datasets with very different patterns of variation.

Important: A distribution describes the pattern of the data, not simply its average. Two datasets may have the same mean but substantially different distributions.

7.2 Frequency Distributions

A frequency distribution organizes data according to the number of times each value or category occurs.

Example:

Suppose the following values represent the number of computers used by ten students in their homes:

1, 2, 1, 3, 2, 2, 4, 1, 3, 2

Number of Computers Frequency
13
24
32
41
Total10

The frequency distribution immediately shows that two computers is the most common value.

Relative Frequency:

Relative frequency expresses a frequency as a proportion or percentage of the total observations.

Formula:

Relative Frequency = Frequency ÷ Total Number of Observations

For students with two computers:

Relative Frequency = 4 ÷ 10 = 0.40 = 40%

Thus, 40% of the students in this dataset have two computers.

7.3 Grouped Frequency Distributions

When a dataset contains many numerical values, listing every individual value may produce an unnecessarily large table. The observations can therefore be grouped into class intervals.

For example, examination scores can be grouped as follows:

Score Interval Frequency
0–192
20–395
40–598
60–7912
80–1003

This table shows that the 60–79 interval contains the greatest number of observations.

7.4 Variation and Range

Data values are rarely identical. The degree to which observations differ from one another is called variation.

Variation is important in Data Science because two datasets with similar central values can behave very differently if their spread is different.

Range:

The simplest measure of variation is the range.

Range = Maximum Value − Minimum Value

Worked Example

Question: Find the range of the following dataset:

12, 18, 15, 25, 10, 21, 17

Given: Maximum = 25; Minimum = 10

Required: Range

Formula: Range = Maximum − Minimum

Solution:

Range = 25 − 10 = 15

Answer: The range is 15.

The range is easy to calculate, but it depends only on the two extreme values. Consequently, it may not fully describe the variation within a large dataset.

7.5 Basic Probability Concepts

Probability measures the likelihood that an event will occur. Its value lies between 0 and 1, inclusive.

Probability Interpretation
0Impossible event
Between 0 and 1Event has some degree of uncertainty
1Certain event

Probability may also be expressed as a percentage. For example:

0.75 = 75%

Probability of an Event:

When all possible outcomes are equally likely, the probability of an event can be calculated using:

P(E) = Number of favourable outcomes ÷ Total number of possible outcomes

Worked Example: Rolling a Die:

Question: What is the probability of rolling a 4 on a fair six-sided die?

Favourable outcomes: 1

Total possible outcomes: 6

P(4) = 1/6 ≈ 0.1667 = 16.67%

Therefore, the probability of rolling a 4 is approximately 16.67%.

7.6 Random Experiments, Outcomes and Events

A random experiment is a process whose exact outcome cannot be predicted with certainty before it is performed, even though the possible outcomes may be known.

For example, when a fair die is rolled, the exact number that appears is uncertain, but the possible outcomes are known:

{1, 2, 3, 4, 5, 6}

The set of all possible outcomes is called the sample space.

An event is a collection of one or more outcomes of a random experiment.

For example, when rolling a die:

  • Event A = obtaining an even number = {2, 4, 6}
  • Event B = obtaining a number greater than 4 = {5, 6}
  • Event C = obtaining a number less than 1 = { } — an impossible event.

Example: Probability of an Even Number:

There are three favourable outcomes: 2, 4 and 6.

P(Even) = 3/6 = 1/2 = 0.5 = 50%

Thus, the probability of obtaining an even number is 50%.

7.7 Complementary Events

The complement of an event consists of all outcomes in the sample space that are not part of that event.

If an event is represented by A, its complement is written as Ac.

The probability of an event and its complement must add up to 1:

P(A) + P(Ac) = 1

Therefore:

P(Ac) = 1 − P(A)

Example: If the probability that a customer purchases a product is 0.65, the probability that the customer does not purchase it is:

P(Not purchase) = 1 − 0.65 = 0.35

Therefore, the probability is 0.35 or 35%.

7.8 Addition and Multiplication of Probabilities

Some probability problems involve more than one event. In such cases, the relationship between events must be considered carefully.

Mutually Exclusive Events:

Two events are mutually exclusive if they cannot occur at the same time.

For mutually exclusive events A and B:

P(A or B) = P(A) + P(B)

Example: When rolling a die, obtaining a 2 and obtaining a 5 are mutually exclusive.

P(2 or 5) = 1/6 + 1/6 = 2/6 = 1/3

Independent Events:

Two events are independent when the occurrence of one does not change the probability of the other.

For independent events A and B:

P(A and B) = P(A) × P(B)

For example, tossing a coin twice gives independent outcomes. The result of the first toss does not alter the probabilities of the second toss.

The probability of obtaining two heads is:

P(H and H) = 1/2 × 1/2 = 1/4 = 25%

7.9 Probability in Data Science

Probability is fundamental to Data Science because data scientists frequently make decisions in situations involving uncertainty.

For example, a data scientist may want to estimate:

  • the probability that a customer will purchase a product;
  • the probability that a machine will fail within a specified period;
  • the probability that an email is spam;
  • the probability that a patient belongs to a particular risk category;
  • the probability that a transaction is fraudulent; or
  • the probability that a particular event will occur in a future dataset.

Probability provides the mathematical language required to express these uncertainties quantitatively.

Probability and Machine Learning:

Many machine-learning systems produce predictions that can be interpreted probabilistically. Instead of simply stating that an observation belongs to a particular class, a model may estimate the probability of membership in each class.

For example, a classification model might produce:

Class Predicted Probability
Not Fraudulent0.08
Fraudulent0.92

The model therefore estimates a 92% probability that the transaction is fraudulent. The probability is not necessarily a guarantee that fraud occurred; it is a quantitative expression of the model's uncertainty.

7.10 Probability Distributions

A probability distribution describes how probabilities are assigned to the possible values of a random variable.

A random variable is a variable whose value is determined by the outcome of a random process.

For example, let X represent the number obtained when a fair die is rolled. Then:

X ∈ {1, 2, 3, 4, 5, 6}

Because the die is fair, each possible value has probability 1/6.

X P(X)
11/6
21/6
31/6
41/6
51/6
61/6
Total1

A valid probability distribution must assign probabilities that are non-negative and whose total is equal to 1.

7.11 Discrete and Continuous Distributions

Probability distributions are commonly distinguished according to whether the random variable is discrete or continuous.

Feature Discrete Variable Continuous Variable
Meaning Takes countable values. Can take any value within an interval.
Example Number of customers. Height or temperature.
Values 0, 1, 2, 3, ... Any value within a range.

For example, the number of defective products produced by a machine is discrete because defects can be counted. The exact operating temperature of the machine is continuous because it can take many possible values within a range.

7.12 Common Probability Distributions

Several probability distributions are particularly important in Data Science and statistics.

Bernoulli Distribution:

The Bernoulli distribution describes a random experiment with two possible outcomes, commonly represented as success and failure, or 1 and 0.

Examples: A customer purchases or does not purchase a product; a machine passes or fails a test; an email is spam or not spam.

Binomial Distribution:

The binomial distribution describes the number of successes obtained in a fixed number of independent Bernoulli trials, when the probability of success remains constant.

For example, if a fair coin is tossed ten times, the number of heads obtained can be modelled using a binomial distribution.

Normal Distribution:

The normal distribution is a continuous probability distribution characterized by its symmetric, bell-shaped form. It is important in statistics because many naturally occurring measurements can be approximately modelled by it under appropriate conditions.

Examples may include certain measurements of height, measurement errors and other quantities when the assumptions required for a normal model are reasonably satisfied.

Important distinction: Not every dataset follows a normal distribution. Data scientists must examine the data and the assumptions of a statistical method before choosing a probability model.

7.13 Distribution, Probability and Frequency: The Difference

Concept Meaning Example
Frequency How many times an observation occurs. A score of 70 occurs 8 times.
Distribution The overall pattern in which observations occur. Most scores are concentrated between 60 and 80.
Probability The likelihood of a possible event. There is a 0.70 probability of an event occurring.
Probability distribution The probabilities assigned to possible values of a random variable. A model assigning probabilities to the possible number of failures.

7.14 Common Mistakes and Misconceptions

1. Confusing frequency with probability: Frequency counts observations in an actual dataset, whereas probability describes the likelihood of an event.

2. Assuming a probability can be greater than 1: A probability must always lie between 0 and 1, inclusive.

3. Forgetting to consider the sample space: A probability calculation requires a clear understanding of the possible outcomes.

4. Assuming that every event is equally likely: The simple formula based on favourable outcomes divided by total outcomes requires equally likely outcomes.

5. Confusing independence with mutual exclusivity: Independent events can occur together, whereas mutually exclusive events cannot occur together.

6. Treating the range as a complete description of variation: The range uses only the minimum and maximum values and may therefore overlook how the remaining observations are distributed.

7. Assuming every dataset follows a normal distribution: Real-world datasets may be skewed, multimodal, heavy-tailed or otherwise non-normal.

7.15 Key Points

  • A data distribution describes how observations are arranged across possible values.
  • A frequency is the number of times a value or category occurs.
  • Relative frequency expresses frequency as a proportion or percentage of the total.
  • Variation describes the extent to which observations differ from one another.
  • The range is calculated as maximum value minus minimum value.
  • Probability measures the likelihood of an event and ranges from 0 to 1.
  • A sample space contains all possible outcomes of a random experiment.
  • An event consists of one or more outcomes from the sample space.
  • The probability of an event and its complement sum to 1.
  • For mutually exclusive events, probabilities can be added.
  • For independent events, the probability of both events occurring is obtained by multiplication.
  • Probability is essential for dealing with uncertainty in Data Science.
  • A probability distribution assigns probabilities to possible values of a random variable.
  • Discrete variables take countable values, while continuous variables can take values across an interval.
  • Bernoulli, binomial and normal distributions are important examples of probability distributions used in data analysis and modelling.

7.16 Chapter Summary

Data distributions provide a structured way of understanding how observations occur within a dataset. Frequency distributions show how often values occur, while grouped distributions organize large datasets into intervals. Variation describes differences among observations, and the range provides a simple measure of spread.

Probability provides the mathematical framework for reasoning about uncertain events. A random experiment has possible outcomes that form a sample space, while an event represents one or more of those outcomes. Probability values range from 0 to 1 and may be expressed as decimals, fractions or percentages.

Probability is particularly important in Data Science because predictions and decisions are frequently made under uncertainty. Probability distributions extend these ideas by describing the likelihood associated with possible values of random variables. Understanding distributions and probability therefore provides an essential foundation for later topics such as statistical inference, predictive modelling, machine learning and uncertainty analysis.

CHAPTER EIGHT

Simulation and Data Analysis

8.1 Meaning of Simulation

Simulation is the use of a mathematical, statistical or computational model to imitate the behaviour of a real-world system or process.

The central idea is simple: instead of experimenting directly with the real system, we construct a representation of the system and conduct experiments on that representation.

Suppose a supermarket wants to determine whether two checkout counters are sufficient during busy periods. Closing or modifying the actual supermarket repeatedly to test different arrangements would be impractical. A simulation can instead represent customers arriving at the supermarket, their waiting times, service times and the number of available checkout counters.

The simulated system can then be run many times to answer questions such as:

  • How long do customers typically wait?
  • What proportion of customers wait more than ten minutes?
  • What happens if another checkout counter is added?
  • What happens when customer arrival rates increase?

Simulation is therefore particularly useful when a real experiment is difficult, costly, risky or impossible.

Key idea: Simulation does not replace reality. It creates a model of reality that can be used to investigate possible behaviour under controlled conditions.

8.2 Why Simulation Is Important in Data Science

Data Science frequently deals with uncertainty. Future events cannot always be observed in advance, and historical data may not contain every situation that a decision-maker wants to investigate.

Simulation provides a method for exploring possible outcomes under different assumptions.

1. Studying uncertain systems:

Many systems contain random behaviour. Customers arrive at different times, machines fail unpredictably, financial prices fluctuate, and weather conditions vary. Simulation allows such uncertainty to be incorporated into a model.

2. Testing different scenarios:

A data scientist can change assumptions and observe how the simulated system responds.

For example, a logistics company can simulate delivery operations under different numbers of vehicles, delivery times and customer demand levels.

3. Reducing cost and risk:

Some real-world experiments are expensive or dangerous. Simulation can allow preliminary investigation before an actual intervention is attempted.

4. Supporting decision-making:

Simulation can provide estimates of possible outcomes, helping managers and analysts compare alternatives before making decisions.

5. Generating data for analysis:

Simulation can produce synthetic observations when researchers need to study the behaviour of a system under controlled assumptions.

8.3 Real Systems and Simulation Models

A real system is the actual process or environment being studied. A simulation model is a simplified representation of that system.

Real System Simulation Model
Actual hospital emergency department Model representing patient arrivals and treatment times
Actual road intersection Model representing traffic flow and waiting times
Actual bank Model representing customer arrivals and service times
Actual agricultural farm Model representing rainfall, crop growth and yield

A useful simulation model does not necessarily reproduce every detail of the real system. Including unnecessary details can make a model complicated without improving its usefulness. The objective is to include the features that are relevant to the question being investigated.

8.4 Basic Components of a Simulation

A simple simulation generally contains several important components.

System:

The system is the real-world process or phenomenon being studied.

Inputs:

Inputs are the factors supplied to the model. Examples include customer arrival rates, machine operating times, population sizes or demand levels.

Rules or relationships:

These describe how the system behaves. For example, a customer may be served only when a service counter is available.

Random variables:

These represent quantities whose values vary because of uncertainty, such as arrival time or service duration.

Outputs:

Outputs are the observations produced by the simulation. Examples include waiting time, total cost, number of customers served and system utilization.

Performance measures:

These are numerical measures used to evaluate the simulated system. Mean waiting time, maximum demand and probability of failure are examples.

8.5 Simulation, Probability and Randomness

Simulation and probability are closely related. Probability provides the mathematical framework for representing uncertainty, while simulation provides a practical method for reproducing uncertain outcomes repeatedly.

Consider the experiment of tossing a fair coin. There are two possible outcomes:

  • Heads
  • Tails

If the coin is fair:

P(Heads) = 0.5

P(Tails) = 0.5

A simulation of 100 coin tosses can use random values to represent these outcomes. We would not necessarily obtain exactly 50 heads and 50 tails, but as the number of trials becomes large, the observed proportion of heads will generally tend to approach 0.5.

Example: Simulating a Die:

Consider a fair six-sided die. Each face has probability:

P(X = x) = 1/6

where x can be 1, 2, 3, 4, 5 or 6.

If we conduct ten simulated rolls, one possible result is:

4, 2, 6, 3, 1, 4, 5, 2, 6, 3

The result contains two occurrences of 2, two occurrences of 3, two occurrences of 4, one occurrence of 1, one occurrence of 5 and two occurrences of 6.

The proportion of rolls producing a 4 is:

2 / 10 = 0.20 = 20%

The theoretical probability of obtaining a 4 is 1/6, approximately 16.67%. The difference is not surprising because only ten trials were performed.

8.6 Random Numbers in Simulation

Computer simulations frequently use pseudorandom numbers. These are numbers generated by an algorithm that produces a sequence with properties similar to random numbers.

A random-number generator can be used to select outcomes according to specified probabilities.

For example, suppose a system has two possible states:

  • Working: probability = 0.90
  • Failed: probability = 0.10

A simulation could generate a random number between 0 and 1. If the number is less than 0.90, the simulated system is classified as working; otherwise, it is classified as failed.

This allows a large number of simulated trials to be generated efficiently.

Important: A pseudorandom number is generated deterministically by an algorithm, but a good generator produces sequences that behave sufficiently like random numbers for many simulation applications.

8.7 A Simple Simulation Process

A basic simulation can be organized into the following steps:

  1. Define the problem. Clearly state what you want to investigate.
  2. Identify important variables. Determine the inputs, outputs and uncertain quantities.
  3. Specify assumptions. State how the system is expected to behave.
  4. Assign probability distributions. Where appropriate, describe uncertain variables probabilistically.
  5. Generate random outcomes. Use random or pseudorandom numbers to represent uncertainty.
  6. Run the simulation. Perform one or many trials.
  7. Record the results. Store relevant outputs.
  8. Analyse the results. Calculate appropriate statistics and identify patterns.
  9. Interpret the results. Relate the findings to the original problem.
  10. Compare scenarios. Where necessary, repeat the simulation using different assumptions.

8.8 Worked Example: Simple Coin-Toss Simulation

Question:

Suppose a fair coin is simulated 20 times. The results are:

H, T, H, H, T, T, H, T, H, H, T, H, T, T, H, H, T, H, T, H

Required:

Determine the number and proportion of heads and tails.

Solution:

Counting the observations gives:

Heads = 11

Tails = 9

Total trials:

11 + 9 = 20

Observed proportion of heads:

11 / 20 = 0.55 = 55%

Observed proportion of tails:

9 / 20 = 0.45 = 45%

Answer: The simulation produced 55% heads and 45% tails.

The theoretical probability for each outcome is 50%. The simulation does not have to produce exactly 50% because it contains only a finite number of trials.

8.9 Repeated Simulation and the Law of Large Numbers

A single simulation can produce an unusual result. Repeating the simulation many times generally provides a more stable estimate of the behaviour of the underlying probability model.

Consider a fair die. The theoretical probability of rolling a 6 is:

P(6) = 1/6 ≈ 0.1667

Suppose the die is rolled ten times. The observed proportion of sixes might be 0.30. If it is rolled 10,000 times, the observed proportion is expected to be much closer to 0.1667, assuming the simulation correctly represents a fair die.

Number of Trials Possible Proportion of Sixes Interpretation
10 0.20 Large random variation is possible.
100 0.18 Generally more stable.
1,000 0.167 Typically close to the theoretical value.

This illustrates the general principle that as the number of independent trials increases, the observed relative frequency tends to approach the underlying probability. This principle is commonly associated with the law of large numbers.

8.10 Analysis of Simulated Data

Generating simulated observations is only the beginning. Data Science requires the resulting data to be analysed and interpreted.

Common analytical measures include:

  • frequency;
  • proportion;
  • mean;
  • median;
  • minimum and maximum;
  • range;
  • variance;
  • standard deviation; and
  • probability estimates.

Example: Analysing Simulated Waiting Times:

Suppose a simulation produces the following waiting times, measured in minutes:

4, 7, 5, 10, 6, 8

Question: Determine the mean waiting time.

Solution:

First calculate the total:

4 + 7 + 5 + 10 + 6 + 8 = 40

There are six observations.

Mean = 40 / 6 = 6.67 minutes

Answer: The mean simulated waiting time is approximately 6.67 minutes.

This value provides a measure of the typical waiting time in the simulated system.

8.11 Analysing Frequency and Proportion

Frequency tells us how many times an outcome occurs. Proportion expresses that frequency relative to the total number of observations.

The basic relationship is:

Proportion = Frequency / Total observations

To express the proportion as a percentage:

Percentage = (Frequency / Total observations) × 100%

Worked Example:

A simulation of 200 delivery attempts produces the following results:

  • Successful deliveries = 184
  • Failed deliveries = 16

The simulated success proportion is:

184 / 200 = 0.92

Therefore:

0.92 × 100% = 92%

Answer: The simulated delivery success rate is 92%.

8.12 Simulation of Business Demand

Simulation is particularly useful when demand varies unpredictably.

Suppose a small business sells a product and expects daily demand to be one of the following values:

Daily Demand Probability
10 units 0.20
20 units 0.50
30 units 0.30

The probabilities add to 1:

0.20 + 0.50 + 0.30 = 1.00

A simulation can repeatedly select one of these demand levels according to the specified probabilities.

For example, one simulated sequence of ten days might be:

20, 30, 20, 10, 20, 30, 20, 20, 10, 30

The total simulated demand is:

20 + 30 + 20 + 10 + 20 + 30 + 20 + 20 + 10 + 30 = 210 units

The simulated average daily demand is therefore:

210 / 10 = 21 units per day

A business could repeat the simulation many times to investigate likely demand and determine an appropriate inventory level.

8.13 Simulation and Decision-Making

The value of simulation in Data Science lies largely in its ability to support decisions under uncertainty.

Consider a company deciding whether to operate with two or three delivery vehicles. A simulation can model customer demand, travel times, vehicle availability and delivery costs.

The company can then compare different scenarios.

Scenario Average Waiting Time Average Daily Cost
2 vehicles 38 minutes ₦120,000
3 vehicles 19 minutes ₦155,000

The second scenario reduces waiting time but increases operating cost. The decision-maker must therefore consider the organization's objectives rather than simply choosing the scenario with the lowest waiting time.

This demonstrates an important principle of Data Science: analysis provides evidence, but decision-making requires interpretation of that evidence within a practical context.

8.14 Scenario Analysis

Scenario analysis involves changing one or more assumptions of a model and examining how the outputs change.

For example, a hospital may simulate patient arrivals under three conditions:

  • normal patient demand;
  • 20% increase in patient demand; and
  • 40% increase in patient demand.

The hospital could then compare the predicted waiting times and resource requirements under each scenario.

Scenario analysis is valuable because decisions are rarely made under only one possible future condition.

8.15 Simulation in Different Fields

Healthcare:

Simulation can model patient arrivals, hospital capacity, treatment times, waiting lists and resource utilization.

Finance:

Simulation can be used to investigate uncertain financial outcomes, portfolio behaviour, cash flows and risk under specified assumptions.

Agriculture:

Models can simulate crop yields under different assumptions about rainfall, temperature, irrigation and other factors.

Business:

Businesses can simulate demand, inventory, customer behaviour, staffing and supply-chain operations.

Engineering:

Engineers use simulation to investigate system behaviour, reliability, production processes and performance before implementing physical changes.

Transportation:

Traffic flow, vehicle movement, travel demand and public transportation systems can be modelled and simulated.

Education:

Simulation can model student enrolment, classroom capacity, resource requirements and other educational planning problems.

8.16 Limitations of Simulation

Simulation is powerful, but its results are not automatically correct. A simulation is only as useful as the assumptions, data and model on which it is based.

Model assumptions:

If important aspects of the real system are omitted or represented incorrectly, the simulation may produce misleading results.

Poor-quality input data:

If the probability estimates or other input values are inaccurate, the simulated results may also be inaccurate.

Random variation:

Different simulation runs can produce different results. This is why repeated trials are often necessary.

Computational cost:

Complex simulations involving millions of observations or highly detailed systems may require substantial computing resources.

False precision:

A simulation can produce results with many decimal places without those results actually being highly accurate. Numerical precision should not be confused with model accuracy.

Common mistake: A student may assume that because a computer produced a simulation result, the result must be correct. The computer executes the model; it does not guarantee that the model represents reality correctly.

8.17 Common Mistakes in Simulation

  1. Confusing simulation with prediction. A simulation explores possible outcomes under specified assumptions; it does not guarantee that a particular outcome will occur.
  2. Using unrealistic assumptions. A model must be based on reasonable representations of the system.
  3. Running too few trials. Small numbers of trials may produce unstable estimates.
  4. Ignoring random variation. Different runs can produce different results.
  5. Interpreting simulated data without context. A numerical result must be connected to the original problem.
  6. Confusing theoretical probability with simulated frequency. A finite simulation does not necessarily reproduce the theoretical probability exactly.
  7. Assuming more complexity always means a better model. A useful model should contain the necessary details without unnecessary complexity.

8.18 Key Points

  • Simulation uses a model to imitate a real or proposed system.
  • Simulation is particularly useful when direct experimentation is expensive, dangerous, difficult or impossible.
  • Probability provides a mathematical framework for uncertainty in simulation.
  • Random variables allow uncertain quantities to be represented.
  • Computer simulations commonly use pseudorandom numbers.
  • A simulation normally involves defining a problem, identifying variables, specifying assumptions, generating outcomes, running trials and analysing results.
  • Repeated simulation can produce more stable estimates of uncertain outcomes.
  • Simulated data can be analysed using descriptive statistics such as frequency, proportion, mean and standard deviation.
  • Scenario analysis allows different assumptions to be compared.
  • Simulation can support decision-making in healthcare, finance, agriculture, business, engineering, transportation and other fields.
  • A simulation is not automatically accurate simply because it is computer-generated.
  • The validity of simulation results depends strongly on the quality of the model, assumptions and input data.

8.19 Chapter Summary

Simulation is a fundamental technique for studying systems that contain uncertainty or are difficult to investigate directly. It involves constructing a model of a real-world system and using that model to conduct controlled experiments.

Probability plays an important role because many simulations contain random events. Random variables and probability distributions can be used to represent uncertain behaviour, while pseudorandom-number generators allow computers to produce large numbers of simulated observations.

The usefulness of simulation increases when it is combined with systematic data analysis. Simulated observations can be summarized using frequencies, proportions, averages and other statistical measures. Repeated simulation allows analysts to investigate the range and likelihood of possible outcomes rather than relying on a single trial.

Simulation is also an important decision-support technique. By comparing different scenarios, organizations can investigate the consequences of alternative strategies before implementing them in the real world. However, simulation results depend on the assumptions and data used to construct the model. A poorly designed model can produce precise-looking but misleading results.

The fundamental relationship can therefore be expressed as:

Probability represents uncertainty → Simulation reproduces possible outcomes → Data Analysis interprets the outcomes → Decision-Making uses the evidence.

8.20 Review Exercises

A. Basic Questions:

  1. Define simulation.
  2. What is a simulation model?
  3. State four situations in which simulation may be useful.
  4. What is a random event?
  5. Define a random variable.
  6. What is meant by an iteration in a simulation?
  7. Explain the relationship between probability and simulation.
  8. What is a pseudorandom number?

B. Understanding and Application:

  1. Explain why a supermarket might use simulation to study customer waiting times.
  2. Explain why simulation may be preferable to direct experimentation in a hospital.
  3. Distinguish between a real system and its simulation model.
  4. Explain why a simulation should normally be repeated several times.
  5. Why can a simulation produce a result that differs from the theoretical probability?
  6. Explain why poor input data can lead to unreliable simulation results.
  7. Describe how simulation can support inventory decisions in a business.

C. Quantitative Exercises:

  1. A simulation produces 500 trials, of which 425 result in success. Calculate the simulated probability of success.
  2. A simulated system records the following waiting times in minutes: 5, 7, 4, 9, 10, 5. Calculate the mean waiting time.
  3. A die is simulated 600 times and the number 4 appears 94 times. Calculate the observed proportion of fours and compare it with the theoretical probability.
  4. A simulation of a production system records 720 successful operations out of 800 attempts. Calculate the success percentage.
  5. A business simulation produces daily sales of 15, 20, 25, 30 and 10 units over five simulated days. Calculate the average daily sales.

D. Higher-Order Thinking:

  1. A company uses a simulation to estimate customer demand but obtains results that differ substantially from actual sales. Identify possible reasons for the difference and explain how the model could be improved.
  2. Two simulation models are developed for the same business problem. Model A is highly detailed but requires considerable computing time. Model B is simpler and produces results quickly. Explain why Model B might sometimes be preferable.
  3. A simulation predicts that adding three employees will reduce customer waiting time by 40%, but the actual reduction is only 15%. Discuss possible explanations for the difference.
  4. Explain why a simulation should not be treated as proof that a particular future event will occur.
  5. Design a simple simulation problem for a university cafeteria. Identify the system, inputs, random variables, outputs and performance measures.

CHAPTER NINE

Predictions and Models

9.1 Chapter Introduction

One of the important objectives of Data Science is to use available data to understand patterns and make informed statements about what may happen in the future or under conditions that have not yet been observed. This process is commonly referred to as prediction.

Prediction does not mean knowing the future with certainty. Instead, a prediction is an estimate produced from information available to a data scientist. The estimate may concern a numerical quantity, such as the expected price of a house, or a category, such as whether a transaction is likely to be fraudulent.

Predictions are normally produced using models. A model is a simplified representation of a real-world process or relationship. In Data Science, models are constructed from data so that they can identify useful relationships between variables and use those relationships to estimate outcomes for new observations.

This chapter introduces the fundamental ideas behind prediction and modelling. It explains the relationship between data and models, introduces basic predictive concepts, distinguishes training from testing, and discusses how predictions can be interpreted and evaluated.

9.2 Learning Objectives

At the end of this chapter, the student should be able to:

  • define prediction in the context of Data Science;
  • explain the meaning and purpose of a model;
  • describe the relationship between data and predictive models;
  • distinguish between predictors, features and target variables;
  • differentiate classification from regression;
  • explain the basic idea of training and testing a model;
  • explain why unseen data are important when evaluating a model;
  • interpret basic model predictions;
  • describe common measures used to evaluate predictions; and
  • identify common problems that can make predictions unreliable.

9.3 Key Terminology

  • Prediction: An estimate of an unknown or future outcome based on available information.
  • Model: A mathematical, statistical or computational representation of relationships or patterns in data.
  • Feature: A variable used by a model to help explain or predict an outcome.
  • Target variable: The outcome that a predictive model is designed to estimate.
  • Training data: Data used to develop or fit a model.
  • Testing data: Data reserved for evaluating how well a trained model performs on previously unseen observations.
  • Regression: A predictive task in which the target is usually numerical.
  • Classification: A predictive task in which the target belongs to one or more categories.
  • Prediction error: The difference between an observed outcome and the corresponding predicted value.
  • Overfitting: A situation in which a model learns the training data too closely and performs poorly on new data.

9.4 Meaning of Prediction

In ordinary language, to predict means to state what one expects to happen. In Data Science, prediction has a more specific meaning: it is the process of using known information to estimate an unknown outcome.

Suppose a bank has information about a customer's income, repayment history, existing debts and previous loan applications. A predictive model can use these variables to estimate the probability that the customer will repay a new loan.

Similarly, a hospital may use information about a patient to estimate the risk of developing a particular condition, while a retailer may use previous purchasing behaviour to estimate which products a customer is likely to buy.

Important: A prediction is not necessarily a fact. It is an estimate based on available evidence and the assumptions, data and methods used to construct the model.

Prediction and Explanation:

Prediction and explanation are related but different objectives.

A model designed primarily for prediction seeks to produce accurate estimates for new observations. A model designed for explanation seeks to help researchers understand relationships between variables.

For example, a company may want to predict which customers are likely to stop using its service. It may not be necessary for the model to provide a complete explanation of every psychological or economic reason behind customer behaviour. Its primary objective may simply be to identify customers who are at high risk of leaving.

9.5 What Is a Model?

A model is a simplified representation of a real-world system, process or relationship.

Real-world systems are usually too complicated to represent in their entirety. A model therefore focuses on selected characteristics that are considered useful for a particular purpose.

In Data Science, a model may be represented using mathematical equations, statistical relationships, decision rules, trees, algorithms or other computational structures.

Example: House Price Model:

Suppose we want to estimate the price of a house. The actual price may depend on many factors, including:

  • floor area;
  • number of bedrooms;
  • location;
  • age of the building;
  • condition of the property;
  • availability of parking;
  • land size; and
  • market conditions.

A model does not necessarily need to represent every factor. It may use a selected set of variables to estimate the price.

A simple mathematical model might have the form:

Price = β0 + β1(Area) + β2(Bedrooms)

Here, β0, β1 and β2 are model parameters determined from data.

The model is a simplified representation because the real price of a house is influenced by many factors that may not be included.

9.6 Purpose of Models in Data Science

Models serve several important purposes.

1. Prediction:

A model can be used to estimate an unknown or future outcome.

Example: Predicting tomorrow's electricity demand from historical consumption, weather and calendar information.

2. Classification:

A model can assign observations to categories.

Example: Classifying an email as either spam or legitimate.

3. Pattern Recognition:

A model can identify recurring relationships or structures within data.

Example: Identifying groups of customers with similar purchasing behaviour.

4. Decision Support:

Predictions from models can support human decision-making.

Example: A bank may use a credit-risk model as one source of information when deciding whether to approve a loan.

5. Simulation and Scenario Analysis:

Models can be used to examine what may happen under different assumptions.

Example: A business can model expected sales under different pricing strategies.

9.7 The Relationship Between Data and Models

Data and models are closely connected. A predictive model requires information from which it can learn or estimate relationships. At the same time, the usefulness of a model depends strongly on the quality and relevance of the data used to construct it.

Data → Model → Prediction → Evaluation → Improvement

The basic relationship can be understood as follows:

  1. Data are collected: Relevant observations are obtained.
  2. Data are prepared: Errors, missing values and unsuitable formats are addressed.
  3. Patterns are identified: A suitable modelling method is selected.
  4. The model is trained: The model parameters are estimated from training data.
  5. Predictions are produced: The model is applied to new observations.
  6. Predictions are evaluated: Predictions are compared with known outcomes where possible.
  7. The model is improved: If necessary, data, features, algorithms or model parameters are reconsidered.

This relationship demonstrates why Data Science is not simply the process of applying an algorithm to a dataset. Data preparation, problem definition, model selection and evaluation are equally important.

9.8 Features and Target Variables

Predictive modelling normally involves distinguishing between information used to make a prediction and the outcome that the model is expected to predict.

Features:

A feature is a variable supplied to a model as information that may help predict the target.

Features may also be called predictor variables, input variables or, in some contexts, explanatory variables.

Target Variable:

The target variable is the outcome the model is designed to predict. It may also be called the response variable, output variable or dependent variable, depending on the modelling context.

Problem Possible Features Target
House-price prediction Area, bedrooms, location House price
Spam detection Words, sender information, message characteristics Spam or not spam
Student performance Attendance, previous scores, study hours Final score
Customer churn Usage, subscription duration, complaints Churn or no churn

9.9 Regression and Classification

Two fundamental types of predictive tasks are regression and classification.

Regression:

Regression is generally used when the target variable is numerical.

Examples include:

  • predicting house price;
  • predicting temperature;
  • predicting monthly sales;
  • predicting electricity consumption; and
  • predicting a patient's length of hospital stay.

A regression model might predict that a house will sell for ₦85,000,000. The result is a numerical value.

Classification:

Classification is used when the target variable represents a category or class.

Examples include:

  • spam versus legitimate email;
  • fraud versus legitimate transaction;
  • pass versus fail;
  • high-risk versus low-risk customer; and
  • disease-positive versus disease-negative classification.

A classification model may produce a probability for each class before assigning the observation to a particular category.

Feature Regression Classification
Target Usually numerical Category or class
Example Predict sales revenue Predict whether a customer will leave
Typical output A number A class or class probability

9.10 Basic Predictive Modelling Example

Consider a small dataset containing the number of hours students spend studying and their examination scores.

Student Study Hours Score (%)
A248
B355
C461
D569
E675

Here, study hours is a feature and examination score is the target variable.

A simple regression model could attempt to learn the relationship between study hours and examination score. Once trained, the model could be used to estimate the score of a student whose study hours are known but whose examination result is not yet available.

It is important to understand that the relationship observed in this small dataset does not prove that study time is the only cause of examination performance. Other factors may influence the result.

9.11 Training a Model

Training is the process through which a model learns patterns or estimates parameters from data.

Suppose a model is intended to predict examination scores. During training, the model receives examples containing both the input variables and their corresponding known outcomes. The modelling algorithm adjusts its parameters so that its predictions become suitable for the training data according to a chosen objective.

Training therefore does not mean that the computer is learning in the same sense that a human student learns. It means that an algorithm is using data to determine parameters or patterns according to a defined mathematical or computational procedure.

Example:

Suppose the following simple model is proposed:

Score = 40 + 6(Study Hours)

If a student studies for 5 hours:

Score = 40 + 6(5)

Score = 40 + 30 = 70

The predicted score is therefore 70%.

In a real modelling process, the coefficients would normally be estimated from data rather than simply selected arbitrarily.

9.12 Testing a Model

A model that performs well on the data used to train it is not automatically a good model. The important question is whether it can perform satisfactorily on new observations.

For this reason, part of the available dataset is often reserved for testing.

A simple arrangement is:

Training Data

Used to develop or fit the model.

Testing Data

Used to evaluate performance on unseen observations.

The test data should represent the type of observations on which the model is expected to operate. If the test data are improperly selected, the evaluation may give a misleading impression of model performance.

9.13 Why Unseen Data Matter

Consider a student who memorizes the exact answers to ten questions and then receives the same ten questions in an examination. A perfect score would demonstrate that the student remembers those questions, but it would not necessarily demonstrate that the student understands the subject well enough to answer new questions.

A similar problem can occur with predictive models.

A model can learn the training observations extremely well without learning a general pattern that works on new observations. This is one reason why model evaluation must involve data that were not used to fit the model.

9.14 Overfitting

Overfitting occurs when a model learns the training data too closely, including patterns that do not generalize well to new observations.

An overfitted model may produce excellent results on training data but poor results on testing data.

For example, imagine that examination performance is generally related to study time, but a dataset contains a few unusual students. A highly complicated model may attempt to reproduce every unusual observation rather than identifying the general relationship.

Situation Training Performance New-Data Performance
Good general model Good Good
Overfitted model Very good Poor
Poorly fitted model Poor Poor

The goal is therefore not simply to maximize performance on training data. The objective is to develop a model that captures useful patterns and generalizes to appropriate new observations.

9.15 Prediction Error

A prediction can differ from the actual observed value. The difference is referred to as prediction error.

For a numerical prediction, a simple error can be expressed as:

Error = Actual Value − Predicted Value

Worked Example:

Question: A model predicts that a student's examination score will be 72%. The actual score is 78%. Determine the prediction error.

Given:

  • Actual value = 78%
  • Predicted value = 72%

Formula:

Error = Actual − Predicted

Solution:

Error = 78 − 72 = 6 percentage points

Answer: The prediction error is +6 percentage points. The model underestimated the student's score by 6 percentage points.

If the predicted value had been 82% instead, the error would be:

Error = 78 − 82 = −4 percentage points

The negative sign indicates that the model overestimated the actual score.

9.16 Mean Absolute Error

When several predictions are made, examining individual errors may not be sufficient. One common measure for numerical predictions is Mean Absolute Error (MAE).

MAE is calculated as:

MAE = (Σ |Actual − Predicted|) / n

where:

  • Σ means that the values are added together;
  • |Actual − Predicted| is the absolute prediction error; and
  • n is the number of observations.

Worked Example:

Question: A model produces the following predictions:

Observation Actual Predicted Absolute Error
180764
265705
390873

Solution:

Total absolute error:

4 + 5 + 3 = 12

Number of observations:

n = 3

Therefore:

MAE = 12 / 3 = 4

Answer: The mean absolute error is 4 percentage points.

This means that, on average, the model's predictions differ from the observed scores by 4 percentage points when measured using absolute error.

9.17 Classification Predictions

Prediction in classification problems is different from numerical prediction. Instead of predicting a continuous numerical value, the model predicts a category.

For example, suppose a model is designed to determine whether an email is spam.

The possible classes may be:

  • Spam
  • Not Spam

A classification model may produce a probability such as:

Probability of Spam = 0.91

If the selected classification threshold is 0.50, the email would normally be classified as spam because 0.91 is greater than 0.50.

The threshold is important because changing it can change the number of observations assigned to each class.

9.18 Interpreting Predictions

A prediction should not be reported without considering what it means in context.

Suppose a model predicts that a customer has a 0.80 probability of leaving a service. This does not mean that the customer will definitely leave. It means that, according to the model and its assumptions, the customer belongs to a group for which the estimated probability of the outcome is 80%.

Good interpretation should therefore consider:

  • what the model was designed to predict;
  • which variables were used;
  • how the model was trained;
  • how the prediction was generated;
  • how accurate the model is;
  • the uncertainty associated with the prediction; and
  • the consequences of acting on the prediction.

Important distinction: A model prediction is evidence to support a decision, not necessarily a substitute for human judgment.

9.19 Evaluating Predictions

Model evaluation involves determining how well a model performs for its intended purpose.

The appropriate evaluation measure depends on the type of prediction being made.

For Numerical Predictions:

Common measures include:

  • Mean Absolute Error (MAE): measures the average absolute difference between predicted and observed values.
  • Mean Squared Error (MSE): calculates the average of squared prediction errors.
  • Root Mean Squared Error (RMSE): is the square root of MSE and expresses error in the same units as the target variable.

These measures provide different ways of describing prediction error and should be interpreted in relation to the problem being studied.

For Classification:

Common evaluation concepts include:

  • Accuracy: the proportion of predictions that are correct.
  • Precision: the proportion of observations predicted as positive that are actually positive.
  • Recall: the proportion of actual positive observations that the model correctly identifies.
  • Confusion matrix: a table that summarizes correct and incorrect classification results by class.

No single measure is appropriate for every problem. For example, accuracy may be misleading when one class is much more common than another.

9.20 Confusion Matrix: Basic Idea

For a two-class classification problem, predictions can be divided into four basic categories.

Actual / Predicted Positive Negative
Positive True Positive (TP) False Negative (FN)
Negative False Positive (FP) True Negative (TN)

For example, if a model is used to identify fraudulent transactions:

  • True Positive: the transaction is fraudulent and the model identifies it as fraudulent.
  • True Negative: the transaction is legitimate and the model identifies it as legitimate.
  • False Positive: the transaction is legitimate but the model incorrectly identifies it as fraudulent.
  • False Negative: the transaction is fraudulent but the model incorrectly identifies it as legitimate.

9.21 Accuracy

For a classification problem, accuracy can be calculated as:

Accuracy = (TP + TN) / (TP + TN + FP + FN)

Worked Example:

Question: A fraud-detection model produces the following results:

  • TP = 80
  • TN = 850
  • FP = 20
  • FN = 50

Required: Calculate the accuracy.

Formula:

Accuracy = (TP + TN) / (TP + TN + FP + FN)

Solution:

Accuracy = (80 + 850) / (80 + 850 + 20 + 50)

Accuracy = 930 / 1000 = 0.93

Converting to percentage:

0.93 × 100 = 93%

Answer: The model has an accuracy of 93%.

9.22 Precision and Recall

In some applications, accuracy alone does not provide enough information.

Precision answers the question: Of the observations the model predicted as positive, how many were actually positive?

Precision = TP / (TP + FP)

Recall answers the question: Of all the observations that were actually positive, how many did the model correctly identify?

Recall = TP / (TP + FN)

Consider a medical screening system. If failing to identify a genuine positive case has serious consequences, recall may be particularly important. In another application, excessive false alarms may be costly, making precision particularly important.

9.23 Model Generalization

Generalization refers to the ability of a model to perform effectively on new observations that were not used to train it.

A model with good generalization has learned useful patterns rather than simply memorizing the training data.

Generalization is one of the central ideas in predictive modelling because real-world users normally want predictions for future or previously unseen cases.

For example, if a model is trained using customer transactions from January to June, the practical objective may be to use it to make useful predictions for customers or transactions encountered later.

9.24 Common Problems in Prediction and Modelling

1. Poor-Quality Data:

Incorrect, incomplete or inconsistent data can produce unreliable models.

2. Insufficient Data:

A very small dataset may not contain enough information to represent the underlying population adequately.

3. Irrelevant Features:

Variables that have little meaningful relationship with the target may add noise and reduce model usefulness.

4. Data Leakage:

Data leakage occurs when information that would not genuinely be available at prediction time is inadvertently used to build the model. This can make the model appear more accurate than it really is.

5. Overfitting:

A model may fit the training data too closely and fail to generalize to new data.

6. Underfitting:

Underfitting occurs when a model is too simple to capture important patterns in the data.

7. Biased Data:

If the training data do not adequately represent the population or problem of interest, model predictions may be systematically unreliable for some groups or situations.

8. Changing Conditions:

Relationships observed in historical data may change over time. A model that was effective in the past may become less reliable when the underlying environment changes.

9.25 Common Mistakes Made by Students

  • Confusing prediction with certainty: A prediction is an estimate, not a guaranteed future event.
  • Assuming a complex model is always better: Greater complexity can increase the risk of overfitting.
  • Evaluating only on training data: Training performance does not necessarily represent performance on new data.
  • Confusing regression and classification: Regression generally predicts numerical quantities, while classification predicts categories.
  • Ignoring the quality of data: A sophisticated algorithm cannot automatically correct every problem in the underlying data.
  • Interpreting probability as certainty: A probability of 0.80 does not mean that an event is guaranteed to occur.
  • Using accuracy without considering the problem: Accuracy may be misleading when classes are highly imbalanced.
  • Assuming correlation proves causation: A predictive relationship does not automatically establish that one variable causes another.

9.26 Key Points

  • Prediction is the process of estimating an unknown or future outcome using available information.
  • A model is a simplified representation of a real-world process or relationship.
  • Data provide the evidence from which many predictive models are developed.
  • Features are variables supplied to a model as predictive information.
  • The target variable is the outcome the model is designed to predict.
  • Regression is generally used for numerical targets.
  • Classification is used for categorical targets.
  • Training data are used to fit a model.
  • Testing data are used to evaluate the model on unseen observations.
  • Good model performance on training data does not guarantee good performance on new data.
  • Overfitting occurs when a model learns training data too closely and generalizes poorly.
  • Prediction error measures the difference between observed and predicted outcomes.
  • MAE is one common measure for evaluating numerical predictions.
  • Accuracy, precision and recall are among the measures used for classification problems.
  • Model evaluation must be appropriate to the prediction problem and its practical consequences.
  • A useful model should generalize to appropriate new observations.

9.27 Chapter Summary

Prediction is a central activity in Data Science because organizations frequently need to estimate outcomes that are unknown, future or otherwise unavailable at the time a decision must be made. Predictions are produced using models that represent useful relationships or patterns in data.

A predictive modelling problem generally involves features and a target variable. The features provide information used to make the prediction, while the target represents the outcome being predicted. Depending on the nature of the target, predictive problems may involve regression or classification.

Models are developed using training data and evaluated using previously unseen testing data. This separation is important because a model should demonstrate its ability to generalize rather than simply reproduce the observations on which it was trained.

Prediction errors provide a basis for evaluating model performance. For numerical predictions, measures such as MAE, MSE and RMSE can be used. For classification, measures such as accuracy, precision and recall provide different perspectives on model performance.

A good predictive model is not necessarily the most complicated model. It is a model that is appropriate to the problem, supported by suitable data, evaluated correctly and capable of producing useful predictions on relevant new observations.

The Core Idea to Remember:

Data → Model → Prediction → Evaluation → Decision

Data provide evidence, models learn or represent relationships, predictions estimate outcomes, evaluation measures performance, and the resulting information can support informed decisions.

9.28 Worked Review Examples

Example 1: Identifying the Target:

Question: A university wants to predict students' final examination scores using attendance, continuous-assessment score and study hours. Identify the features and target.

Solution:

  • Attendance = feature
  • Continuous-assessment score = feature
  • Study hours = feature
  • Final examination score = target

Because the final examination score is numerical, this is a regression problem.

Example 2: Identifying the Type of Prediction:

Question: A bank wants to determine whether a loan applicant will default or not default.

Solution: The target consists of categories such as default and no default. Therefore, this is a classification problem.

Example 3: Calculating Prediction Error:

Question: A model predicts monthly sales of ₦4,800,000, while actual sales are ₦5,200,000. Calculate the prediction error.

Formula:

Error = Actual − Predicted

Solution:

Error = ₦5,200,000 − ₦4,800,000 = ₦400,000

Answer: The model underestimated sales by ₦400,000.

Example 4: Interpreting a Classification Probability:

Question: A fraud-detection model gives a transaction a fraud probability of 0.87. Explain what this means.

Answer: The model estimates a probability of 87% for the fraud class under the modelling framework used. It does not establish with certainty that the transaction is fraudulent. A decision rule or threshold may subsequently be used to convert the probability into a class prediction.

9.29 Exercises

Part A: Basic Understanding:

  1. Define prediction in the context of Data Science.
  2. What is a model?
  3. Explain the difference between a feature and a target variable.
  4. What is training data?
  5. What is testing data?
  6. Distinguish between regression and classification.
  7. Explain why unseen data are important when evaluating a predictive model.
  8. What is overfitting?

Part B: Application:

  1. A supermarket wants to predict the amount a customer will spend during the next visit. Identify three possible features and the target variable.
  2. A university wants to predict whether a student will graduate on time. Is this primarily a regression or classification problem? Explain.
  3. A weather model predicts a temperature of 31°C, while the actual temperature is 34°C. Calculate the prediction error.
  4. A model predicts a house price of ₦95 million, while the actual selling price is ₦100 million. Calculate the prediction error and state whether the model overestimated or underestimated the price.
  5. Explain why a model with 99% accuracy on training data may still be unsuitable for practical use.

Part C: Quantitative Questions:

  1. A model predicts examination scores of 70, 65, 80 and 90 for four students. The actual scores are 75, 60, 84 and 86 respectively. Calculate the absolute error for each student and determine the MAE.
  2. A classification model produces TP = 72, TN = 810, FP = 18 and FN = 100. Calculate its accuracy.
  3. Using the values in Question 2, calculate precision and recall.
  4. A model predicts a sales value of ₦8.5 million, while the actual value is ₦7.9 million. Calculate the prediction error and interpret its sign.

Part D: Higher-Order Questions:

  1. Explain why a highly complex predictive model can perform worse on new data than a simpler model.
  2. Discuss why data quality is important even when an advanced modelling algorithm is used.
  3. A disease-screening system has high accuracy but misses a significant number of genuine positive cases. Explain why accuracy alone may not be sufficient for evaluating the system.
  4. Explain the difference between a model that predicts well and a model that explains a phenomenon well.
  5. A company wants to use historical customer behaviour to predict future customer churn. Identify at least four factors that should be considered before deploying the model.

9.30 Examination-Style Questions

  1. Define a predictive model and explain its importance in Data Science.
  2. With suitable examples, distinguish between regression and classification.
  3. Explain the relationship between data, features, target variables, models and predictions.
  4. Describe the purpose of training and testing datasets in predictive modelling.
  5. Explain overfitting and discuss why it is undesirable.
  6. A predictive model produces the following results: TP = 90, TN = 860, FP = 30 and FN = 20. Calculate the accuracy, precision and recall.
  7. A regression model produces the following predictions:
Observation Actual Value Predicted Value
15047
26570
38076
49094
  1. Using the table above, calculate the absolute error for each observation and determine the MAE.
  2. Discuss at least five factors that can cause a predictive model to produce unreliable results.
  3. Explain why the quality of a prediction should be evaluated in relation to the purpose for which the model is being used.

CHAPTER TEN

Knowledge Extraction

10.1 Introduction

Data Science is concerned not only with collecting and analysing data but also with discovering useful patterns, relationships and insights within that data. The ultimate purpose of many data-driven activities is to move from large quantities of raw data to information that can support understanding and informed decision-making.

Knowledge extraction refers to the systematic process of discovering useful information, patterns, relationships and knowledge from data. It involves examining data, identifying meaningful structures and interpreting the results within a particular context.

For example, a supermarket may have millions of transaction records. The raw records themselves are data. After analysis, the business may discover that customers who purchase baby products frequently purchase certain household products during the same shopping period. That discovered relationship can become useful knowledge for inventory management, product placement or recommendation systems.

Knowledge extraction therefore represents an important stage in the transformation of data into something that can support practical action.

10.2 Data, Information and Knowledge

Understanding knowledge extraction requires a clear distinction between data, information and knowledge. Although these terms are sometimes used interchangeably in everyday language, they describe different levels of meaning in Data Science.

Data:

Data consists of recorded observations, measurements, values, symbols or facts. Data may exist as numbers, text, images, audio, video, dates, categories or other forms.

Consider the following examination scores:

65, 72, 81, 58, 74, 90, 63

These values are data. By themselves, they provide limited information about the students or the examination.

Information:

Information is data that has been processed, organized or summarized so that it becomes meaningful.

For example, calculating the average of the seven scores gives approximately 71.9. The average provides more useful information than simply viewing the individual scores.

Knowledge:

Knowledge involves understanding what the information means and how it can be used. For example, an academic department may discover that students who attend practical laboratory sessions regularly tend to achieve higher examination scores.

The numerical records are data. The calculated relationship is information. Understanding that regular practical participation may contribute to improved academic performance, together with the contextual interpretation needed to act on it, represents knowledge.

Level Meaning Example
Data Recorded facts or observations. 65, 72, 81, 58, 74
Information Processed data with meaning. The class average is 70.
Knowledge Useful understanding derived from information and context. Students receiving additional support show improved performance.

10.3 Meaning of Knowledge Extraction

Knowledge extraction is the process of identifying meaningful and useful knowledge from available data. It combines data preparation, analysis, pattern discovery and interpretation.

The process can be represented conceptually as:

Raw Data
→
Processed Data
→
Patterns
→
Knowledge

The objective is not simply to find any pattern. A useful knowledge-extraction process should seek patterns that are meaningful, reliable and relevant to the problem being investigated.

Example:

Suppose a bank has records containing customer age, income, transaction frequency, account balance and loan repayment history.

After analysing these records, a Data Scientist may discover that customers with certain combinations of characteristics are more likely to default on loans.

The discovered relationship may then be used as part of a credit-risk assessment system. The value of the process lies not merely in identifying a statistical relationship but in understanding and appropriately applying the relationship.

10.4 Knowledge Discovery from Data

Knowledge Discovery from Data (KDD) is a structured process for discovering useful and understandable patterns from datasets.

KDD is broader than data mining. Data mining is generally considered one stage within the larger knowledge-discovery process.

This distinction is important. A data-mining algorithm may identify a pattern, but the complete KDD process also considers where the data came from, whether the data is suitable, how it should be prepared, whether the discovered pattern is meaningful and how the result should be interpreted.

Important distinction: Data mining is not synonymous with the entire KDD process. Data mining is a major analytical stage within the broader process of discovering knowledge from data.

10.5 Stages of Knowledge Discovery

The exact description of KDD stages may vary among textbooks and applications, but a typical process contains the following major stages:

  1. Data selection
  2. Data preprocessing and cleaning
  3. Data transformation
  4. Data mining or pattern discovery
  5. Pattern evaluation
  6. Knowledge interpretation and presentation

10.5.1 Data Selection:

The first step is to identify and select the data relevant to the problem.

A dataset may contain hundreds or thousands of variables, but not every variable will be useful for a particular analysis.

Example: If a university wants to study factors associated with student academic performance, relevant variables may include examination scores, attendance, course registration and study time. A student's favourite colour is unlikely to be useful for this particular investigation.

Data selection therefore reduces irrelevant information and focuses the analysis on the problem of interest.

10.5.2 Data Preprocessing and Cleaning:

Selected data may contain missing values, duplicate records, incorrect entries, inconsistent formats and other quality problems.

Preprocessing involves identifying and addressing these problems before advanced analysis is performed.

For example, the same date might appear as:

  • 12/08/2026
  • 2026-08-12
  • August 12, 2026

These values may represent the same date but use different formats. Standardizing the representation helps prevent inconsistencies during analysis.

10.5.3 Data Transformation:

Data transformation changes data into a form that is more suitable for analysis.

Examples include:

  • converting units;
  • scaling numerical variables;
  • encoding categorical variables;
  • aggregating records;
  • creating derived variables; and
  • transforming highly skewed measurements when appropriate.

Example: If temperature is recorded in Fahrenheit but an analysis requires Celsius, the values may be converted using:

°C = (°F − 32) × 5/9

Transformation does not necessarily create new information. Rather, it places existing data into a more useful analytical form.

10.5.4 Data Mining and Pattern Discovery:

At this stage, computational, statistical or mathematical methods are applied to discover patterns or relationships.

Common tasks include:

  • classification;
  • clustering;
  • association analysis;
  • regression;
  • anomaly detection; and
  • pattern recognition.

Example: A retailer may analyse transaction records to determine which products are frequently purchased together.

10.5.5 Pattern Evaluation:

Not every pattern discovered in data is useful. A large dataset can produce accidental relationships that have little practical meaning.

Pattern evaluation determines whether a discovered pattern is relevant, reliable, sufficiently strong and useful for the problem under investigation.

For example, a correlation between two variables does not automatically mean that one variable causes the other. A Data Scientist must consider the context and possible alternative explanations.

10.5.6 Knowledge Interpretation and Presentation:

The final stage involves interpreting meaningful patterns and presenting them in a form that users can understand and apply.

Results may be communicated through:

  • reports;
  • tables;
  • charts and graphs;
  • dashboards;
  • statistical summaries;
  • recommendations; or
  • decision-support systems.

The goal is to transform analytical findings into understandable knowledge that can support an appropriate action or conclusion.

10.6 The Knowledge Discovery Pipeline

Typical Knowledge Discovery Pipeline

1. Problem Definition — Determine what needs to be understood.
↓
2. Data Selection — Identify relevant data.
↓
3. Data Cleaning — Correct or manage data-quality problems.
↓
4. Data Transformation — Prepare variables for analysis.
↓
5. Pattern Discovery — Apply analytical and computational methods.
↓
6. Pattern Evaluation — Determine which patterns are meaningful.
↓
7. Interpretation — Convert useful patterns into understandable knowledge.

10.7 Techniques Used in Knowledge Extraction

Different types of problems require different analytical techniques. Some common approaches are described below.

Classification:

Classification assigns observations to predefined categories or classes.

Example: A financial institution may classify loan applications as low risk, medium risk or high risk based on relevant characteristics.

Clustering:

Clustering groups observations according to similarities without requiring predefined categories.

Example: A retailer may group customers into segments based on purchasing behaviour.

Association Analysis:

Association analysis identifies relationships between items or events that frequently occur together.

Example: A supermarket may discover that customers who purchase bread frequently purchase a particular spread during the same shopping trip.

Regression:

Regression examines relationships between variables and can be used to estimate or predict numerical outcomes.

Example: A housing company may analyse how property size, location and number of bedrooms relate to selling price.

Anomaly Detection:

Anomaly detection identifies observations that differ substantially from expected patterns.

Example: A bank may detect a transaction that is unusually large or occurs in an unusual location compared with a customer's normal transaction behaviour.

10.8 From Raw Data to Useful Knowledge

The transformation from raw data to knowledge is not a single operation. It is a sequence of increasingly meaningful stages.

Stage Question Being Answered Example
Raw data What was recorded? Individual transaction records.
Cleaning Can the data be trusted? Removing duplicates and correcting invalid entries.
Analysis What patterns exist? Certain products are frequently purchased together.
Interpretation What do the patterns mean? Customers may have related purchasing needs.
Knowledge How can the finding be used? Improve product placement or recommendations.

10.9 A Practical Example of Knowledge Extraction

Consider a university that wants to understand factors associated with student academic performance.

Step 1: Define the problem:

The university wants to identify factors associated with students' final examination performance.

Step 2: Select relevant data:

The university collects information such as:

  • attendance rate;
  • continuous assessment score;
  • examination score;
  • number of assignments submitted;
  • study hours; and
  • previous academic performance.

Step 3: Clean the data:

The Data Scientist checks for missing scores, duplicate student records, impossible attendance values and inconsistent formats.

Step 4: Transform the data:

Variables may be converted into suitable numerical forms. For example, attendance may be represented as a percentage, while categorical variables may be encoded for computational analysis.

Step 5: Discover patterns:

The data is analysed to determine whether variables such as attendance, assignment completion and study time are associated with examination performance.

Step 6: Evaluate the patterns:

The Data Scientist examines whether the relationships are sufficiently strong and reliable to be useful. A relationship should not automatically be interpreted as proof of causation.

Step 7: Interpret the results:

Suppose the analysis indicates that students with consistently high attendance and assignment completion tend to achieve higher examination scores.

The university may interpret this as evidence of an association between academic engagement and performance. However, other factors may also influence results.

Step 8: Communicate the knowledge:

The findings could be presented using charts, statistical summaries and a report for academic administrators.

The final objective is not merely to produce a statistical output but to provide understandable knowledge that can support evidence-based educational decisions.

10.10 Knowledge Extraction and Data Science

Knowledge extraction is closely connected to the broader Data Science process. Data Scientists work with data to answer questions, discover patterns, make predictions and support decisions.

The relationship can be represented as:

Data Collection
→
Preparation
→
Analysis
→
Pattern Discovery
→
Knowledge

Knowledge extraction therefore connects analytical activity with practical understanding. It helps answer questions such as:

  • What patterns exist in the data?
  • Which relationships are meaningful?
  • What unusual behaviour can be detected?
  • What groups or categories exist?
  • What factors appear to be associated with an outcome?
  • What useful conclusions can be drawn from the evidence?

10.11 Importance of Knowledge Extraction

Knowledge extraction is important because modern organizations generate data at a scale that cannot be effectively understood through manual inspection alone.

Improved Decision-Making:

Knowledge extracted from reliable data can support evidence-based decisions rather than decisions based solely on assumptions or intuition.

Pattern Identification:

Large datasets may contain relationships that are difficult to detect manually. Analytical methods can reveal recurring patterns and associations.

Prediction and Planning:

Knowledge discovered from historical data can contribute to predictive models and planning activities.

Problem Detection:

Knowledge extraction can reveal anomalies, unusual behaviour, errors and potential risks.

Business Intelligence:

Organizations can use extracted knowledge to understand customers, optimize operations, improve services and identify opportunities.

Scientific Discovery:

Researchers can analyse large datasets to identify relationships and patterns that may contribute to scientific understanding.

Automation:

Extracted patterns can be incorporated into software systems that automate certain decisions, recommendations or classifications.

10.12 Applications of Knowledge Extraction

Domain Example of Knowledge Extraction
Healthcare Identifying patterns associated with disease risk or treatment outcomes.
Finance Detecting unusual transactions and identifying patterns associated with credit risk.
Education Identifying factors associated with student performance and engagement.
Agriculture Discovering relationships between weather, soil conditions and crop performance.
Retail Identifying purchasing patterns and customer segments.
Government Analysing population and public-service data to identify trends and service needs.
Cybersecurity Detecting unusual network or user behaviour that may indicate security threats.
Transportation Identifying traffic patterns and travel behaviour.

10.13 Knowledge Extraction, Correlation and Causation

An important principle in knowledge extraction is that discovering a relationship between variables does not necessarily establish a cause-and-effect relationship.

Suppose an analysis discovers that ice-cream sales and the number of people visiting beaches increase at approximately the same time.

The two variables may be positively associated, but it would be incorrect to conclude that increased ice-cream sales cause people to visit beaches. A third factor, such as warmer weather, may influence both variables.

Key principle: Association indicates that variables are related in some way; it does not by itself prove that one variable causes another.

Data Scientists must therefore interpret extracted knowledge carefully and consider the context, study design, alternative explanations and limitations of the available data.

10.14 Quality of Extracted Knowledge

Useful knowledge should satisfy several important requirements.

Validity:

The discovered pattern should accurately represent the underlying data and analytical problem.

Reliability:

The finding should not depend entirely on accidental characteristics or errors in a particular dataset.

Relevance:

The knowledge should relate directly to the problem or question being investigated.

Understandability:

The result should be interpretable by the intended users. A technically complex model may produce useful results, but the findings still need to be communicated appropriately.

Usefulness:

The extracted knowledge should have practical, scientific or analytical value.

Timeliness:

In rapidly changing environments, old patterns may become less useful. Knowledge should therefore be interpreted in relation to the time period represented by the data.

10.15 Common Mistakes in Knowledge Extraction

1. Treating all discovered patterns as useful knowledge. A pattern may occur by chance or may have little practical significance.

2. Confusing data mining with KDD. Data mining is a major component of knowledge discovery, but KDD encompasses the broader process.

3. Ignoring data quality. Poor-quality input data can produce misleading results.

4. Assuming correlation proves causation. A statistical relationship alone does not establish cause and effect.

5. Ignoring context. A pattern may be meaningful in one environment but inappropriate in another.

6. Focusing only on algorithms. Knowledge extraction is not simply a technical exercise. Problem definition, data quality, interpretation and communication are equally important.

7. Confusing information with knowledge. A statistical table may provide information, but understanding what the results mean and how they can appropriately be used requires interpretation and context.

10.16 Key Points

  • Knowledge extraction involves discovering useful patterns, relationships and insights from data.
  • Data consists of recorded observations, while information is processed data with meaning.
  • Knowledge represents useful understanding derived from information, interpretation and context.
  • Knowledge Discovery from Data provides a structured framework for discovering useful patterns.
  • KDD commonly involves data selection, preprocessing, transformation, pattern discovery, pattern evaluation and interpretation.
  • Data mining is an important stage within the broader KDD process.
  • Classification assigns observations to predefined categories.
  • Clustering groups observations according to similarity.
  • Association analysis identifies items or events that frequently occur together.
  • Regression can be used to examine relationships between variables and estimate numerical outcomes.
  • Anomaly detection identifies observations that differ substantially from expected patterns.
  • Not every discovered pattern represents useful knowledge.
  • Data quality, context and interpretation are essential for reliable knowledge extraction.
  • Correlation or association should not automatically be interpreted as causation.
  • Knowledge extraction supports decision-making in fields such as healthcare, finance, education, agriculture, business, government and cybersecurity.

10.17 Chapter Summary

Knowledge extraction is a fundamental activity in Data Science because the value of data often lies in the useful understanding that can be obtained from it. Raw data consists of recorded facts and observations, but these records do not automatically constitute useful knowledge. Through processing, analysis and interpretation, data can be transformed into meaningful information and eventually into knowledge that supports understanding and decision-making.

Knowledge Discovery from Data provides a systematic approach to this transformation. The process commonly involves selecting relevant data, cleaning and preprocessing it, transforming it into a suitable analytical form, discovering patterns, evaluating those patterns and interpreting the meaningful results.

Different analytical techniques can be used depending on the problem. Classification can assign observations to predefined categories, clustering can identify naturally occurring groups, association analysis can reveal items that occur together, regression can examine relationships between variables, and anomaly detection can identify unusual observations.

An important principle is that knowledge extraction must go beyond simply finding relationships. Discovered patterns must be evaluated for relevance, reliability and usefulness. In particular, an association between variables should not automatically be interpreted as evidence that one variable causes another.

In modern Data Science, knowledge extraction connects data analysis with practical understanding. It enables organizations and researchers to discover patterns, identify risks, understand behaviour, improve processes and make more informed decisions.

Core Idea to Remember:

The central purpose of knowledge extraction is to move beyond “What data do we have?” toward “What meaningful patterns and relationships can we discover, what do they mean, and how can that understanding be used responsibly?”

DTS 201: INTRODUCTION TO DATA SCIENCE

Chapter Eleven: Data Mining

Discovering useful patterns, relationships and knowledge from large collections of data.

11.1 Meaning of Data Mining

Data mining is the systematic process of examining data to discover useful patterns, relationships, trends, structures and other meaningful information.

The word mining is used as an analogy. In physical mining, valuable materials are extracted from large quantities of earth or rock. In data mining, potentially valuable knowledge is extracted from large quantities of data.

Important: Data mining does not mean simply searching through a database. It involves applying appropriate analytical and computational methods to identify patterns or relationships that are useful for understanding a problem or making decisions.

Suppose a university has records containing students' attendance, coursework scores, examination results and demographic information. A simple database query might retrieve the records of students whose examination scores are below a particular value. Data mining goes further by examining many variables simultaneously to discover patterns, such as whether combinations of low attendance and poor continuous-assessment performance are associated with a higher likelihood of failing a course.

The objective is not merely to find patterns, but to find patterns that are meaningful, useful and sufficiently reliable for the intended purpose.

Data Mining and Knowledge Discovery:

Data mining is closely related to Knowledge Discovery in Databases (KDD). KDD refers to the broader process of discovering useful knowledge from data, while data mining is generally regarded as a central analytical stage within that process.

A simplified representation is:

Raw Data → Preparation → Data Mining → Patterns → Evaluation → Knowledge

Therefore, data mining should not be considered an isolated activity. The quality of the input data, the suitability of the method and the interpretation of the discovered patterns all influence the usefulness of the final result.

11.2 Purpose of Data Mining

The central purpose of data mining is to transform large collections of data into useful insights that can support understanding, prediction, planning and decision-making.

Major purposes include the following.

1. Discovering Hidden Patterns:

Some relationships are difficult to identify by manually inspecting individual records. Data mining can reveal patterns across thousands or millions of observations.

Example: An online retailer may discover that customers who purchase a particular type of laptop frequently purchase a specific laptop bag.

2. Identifying Relationships:

Data mining can identify relationships between variables or events.

Example: A bank may discover a relationship between certain transaction characteristics and previously identified fraudulent transactions.

3. Supporting Prediction:

Patterns found in historical data can sometimes be used to construct models that estimate future or unknown outcomes.

Example: Historical sales data can be used to develop a model for estimating future product demand.

4. Grouping Similar Records:

Data mining can divide observations into groups based on similarities.

Example: A telecommunications company may group customers according to similarities in their usage patterns.

5. Detecting Unusual Behaviour:

Data mining can identify observations that differ significantly from normal patterns.

Example: An unusual sequence of financial transactions may be flagged for further fraud investigation.

6. Supporting Decision-Making:

Organizations can use discovered patterns to improve planning, resource allocation, customer service, risk management and operational decisions.

11.3 Characteristics of Data Mining

Effective data mining has several important characteristics.

Characteristic Explanation
Pattern-oriented It focuses on identifying meaningful regularities and relationships.
Data-driven Findings are derived from available observations and variables.
Computational Computers are commonly required to process large datasets efficiently.
Scalable Data mining methods can be applied to datasets ranging from relatively small collections to very large datasets.
Analytical It uses statistical, mathematical and computational methods to analyze data.
Application-oriented The usefulness of a discovered pattern depends on its relevance to a practical or analytical objective.

11.4 The Data Mining Process

Data mining is normally performed as part of a broader analytical workflow. The exact steps vary according to the problem, but a typical process includes problem definition, data selection, preparation, exploration, mining, evaluation and interpretation.

1. Define Problem
2. Collect Data
3. Prepare Data
4. Explore Data
5. Mine Data
6. Evaluate
7. Interpret

Step 1: Define the Problem:

Before selecting a data mining technique, the analyst must clearly define what needs to be discovered or predicted.

A poorly defined problem can lead to technically correct analysis that does not answer the organization's actual question.

Weak question: "Find something interesting in our customer data."

Better question: "Can customers be grouped according to similarities in purchasing behaviour so that marketing strategies can be tailored to different groups?"

Step 2: Collect or Select Data:

Relevant data are collected from appropriate sources or selected from an existing database. The data should contain variables relevant to the problem.

Step 3: Prepare the Data:

Raw data often contain missing values, duplicate records, inconsistent formats, errors and irrelevant variables. Data preparation may therefore involve cleaning, transformation, integration and selection.

For example, the values Male, male, M and MALE may represent the same category but are stored inconsistently. A data-preparation process can standardize them.

Step 4: Explore the Data:

Exploratory analysis helps the analyst understand distributions, relationships, unusual observations and possible problems in the dataset before applying mining techniques.

Methods may include descriptive statistics, frequency tables, charts, correlation analysis and exploratory visualization.

Step 5: Apply Data Mining Techniques:

An appropriate technique is selected according to the objective and nature of the data. Examples include classification, clustering and association analysis.

Step 6: Evaluate the Results:

Not every discovered pattern is useful. A pattern may occur by chance, may be too weak to matter, or may result from errors or biases in the data.

The analyst therefore evaluates whether the discovered result is meaningful, reliable and relevant to the original problem.

Step 7: Interpret and Communicate:

The final patterns should be translated into understandable findings. A technically correct result is of limited practical value if decision-makers cannot understand its meaning or implications.

11.5 Discovery of Patterns

A pattern is a regularity, relationship or structure that occurs within data. Pattern discovery involves searching for such regularities and determining whether they provide useful information.

Patterns may appear in many forms.

  • Trends: A variable consistently increases or decreases over time.
  • Associations: Two or more events or items occur together more frequently than expected.
  • Groups: Observations form naturally similar clusters.
  • Sequences: Events occur in a particular order.
  • Anomalies: Certain observations differ substantially from normal behaviour.
  • Predictive relationships: One or more variables provide information useful for estimating another variable.

Example: Sales Data:

Consider the following simplified transaction data:

Transaction Items Purchased
1Bread, Milk
2Bread, Milk, Eggs
3Bread, Eggs
4Milk, Eggs
5Bread, Milk, Eggs

Inspection of these transactions suggests that bread, milk and eggs frequently occur together. With a much larger dataset, an association-mining method could quantify the strength and usefulness of such relationships.

Important distinction: Finding that two events occur together does not automatically prove that one event causes the other. Data mining primarily discovers patterns and relationships; causal conclusions require appropriate research designs and additional evidence.

11.6 Pattern Recognition

Pattern recognition is the process of identifying meaningful regularities or structures in data and using those characteristics to distinguish one type of observation from another.

Humans perform pattern recognition naturally. For example, a person can recognize a familiar face, distinguish different handwriting styles or identify a particular sound. In computing, algorithms can be designed to perform related tasks using measurable characteristics of data.

Example: Image Recognition:

Suppose a dataset contains thousands of images of cats and dogs. Each image contains many measurable properties, such as pixel intensities, shapes, textures and other extracted features.

A computational system can learn patterns associated with the two categories and use those patterns when examining a new image.

The important idea is that the system does not simply memorize the word "cat" or "dog." It attempts to identify characteristics that help distinguish the classes.

Pattern Recognition in Data Science:

Pattern recognition is relevant to:

  • image and facial recognition;
  • speech recognition;
  • medical diagnosis support;
  • fraud detection;
  • document classification;
  • spam detection;
  • customer segmentation; and
  • anomaly detection.

11.7 Classification

Classification is a data mining and machine learning task in which observations are assigned to one of a set of predefined categories or classes.

Classification is generally a supervised learning task because the algorithm learns from training examples for which the correct class is already known.

Basic Example:

Suppose a bank has historical loan applications labelled as:

  • Approved
  • Rejected

The dataset may contain variables such as income, credit history, loan amount and employment status. A classification model can learn from historical labelled applications and then estimate the appropriate class for a new application.

Classification structure:

Input features → Classification model → Predicted class

Examples of Classification Problems:

Application Possible Classes
Email filtering Spam / Not spam
Medical screening Positive / Negative
Customer classification Low / Medium / High risk
Image classification Cat / Dog / Other
Student performance At-risk / Not at-risk

Binary and Multiclass Classification:

Binary classification involves two classes.

Example: A transaction may be classified as fraudulent or legitimate.

Multiclass classification involves more than two classes.

Example: A customer support message may be classified as billing, technical support, account issue or general enquiry.

11.8 Clustering

Clustering is the process of grouping observations according to similarities within the data, without requiring predefined class labels.

Clustering is therefore commonly described as an unsupervised learning task.

Example: Customer Segmentation:

Suppose a retailer has customer records containing annual spending and number of purchases. The retailer does not already know how many customer groups exist.

A clustering method could identify groups such as:

  • customers who purchase frequently and spend heavily;
  • customers who purchase frequently but spend relatively little;
  • customers who purchase occasionally but spend heavily; and
  • customers who purchase infrequently and spend relatively little.

The groups are discovered from similarities in the data rather than being supplied beforehand.

Key idea: Classification asks, "Which known category does this observation belong to?" Clustering asks, "Which observations naturally belong together?"

11.9 Classification versus Clustering

Classification and clustering are closely related but solve different types of problems.

Feature Classification Clustering
Learning type Supervised Unsupervised
Labels Known during training Not required in advance
Purpose Assign observations to known categories Discover groups of similar observations
Example Spam versus legitimate email Grouping customers by behaviour
Main question Which class? Which group?

11.10 Association and Relationship Discovery

Another important data mining task is the discovery of associations between items or events.

An association occurs when the presence or occurrence of one item is related to the presence or occurrence of another item in a dataset.

Market Basket Analysis:

Market basket analysis examines items that customers purchase together. It is commonly used in retail and e-commerce.

For example, if customers who purchase a particular printer frequently purchase printer ink in the same transaction, the retailer may use this information to:

  • recommend the related product;
  • place related products near one another;
  • create product bundles; or
  • design targeted promotions.

The discovery of an association does not necessarily mean that one item causes customers to purchase another. It indicates that the two events occur together according to a measurable pattern in the dataset.

11.11 Anomaly and Outlier Detection

Data mining can also be used to identify observations that differ significantly from normal patterns.

An outlier is an observation that appears unusually different from the majority of observations. Anomaly detection is the broader process of identifying such unusual behaviour.

Example: Banking:

Suppose a customer's account normally records transactions between ₦5,000 and ₦100,000 within Nigeria. A sudden sequence of very large transactions from an unfamiliar location may differ substantially from the customer's normal pattern.

The unusual behaviour does not prove that fraud has occurred. Instead, it may be identified as an anomaly requiring further investigation.

This distinction is important because an unusual observation may have a legitimate explanation. Data mining can identify a suspicious pattern, but human or additional automated investigation may still be necessary.

11.12 Data Mining Techniques

Data mining includes a range of techniques. The appropriate technique depends on the problem, the type of data and the desired outcome.

Technique Main Purpose Example
Classification Assign records to predefined classes. Classify an email as spam or legitimate.
Clustering Discover groups of similar observations. Group customers according to purchasing behaviour.
Association analysis Discover relationships between items or events. Identify products frequently purchased together.
Anomaly detection Identify unusual observations. Detect suspicious financial transactions.
Regression Estimate a numerical outcome from one or more variables. Estimate future sales.

11.13 A Simple Worked Data Mining Example

Problem: A university wants to identify students who may require additional academic support.

Available data:

  • attendance percentage;
  • continuous-assessment score;
  • previous examination performance;
  • number of completed assignments; and
  • final examination outcome.

Step 1 — Define the problem: Determine whether available academic indicators can help classify students according to whether they are at risk of failing.

Step 2 — Prepare the data: Remove duplicate records, address missing values, correct inconsistent entries and ensure that the variables are represented appropriately.

Step 3 — Explore: Examine relationships between attendance, assessment scores and examination outcomes.

Step 4 — Select a method: Because historical students can be labelled as "at risk" or "not at risk," a classification approach may be appropriate.

Step 5 — Train: Use a suitable portion of historical labelled data to develop the classification model.

Step 6 — Evaluate: Test the model using data that were not used to train it.

Step 7 — Interpret: Examine which patterns appear useful and determine whether they are reasonable and educationally meaningful.

Step 8 — Apply: Use the results as one source of evidence for identifying students who may benefit from additional support.

This example demonstrates an important principle: data mining is not simply about applying an algorithm. The problem must first be understood, the data must be prepared properly, and the results must be evaluated and interpreted in context.

11.14 Applications of Data Mining

Healthcare:

Data mining can be applied to electronic health records, laboratory results, medical images and patient histories to identify patterns that may support clinical research, risk assessment and healthcare planning.

Example: Historical patient records may be analyzed to identify combinations of factors associated with a particular health outcome.

Finance and Banking:

Financial institutions use data analysis and mining techniques to identify unusual transactions, assess risk, understand customer behaviour and support fraud detection.

Retail and E-Commerce:

Retailers analyze transaction histories to understand purchasing behaviour, recommend products, identify customer segments and improve inventory planning.

Education:

Educational institutions can analyze attendance, assessment results, learning-platform activity and other academic data to identify patterns in student performance.

Agriculture:

Agricultural data from weather records, soil measurements, crop yields and remote sensors can be analyzed to identify patterns that support crop planning, irrigation and resource management.

Business:

Organizations can use data mining to understand customers, analyze sales, identify operational patterns, assess risks and support strategic planning.

Government:

Government agencies can analyze large administrative datasets to improve planning, allocate resources, monitor public services and identify unusual patterns requiring investigation.

Cybersecurity:

Data mining can help identify unusual network activity, suspicious access patterns and other behaviours that may indicate security incidents.

11.15 Advantages of Data Mining

  • Improved decision-making: Discovered patterns can provide evidence for better decisions.
  • Efficient analysis: Computers can examine datasets much faster than manual inspection.
  • Pattern discovery: Data mining can reveal relationships that may not be immediately visible.
  • Predictive support: Historical patterns can contribute to models that estimate future outcomes.
  • Customer understanding: Organizations can identify different customer behaviours and needs.
  • Risk identification: Unusual or risky patterns can be detected earlier.
  • Operational improvement: Organizations can identify inefficiencies and opportunities for improvement.

11.16 Limitations and Risks of Data Mining

Data mining is powerful, but its results are not automatically correct or useful. Several limitations must be considered.

Poor Data Quality:

If the input data contain substantial errors, missing values or inconsistent records, the resulting patterns may be unreliable.

Spurious Patterns:

Large datasets contain many possible relationships. Some apparent relationships may occur by chance rather than because they represent a meaningful underlying phenomenon.

Overfitting:

A model may learn the specific characteristics or noise of the training data too closely and perform poorly on new data. Evaluation using appropriate unseen data is therefore important.

Bias:

If the data reflect historical or sampling biases, data mining methods may reproduce or even amplify those biases.

Privacy:

Data mining may involve sensitive personal information. Organizations must therefore consider privacy, security, lawful data use and appropriate access controls.

Interpretation Problems:

A discovered relationship does not automatically establish causation. Analysts must distinguish between correlation or association and evidence of a causal relationship.

Critical principle: A sophisticated data mining algorithm cannot compensate for fundamentally poor data, a poorly defined problem or incorrect interpretation of results.

11.17 Common Misconceptions and Student Mistakes

1. "Data mining means searching a database."

Database searching retrieves records that satisfy specified conditions. Data mining goes further by discovering patterns, relationships and structures within data.

2. "Every discovered pattern is useful."

Some patterns are accidental, weak, irrelevant or caused by problems in the data. Patterns must be evaluated before being used.

3. "Data mining proves cause and effect."

Data mining can identify associations and patterns, but an association alone does not establish causation.

4. "Classification and clustering are the same."

Classification uses predefined classes, while clustering discovers groups without requiring predefined labels.

5. "More data always means better results."

More data can be beneficial, but quality, relevance, representativeness and appropriate methodology are also essential.

6. "Data mining is only used for business."

Data mining is applied across healthcare, education, agriculture, government, finance, cybersecurity, science and many other domains.

7. "The algorithm is the most important part of the process."

Algorithm selection matters, but problem definition, data quality, preparation, evaluation and interpretation are equally important.

11.18 Relationship Between Data Mining and Other Data Science Activities

Data mining is one component of the broader field of Data Science. It overlaps with several disciplines but should not be treated as synonymous with them.

Field Relationship with Data Mining
Statistics Provides methods for understanding variation, relationships, uncertainty and evidence in data.
Machine Learning Provides algorithms that can learn patterns from data for prediction or grouping.
Database Systems Provide mechanisms for storing, managing and retrieving large datasets.
Data Visualization Helps analysts explore and communicate patterns discovered in data.
Artificial Intelligence Provides broader computational approaches for intelligent behaviour, some of which rely on patterns learned from data.

11.19 Key Points

  • Data mining is the systematic discovery of useful patterns, relationships, trends and structures in data.
  • Data mining is an important analytical activity within the broader Data Science and Knowledge Discovery process.
  • The objective of data mining is not simply to find patterns but to discover patterns that are meaningful, reliable and useful.
  • A typical data mining process involves problem definition, data collection or selection, data preparation, exploration, mining, evaluation and interpretation.
  • Patterns may appear as trends, associations, groups, sequences, anomalies or predictive relationships.
  • Pattern recognition involves identifying recurring characteristics or structures in data.
  • Classification assigns observations to predefined categories and is generally a supervised learning task.
  • Clustering groups observations according to similarities without requiring predefined categories and is generally an unsupervised learning task.
  • Association analysis can identify items or events that frequently occur together.
  • Anomaly detection identifies observations that differ substantially from normal patterns.
  • Data mining is applied in healthcare, finance, education, agriculture, business, government, retail and cybersecurity, among many other fields.
  • Poor data quality, bias, accidental patterns, overfitting and privacy concerns can reduce the reliability or usefulness of data mining results.
  • An association discovered through data mining should not automatically be interpreted as a causal relationship.

11.20 Chapter Summary

Data mining is concerned with extracting useful patterns and relationships from data. It provides computational and analytical techniques for discovering information that may not be immediately apparent from individual records or simple database queries.

A successful data mining process begins with a clearly defined problem and proceeds through data selection, preparation, exploration, application of suitable mining techniques, evaluation and interpretation. Data quality is fundamental because unreliable or biased data can produce misleading results.

Pattern discovery can involve trends, associations, groups, sequences and anomalies. Classification and clustering are two important introductory approaches. Classification assigns observations to predefined classes using labelled examples, whereas clustering discovers groups of similar observations without predefined class labels.

Data mining has applications across virtually every data-intensive sector, including healthcare, banking, education, agriculture, retail, government and cybersecurity. Its usefulness comes from the ability to transform large volumes of data into information that can support analysis and decision-making.

However, data mining must be applied carefully. Patterns can arise by chance, models can overfit, datasets can contain bias, and relationships do not necessarily demonstrate causation. Good data mining therefore requires not only appropriate algorithms but also sound problem definition, quality data, careful evaluation and responsible interpretation.

Data → Preparation → Pattern Discovery → Evaluation → Interpretation → Knowledge → Decision

CHAPTER TWELVE

Business Intelligence and Knowledge Management

Chapter Introduction

Organizations collect enormous quantities of data from customers, employees, transactions, websites, sensors, financial systems and other sources. However, the existence of large amounts of data does not automatically produce better decisions. Data must be organized, analyzed, interpreted and communicated before it can become useful to decision-makers.

Business Intelligence (BI) provides methods and technologies for transforming organizational data into information and insights that support decision-making. Knowledge Management (KM), on the other hand, focuses on how organizations create, capture, organize, share and apply knowledge.

Data Science complements both areas by applying statistical, computational and analytical techniques to discover patterns, generate predictions and extract useful insights from data. Understanding the relationship among these disciplines is therefore important for anyone studying Data Science.

Learning Objectives

At the end of this chapter, the student should be able to:

  • define Business Intelligence and explain its purpose;
  • identify the major components of a Business Intelligence environment;
  • explain how BI supports organizational decision-making;
  • define Knowledge Management and explain its importance;
  • distinguish between data, information, knowledge and insight;
  • explain the relationship between Data Science, Business Intelligence and Knowledge Management;
  • describe practical applications of BI and KM in organizations; and
  • explain how organizations can use data and knowledge to improve decision-making.

Key Terminology

Business Intelligence: Processes, technologies and practices used to transform organizational data into useful information and insights for decision-making.
Dashboard: A visual interface that presents important measures, indicators and trends in a concise form.
Data Warehouse: A centralized repository designed to store integrated data for reporting and analysis.
Knowledge Management: The systematic process of creating, capturing, organizing, sharing and applying knowledge within an organization.
Decision Support: The use of information, analytical methods and tools to assist individuals or organizations in making decisions.
Key Performance Indicator: A measurable value used to evaluate progress toward an important organizational objective.

12.1 From Data to Knowledge

A useful starting point for understanding BI and KM is to distinguish between data, information, knowledge and insight.

Data:

Data consists of recorded observations, measurements, facts or symbols. For example, a retail organization may record individual sales transactions such as product identifiers, quantities, prices and transaction dates.

Information:

Information is data that has been processed, organized or presented in a meaningful context. If the individual sales records are summarized to show monthly sales by product, the resulting summary is information.

Knowledge:

Knowledge involves understanding information and knowing how it can be interpreted or applied. For example, a manager may recognize from several months of sales information that demand for a particular product consistently increases during certain periods.

Insight:

Insight is a useful understanding derived from analysis that can guide action or decision-making. A data scientist might identify that customers who purchase one product are particularly likely to purchase another product and recommend an appropriate marketing strategy.

Level Meaning Example
DataRaw recorded observations₦25,000, 12 August, Product A
InformationOrganized and meaningful dataProduct A generated ₦2.4 million in August
KnowledgeUnderstanding derived from informationProduct A performs strongly during certain periods
InsightActionable understandingIncrease inventory before periods of expected high demand
Key idea: Business Intelligence is primarily concerned with turning organizational data into information and insights for decisions, while Knowledge Management extends the process by ensuring that useful knowledge is retained, shared and applied throughout the organization.

12.2 Meaning of Business Intelligence

Business Intelligence (BI) refers to the collection of processes, technologies, analytical methods and practices used to collect, integrate, analyze and present organizational data so that people can make informed decisions.

The term business does not restrict BI to commercial companies. BI techniques can also be applied in universities, hospitals, government agencies, non-profit organizations and other institutions.

The central purpose of BI is not simply to produce reports. Its purpose is to help an organization understand what is happening, identify important patterns and trends, monitor performance, investigate problems and support appropriate decisions.

Questions Business Intelligence Can Help Answer:

  • What happened? For example, how many products were sold last month?
  • Where did it happen? For example, which branch recorded the highest sales?
  • When did it happen? For example, during which months did demand increase?
  • How is performance changing? For example, are customer complaints increasing or decreasing?
  • Why might it have happened? Analytical techniques can help investigate possible causes.
  • What should decision-makers pay attention to? Dashboards, alerts and analytical reports can highlight important conditions.

12.3 Purpose and Importance of Business Intelligence

Organizations operate in environments where decisions must often be made using incomplete, rapidly changing and complex information. BI provides a systematic approach for making organizational information more accessible and useful.

Performance Monitoring:

BI systems can monitor measures such as sales, revenue, expenses, production output, customer satisfaction, inventory levels and service performance.

Improved Decision-Making:

Decision-makers can use analyzed information rather than relying entirely on intuition or isolated observations.

Trend Identification:

Historical data can be examined to identify patterns and changes over time. For example, an organization may discover that demand for a service has been increasing steadily.

Problem Identification:

BI can reveal unusual changes that require investigation. A sudden increase in product returns, for example, may indicate a quality problem.

Operational Improvement:

Analyzing organizational processes can reveal delays, inefficiencies, bottlenecks and opportunities for improvement.

Strategic Planning:

Long-term decisions such as entering a new market, expanding a service or allocating resources can benefit from reliable historical and current information.

12.4 Components of Business Intelligence

A Business Intelligence environment usually contains several interconnected components. The exact architecture differs between organizations, but the major functions are broadly similar.

1. Data Sources:

BI begins with data. Sources may include transaction-processing systems, accounting systems, customer databases, enterprise applications, websites, spreadsheets, sensors and external datasets.

2. Data Integration:

Data collected from different systems may have different formats, naming conventions and structures. Data integration combines relevant sources into a form suitable for analysis.

3. Data Warehouse:

A data warehouse is a centralized repository designed primarily for reporting and analytical workloads. It typically contains integrated historical data from multiple operational sources.

A warehouse allows an organization to analyze information across different periods, departments, products, locations or other dimensions.

4. Data Processing and Transformation:

Raw data may require cleaning, validation, transformation and organization before it can be analyzed reliably.

5. Analytical Tools:

BI environments may include tools for querying data, calculating measures, identifying trends, comparing performance and exploring relationships.

6. Reporting:

Reports present information in a structured form. They may provide periodic summaries such as daily production reports, monthly financial reports or annual performance reports.

7. Dashboards:

A dashboard presents selected indicators and visualizations in a compact interface. It is particularly useful when decision-makers need to monitor important measures quickly.

8. Visualization:

Charts, graphs, tables and other visual representations help users identify patterns and relationships that may be difficult to recognize from raw numerical data.

12.5 Business Intelligence Architecture

A simplified BI architecture can be represented as a sequence:

Data Sources
↓
Data Integration and Transformation
↓
Data Warehouse / Analytical Storage
↓
Analysis and Query
↓
Reports, Dashboards and Visualizations
↓
Decision-Making

This model emphasizes an important principle: the quality of a decision depends partly on the quality, relevance and interpretation of the information supplied to the decision-maker.

12.6 Business Intelligence and Decision Support

Decision support refers to the use of information and analytical tools to assist people in making decisions. BI contributes to decision support by making relevant information easier to access and interpret.

Operational Decisions:

Operational decisions concern routine activities. A supermarket manager may use BI to monitor today's sales, inventory levels and stock shortages.

Tactical Decisions:

Tactical decisions generally concern medium-term activities. A department manager might compare monthly performance across branches to determine where additional resources are needed.

Strategic Decisions:

Strategic decisions affect the long-term direction of an organization. Senior management may analyze historical performance, market information and customer behavior when evaluating expansion into a new region.

Decision level Typical time horizon Example BI use
OperationalShort termMonitoring daily sales and stock
TacticalMedium termComparing branch performance
StrategicLong termEvaluating market expansion

12.7 Meaning of Knowledge Management

Knowledge Management (KM) is the systematic process through which an organization creates, captures, organizes, stores, shares and applies knowledge to improve its activities and achieve its objectives.

Knowledge exists in more than databases and reports. Employees possess experience, skills, procedures, lessons learned, professional judgment and practical understanding that may not be fully represented in formal information systems.

Knowledge Management therefore attempts to ensure that valuable organizational knowledge does not remain isolated with one individual or disappear when employees leave the organization.

Example:

Suppose an experienced maintenance engineer knows that a particular machine tends to fail after a specific operating condition. If that knowledge exists only in the engineer's personal experience, the organization may lose it when the engineer leaves.

A KM system could capture the knowledge through maintenance documentation, procedures, lessons learned and an organizational knowledge base. Other engineers could then access and apply it.

12.8 Types of Knowledge

Explicit Knowledge:

Explicit knowledge can be documented, stored and communicated relatively easily. Examples include manuals, reports, policies, databases, diagrams, standard operating procedures and technical documents.

Tacit Knowledge:

Tacit knowledge is knowledge based heavily on personal experience, skills, judgment and context. It is often difficult to express completely in written form.

For example, a skilled technician may be able to identify an abnormal machine sound immediately because of years of experience. Recording the sound and documenting the diagnostic procedure can help convert some of this tacit knowledge into a form that others can use.

Feature Explicit knowledge Tacit knowledge
FormDocumented or codifiedExperience and personal understanding
ExamplesManuals, databases, reportsSkill, judgment, experience
SharingUsually easier to distributeOften requires interaction and experience sharing

12.9 The Knowledge Management Process

Knowledge Management can be understood as a continuous organizational process rather than a single software application.

1. Knowledge Creation:

New knowledge may emerge through research, experimentation, problem-solving, innovation, collaboration or analysis.

2. Knowledge Capture:

Useful knowledge is documented or recorded so that it can be retained by the organization.

3. Knowledge Organization:

Knowledge is classified and structured so that users can locate it efficiently.

4. Knowledge Storage:

Knowledge can be stored in document repositories, databases, knowledge bases, intranets and other organizational systems.

5. Knowledge Sharing:

Knowledge is distributed through training, meetings, collaboration platforms, documentation and other communication mechanisms.

6. Knowledge Application:

The final objective is to use knowledge to solve problems, improve processes, support decisions and create value.

Create → Capture → Organize → Store → Share → Apply

12.10 Data Science, Business Intelligence and Knowledge Management

Data Science, Business Intelligence and Knowledge Management overlap, but they are not identical disciplines.

Data Science:

Data Science combines statistical reasoning, mathematics, computing and domain knowledge to extract useful patterns, insights and predictive models from data.

Data Science may address questions such as:

  • What factors influence customer churn?
  • Can future demand be predicted?
  • Which customers are likely to respond to a particular offer?
  • Can an unusual transaction be detected automatically?

Business Intelligence:

BI focuses strongly on understanding organizational performance through reporting, dashboards, analysis and related decision-support capabilities.

BI may answer questions such as:

  • How much revenue did each branch generate?
  • Which products performed best this quarter?
  • How has performance changed over the past year?
  • Which department is exceeding its budget?

Knowledge Management:

KM focuses on organizational knowledge and how that knowledge is captured, shared and applied.

KM may address questions such as:

  • What did the organization learn from previous projects?
  • Where can employees find the procedure for solving a particular problem?
  • How can expert knowledge be transferred to new employees?
  • How can lessons learned be reused in future projects?
Aspect Data Science Business Intelligence Knowledge Management
Main focus Extracting patterns, insights and predictions from data Understanding organizational performance and supporting decisions Managing organizational knowledge
Typical outputs Models, predictions, analyses and insights Reports, dashboards, KPIs and analytical summaries Knowledge bases, procedures, lessons learned and shared expertise
Typical emphasis Statistical and computational analysis Monitoring, reporting and decision support Creation, preservation, sharing and application of knowledge

12.11 How the Three Disciplines Work Together

The three disciplines can operate as complementary parts of an organizational information and knowledge environment.

Data → collected from organizational systems

Business Intelligence → organizes, summarizes and presents performance information

Data Science → investigates patterns, relationships and predictions

Knowledge Management → captures and shares what the organization learns

Decision-Makers → apply information, analytical findings and organizational knowledge

Consider a bank attempting to reduce customer attrition. BI might reveal that customer attrition has increased in a particular segment. Data Science could develop a model for identifying customers who are likely to leave. Knowledge Management could ensure that successful retention strategies discovered by employees are documented and shared. Management can then combine these sources of evidence when making decisions.

12.12 Practical Application: Retail Business

Consider a retail company that operates several branches.

The company collects transaction data containing product identifiers, quantities, prices, dates, branches and customer information.

Business Intelligence: The company creates dashboards showing sales by branch, product and month.

Data Science: Analysts develop models to forecast demand and identify purchasing patterns.

Knowledge Management: Managers document successful sales strategies, inventory practices and lessons learned from previous campaigns.

Decision: Management combines these resources to determine inventory levels, marketing priorities and branch strategies.

This example demonstrates that the three disciplines can address different parts of the same organizational problem.

12.13 Practical Application: University

A university can also benefit from BI, Data Science and Knowledge Management.

BI: Dashboards can show student enrolment, course registration, graduation rates and resource utilization.

Data Science: Analytical models can be used to investigate factors associated with student performance or identify patterns in course outcomes.

Knowledge Management: Academic procedures, research knowledge, institutional policies, lessons learned and best practices can be organized and shared across departments.

When these capabilities work together, university administrators can make better-informed decisions while academic and administrative knowledge can be preserved for future use.

12.14 Benefits and Limitations

Benefits of Business Intelligence:

  • improves access to organizational information;
  • supports evidence-based decision-making;
  • helps identify trends and performance problems;
  • improves monitoring through dashboards and indicators;
  • can reveal opportunities for operational improvement; and
  • helps organizations compare performance across periods, locations or departments.

Limitations of Business Intelligence:

  • poor-quality data can produce misleading reports;
  • BI systems may require significant technical and organizational resources;
  • dashboards can encourage users to focus on metrics without understanding their context;
  • historical reporting does not automatically explain causation; and
  • access to sensitive organizational information must be properly controlled.

Benefits of Knowledge Management:

  • preserves valuable organizational experience;
  • reduces unnecessary duplication of work;
  • supports employee learning;
  • improves knowledge sharing;
  • helps organizations retain lessons from previous projects; and
  • can support more consistent decision-making.

Limitations of Knowledge Management:

  • employees may be reluctant to document or share knowledge;
  • knowledge can become outdated;
  • poor organization can make knowledge difficult to locate;
  • tacit knowledge may be difficult to capture completely; and
  • technology alone cannot guarantee effective knowledge sharing.

12.15 Common Misconceptions and Mistakes

1. “Business Intelligence is the same as Data Science.” They overlap, but their primary emphases differ. BI traditionally focuses strongly on reporting, monitoring and decision support, while Data Science often involves deeper statistical, computational and predictive analysis.

2. “Knowledge is simply stored data.” Data and knowledge are related but not identical. Knowledge involves interpretation, understanding, experience and the ability to apply what has been learned.

3. “A dashboard automatically produces good decisions.” A dashboard only presents information. Decision-makers still need appropriate context, judgment and domain knowledge.

4. “More data always means better BI.” Large quantities of poor-quality or irrelevant data can make analysis more difficult rather than more useful.

5. “Knowledge Management is just a document storage system.” Document repositories can support KM, but effective KM also involves knowledge creation, sharing, learning and application.

6. “Only large corporations need Business Intelligence.” Organizations of different sizes can use BI. The scale and sophistication of the implementation may differ.

7. “Data Science replaces human decision-makers.” Data Science can support decision-making, but analytical outputs must still be interpreted in context and considered alongside organizational objectives, constraints and professional judgment.

12.16 Key Points

  • Business Intelligence transforms organizational data into useful information and insights for decision-making.
  • BI commonly involves data sources, integration, storage, analysis, reporting, dashboards and visualization.
  • BI supports operational, tactical and strategic decision-making.
  • A data warehouse is commonly used to store integrated data for analytical purposes.
  • Knowledge Management is concerned with creating, capturing, organizing, storing, sharing and applying organizational knowledge.
  • Explicit knowledge can be documented relatively easily, while tacit knowledge is closely associated with experience and personal expertise.
  • Data, information, knowledge and insight represent related but distinct concepts.
  • Data Science focuses on extracting patterns, insights and predictive knowledge from data using statistical and computational methods.
  • Business Intelligence focuses strongly on organizational reporting, performance analysis and decision support.
  • Knowledge Management focuses on preserving, sharing and applying organizational knowledge.
  • Data Science, BI and KM can complement one another in organizational decision-making.
  • The usefulness of BI and Data Science depends heavily on data quality, appropriate analysis and correct interpretation.

12.17 Chapter Summary

Business Intelligence and Knowledge Management address two important organizational challenges: understanding what organizational data reveals and ensuring that useful knowledge can be retained and applied.

Business Intelligence uses processes and technologies for collecting, integrating, analyzing and presenting organizational data. Its outputs may include reports, dashboards, key performance indicators and analytical summaries. These outputs support operational, tactical and strategic decisions.

Knowledge Management focuses on the broader management of organizational knowledge. It includes the creation, capture, organization, storage, sharing and application of knowledge. Both explicit knowledge, such as documented procedures, and tacit knowledge, such as experience and professional judgment, are important.

Data Science, Business Intelligence and Knowledge Management are distinct but complementary. Data Science can discover patterns and build predictive models; BI can transform organizational data into accessible performance information; and KM can preserve and distribute the knowledge generated through organizational experience and analysis.

The central principle is therefore simple: data becomes valuable when it is transformed into meaningful information, interpreted to produce knowledge and applied appropriately to support action and decision-making.

Chapter Exercises

A. Short-Answer Questions:

  1. Define Business Intelligence.
  2. State four purposes of Business Intelligence.
  3. What is a data warehouse?
  4. Differentiate between a report and a dashboard.
  5. Define Knowledge Management.
  6. Distinguish between explicit and tacit knowledge.
  7. What is decision support?
  8. State three ways in which Data Science supports organizational decision-making.
  9. Differentiate between Business Intelligence and Knowledge Management.
  10. Explain the relationship between data, information and knowledge.

B. Application Questions:

  1. A supermarket wants to monitor daily sales, inventory and branch performance. Explain how a BI system could support this objective.
  2. A manufacturing company loses an experienced technician who had developed several effective maintenance procedures. Explain how Knowledge Management could reduce the risk of losing such knowledge.
  3. A university wants to understand factors associated with student withdrawal. Explain how BI and Data Science could contribute to the investigation.
  4. A bank wants to identify customers who may stop using its services. Explain how BI, Data Science and Knowledge Management could work together to address the problem.

C. Analytical Questions:

  1. Explain why high-quality data is essential for effective Business Intelligence.
  2. Discuss the differences between Data Science and Business Intelligence.
  3. Explain why Knowledge Management cannot be reduced to storing documents.
  4. Discuss how poor interpretation of a dashboard could result in an inappropriate organizational decision.
  5. Explain how an organization could combine Data Science, Business Intelligence and Knowledge Management to improve customer service.

D. Examination-Style Questions:

  1. Define Business Intelligence and discuss its major components.
  2. Explain the role of Business Intelligence in operational, tactical and strategic decision-making.
  3. Define Knowledge Management and explain the major stages involved in managing organizational knowledge.
  4. Distinguish between explicit and tacit knowledge, giving suitable examples of each.
  5. Using a practical organizational example, explain the relationship among Data Science, Business Intelligence and Knowledge Management.

CHAPTER THIRTEEN

Big Data and Data Analytics

13.1 Meaning of Big Data

Big Data refers to datasets and data environments whose size, speed, diversity, complexity or other characteristics create challenges that cannot be efficiently addressed using conventional data-processing methods alone.

The term does not have a single universal numerical threshold. A dataset does not become Big Data simply because it contains a particular number of records. What matters is whether the characteristics of the data create significant challenges for conventional methods of collection, storage, processing, integration, analysis or management.

For example, a small organization may consider a dataset containing millions of records difficult to manage, while a large technology company may routinely process datasets containing billions or trillions of records.

Important distinction:

Big Data is not simply “a lot of data.” It is data whose characteristics introduce substantial technical, organizational or analytical challenges and therefore require appropriate technologies, architectures and methods.

13.2 Why Has Big Data Become Important?

The growth of Big Data is closely connected with the expansion of digital technologies. Organizations now generate and collect data from many sources simultaneously.

  • Internet activity: Websites and online services continuously generate records of user interactions.
  • Mobile devices: Smartphones generate information through applications, location services, communication and device sensors.
  • Business transactions: Banks, retailers and other organizations generate large numbers of transaction records.
  • Social media: Users generate text, images, videos, reactions and interaction data.
  • Internet of Things: Connected devices and sensors can generate data continuously.
  • Scientific research: Modern instruments can produce enormous datasets from experiments and observations.
  • Healthcare: Electronic records, diagnostic systems, medical imaging and monitoring devices generate diverse forms of data.
  • Industrial systems: Machines and production systems can continuously record operational measurements.

The value of these datasets comes from the possibility of using them to understand situations, identify patterns, improve processes, predict outcomes and support better decisions.

13.3 Characteristics of Big Data

Big Data is commonly described using the 5 Vs: Volume, Velocity, Variety, Veracity and Value. These characteristics provide a useful framework for understanding why large-scale data environments can be difficult to manage.

13.3.1 Volume:

Volume refers to the amount of data being generated, collected, stored and processed.

Organizations may accumulate millions, billions or even larger numbers of records. The data may include structured database records, documents, images, videos, sensor readings and transaction histories.

Example: An online retailer may store years of customer transactions, product searches, shopping-cart activities, reviews and website interactions.

Large volume creates challenges involving storage capacity, data management, processing time and computational resources.

13.3.2 Velocity:

Velocity refers to the speed at which data is generated, transmitted, received and processed.

Some datasets are generated continuously and may need to be analyzed almost immediately.

Example: A financial system may receive thousands of transactions within a short period. A fraud-detection system may need to analyze transactions while they are occurring rather than waiting until the end of the day.

High velocity creates requirements for efficient data pipelines, rapid processing and, in some cases, real-time or near-real-time analytics.

13.3.3 Variety:

Variety refers to the different forms and sources of data.

Big Data environments may contain:

  • structured tables;
  • semi-structured formats such as JSON and XML;
  • text documents;
  • images;
  • audio;
  • video;
  • sensor data;
  • geographical information; and
  • machine-generated records.

Different data types often require different storage, processing and analytical techniques.

13.3.4 Veracity:

Veracity refers to the reliability, accuracy, consistency and trustworthiness of data.

Large datasets may contain errors, duplicates, missing values, outdated records, inconsistent formats or misleading observations.

Example: If a customer database contains different spellings of the same customer's name, inconsistent addresses and duplicate accounts, simply increasing the amount of data does not improve the quality of the analysis.

13.3.5 Value:

Value refers to the usefulness that can be obtained from data.

Data has little practical benefit if an organization cannot convert it into useful information, knowledge or decisions.

For example, a supermarket may collect millions of transaction records. The data becomes valuable when analysis can reveal purchasing patterns, improve inventory management or support better business decisions.

Characteristic Meaning Example
Volume Amount of data Billions of transaction records
Velocity Speed of data generation and processing Real-time sensor readings
Variety Different forms of data Text, images, tables and video
Veracity Reliability and quality of data Missing or duplicated records
Value Useful benefit obtained from data Improved decisions from customer analysis

13.4 Big Data Integration

Big Data integration is the process of bringing together data from multiple sources so that it can be accessed, managed and analyzed consistently.

In a modern organization, information is rarely stored in one location. A company may have customer information in a customer relationship management system, sales records in a transaction database, website activity in web logs and operational data in separate systems.

Integration allows these sources to be combined or connected so that analysts can examine relationships across them.

13.4.1 Example of Data Integration:

Consider an online retailer with the following data sources:

  • customer database;
  • sales transaction system;
  • website activity logs;
  • mobile application data;
  • inventory system; and
  • customer review platform.

Individually, each source provides only part of the business picture. When properly integrated, the organization can investigate questions such as:

  • Which products are frequently viewed but rarely purchased?
  • Which customers purchase particular categories of products?
  • How does website activity relate to sales?
  • Which products are likely to require replenishment?
  • How do customer reviews relate to repeat purchases?

The quality of the resulting analysis depends heavily on the quality of the integration process.

13.5 Big Data and Intelligence

The collection of large amounts of data does not automatically make an organization intelligent. Intelligence arises when data can be transformed into useful information and insights that improve understanding and decision-making.

In Data Science, Big Data can support intelligent systems through a sequence such as:

Data → Processing → Analysis → Insight → Decision → Action

Data: Raw observations are collected from relevant sources.

Processing: The data is cleaned, transformed, integrated and prepared for analysis.

Analysis: Statistical, computational or machine-learning techniques are applied to identify patterns and relationships.

Insight: The results are interpreted to understand what the patterns mean.

Decision: The insight is used to select an appropriate course of action.

Action: The decision is implemented in the real-world environment.

For example, a hospital may collect information about patient admissions, laboratory results, treatments and outcomes. Analysis of these data may reveal patterns associated with patient readmission. Hospital management can use those insights to improve treatment procedures or follow-up care.

13.6 Challenges of Big Data

Big Data provides significant opportunities, but it also creates technical, organizational, ethical and analytical challenges.

13.6.1 Storage:

Very large datasets require substantial storage capacity. Organizations must determine how data should be stored, organized, backed up and accessed efficiently.

13.6.2 Processing:

Traditional processing methods may become inefficient when datasets are extremely large or arrive at very high speeds. Large-scale processing may require distributed computing and specialized infrastructure.

13.6.3 Data Quality:

Large datasets can contain missing, inaccurate, inconsistent or duplicated records. Analytical results are strongly influenced by the quality of the input data.

13.6.4 Data Integration:

Combining information from different systems can be difficult because sources may use different formats, naming conventions, identifiers and levels of detail.

13.6.5 Security:

Large collections of sensitive data can become attractive targets for unauthorized access, theft or misuse. Appropriate security controls are therefore essential.

13.6.6 Privacy:

Data may contain personal, financial, medical or behavioral information. Organizations must consider privacy requirements and ensure that data is collected and used responsibly.

13.6.7 Skills and Expertise:

Effective Big Data projects require professionals with knowledge of data management, statistics, programming, computing infrastructure, analytics and domain-specific problems.

13.6.8 Cost:

Large-scale data infrastructure can require significant investment in hardware, software, cloud services, personnel, security and maintenance.

13.6.9 Interpretation:

Large datasets can produce statistically significant relationships that are not necessarily meaningful in practice. Analysts must therefore distinguish genuine useful relationships from misleading patterns.

Common Mistake: More Data Does Not Always Mean Better Analysis:

A common misconception is that increasing the amount of data automatically produces better conclusions.

Suppose a dataset contains ten million records but a large proportion of the records are inaccurate or duplicated. The dataset may produce worse results than a smaller but carefully cleaned and representative dataset.

The principle is therefore:

More data can provide more information, but useful analysis requires relevant, reliable and appropriately processed data.

13.7 Meaning of Data Analytics

Data Analytics is the systematic process of examining, transforming and interpreting data to discover useful patterns, answer questions, generate insights and support decision-making.

Data Analytics may involve techniques from statistics, mathematics, computer science and domain-specific knowledge.

The analytical process commonly involves:

  1. defining the question or problem;
  2. identifying and obtaining relevant data;
  3. cleaning and preparing the data;
  4. exploring the data;
  5. applying appropriate analytical methods;
  6. interpreting the results; and
  7. communicating the findings to relevant users.

Data Analytics therefore goes beyond producing tables or charts. The central objective is to obtain meaningful information from data that can support understanding and action.

13.8 The Four Major Types of Data Analytics

Data Analytics is commonly divided into four broad categories:

Descriptive:

What happened?

Diagnostic:

Why did it happen?

Predictive:

What is likely to happen?

Prescriptive:

What should we do?

13.8.1 Descriptive Analytics:

Descriptive analytics summarizes historical or current data to explain what has happened or what is happening.

It commonly uses:

  • totals;
  • averages;
  • percentages;
  • frequencies;
  • tables;
  • charts;
  • dashboards; and
  • summary statistics.

Example: A university reports that 78% of registered students passed a particular examination.

The statement describes an observed result. It does not explain why the result occurred or predict what will happen next.

13.8.2 Diagnostic Analytics:

Diagnostic analytics investigates the reasons or factors associated with an observed result.

It asks questions such as:

  • Why did sales decrease?
  • Why did student performance decline?
  • Why did machine downtime increase?
  • Why did customer complaints increase?

Example: Suppose a company discovers through descriptive analytics that monthly sales fell by 15%. Diagnostic analysis may examine regional sales, product availability, pricing, customer behavior and marketing activity to identify factors associated with the decline.

13.8.3 Predictive Analytics:

Predictive analytics uses historical and current data, together with statistical or computational models, to estimate future or unknown outcomes.

Predictive analytics may be used to estimate:

  • future sales;
  • customer demand;
  • equipment failure;
  • credit risk;
  • student performance;
  • disease risk; or
  • customer churn.

Example: A retailer uses previous sales, seasonal patterns and other relevant variables to estimate the number of products likely to be sold next month.

Important:

A prediction is an estimate, not a guarantee. Predictive models are subject to uncertainty and depend on the quality and relevance of the data and assumptions used to construct them.

13.8.4 Prescriptive Analytics:

Prescriptive analytics goes beyond predicting what may happen by considering what actions could be taken to achieve a desired outcome.

It may answer questions such as:

  • What should the organization do?
  • Which option should be selected?
  • How should available resources be allocated?
  • What decision is likely to produce the best outcome under specified conditions?

Example: A delivery company predicts that demand will increase in three regions. Prescriptive analytics may evaluate different vehicle and driver allocations and recommend a distribution that minimizes expected delivery delays while respecting available resources.

13.9 Comparing the Four Types of Analytics

Type Main Question Purpose Typical Output
Descriptive What happened? Summarize observed data Reports, dashboards, charts and statistics
Diagnostic Why did it happen? Investigate causes and relationships Explanations, contributing factors and relationships
Predictive What is likely to happen? Estimate future or unknown outcomes Forecasts, probabilities and predictions
Prescriptive What should we do? Support decisions and recommend actions Recommendations, optimized decisions and action plans

These categories should not be interpreted as completely separate activities. A single Data Science project may use all four.

For example, a retailer could first determine what happened to sales, investigate why it happened, estimate what is likely to happen next month and finally determine what action should be taken.

13.10 An Integrated Example of Data Analytics

Consider a university that wants to improve student retention.

Step 1: Descriptive Analytics — What Happened?:

The university examines historical records and discovers that the percentage of students returning for the second year has decreased from 82% to 75% over three academic sessions.

This establishes the observed pattern.

Step 2: Diagnostic Analytics — Why Did It Happen?:

The university investigates factors such as academic performance, course workload, financial difficulties, attendance and student engagement.

The analysis may reveal that withdrawal rates are particularly high among students experiencing poor performance in foundational courses.

Step 3: Predictive Analytics — What Is Likely to Happen?:

A predictive model may use historical student information to estimate which currently enrolled students have a higher probability of withdrawing.

The prediction allows the university to identify students who may benefit from early intervention.

Step 4: Prescriptive Analytics — What Should Be Done?:

The university may compare possible interventions such as academic advising, tutoring, additional learning resources or targeted support programmes and determine which combination is most appropriate under its available resources.

The complete analytical chain:

What happened? → Why? → What is likely? → What should we do?

13.11 Big Data, Data Analytics and Data Science

Big Data, Data Analytics and Data Science are closely related, but they are not interchangeable terms.

Big Data focuses on the characteristics and challenges associated with large-scale, high-speed, diverse or complex datasets.

Data Analytics focuses on examining data to understand patterns, answer questions, generate insights and support decisions.

Data Science is a broader interdisciplinary field that combines statistical, mathematical, computational and domain knowledge to extract knowledge and build data-driven solutions.

Concept Primary Focus Example
Big Data Managing and processing challenging large-scale data Processing millions of sensor readings per second
Data Analytics Examining data to generate insights Analyzing sales data to identify declining product demand
Data Science Using interdisciplinary methods to extract knowledge and develop data-driven solutions Developing and evaluating a predictive system using historical data

Not every Data Science project involves Big Data. A Data Scientist may work with a dataset containing only a few thousand observations. Similarly, Big Data systems are not useful merely because they are large; their value depends on how effectively the data can be processed and applied.

13.12 Applications of Big Data and Data Analytics

Healthcare:

Healthcare organizations can analyze clinical records, laboratory results, medical images, treatment histories and operational data. Analytics can support disease-risk assessment, resource planning, patient monitoring and healthcare management.

Finance:

Financial institutions analyze transaction data, customer behavior and market information. Analytics can support fraud detection, risk assessment, customer segmentation and financial forecasting.

Education:

Educational institutions can analyze student performance, attendance, course participation and learning activities. Such analysis can help identify students who may require additional support and evaluate educational outcomes.

Agriculture:

Agricultural systems can combine weather information, soil measurements, satellite imagery, crop information and farm records. Analytics can support crop monitoring, resource management and yield estimation.

Business:

Businesses use analytics to understand customers, forecast demand, optimize operations, monitor performance and support strategic decisions.

Transportation:

Transport organizations can analyze traffic, vehicle location, passenger demand and route information to improve scheduling, routing and resource utilization.

Manufacturing:

Industrial systems can collect sensor readings from machines and production lines. Analytics can help identify abnormal operating conditions and support predictive maintenance.

Government:

Government agencies can use data to support planning, public-service delivery, resource allocation and policy analysis.

13.13 Common Misconceptions and Mistakes

1. “Big Data simply means a very large database.”

Size is important, but Big Data also involves characteristics such as velocity, variety, veracity and value.

2. “All Big Data must be processed in real time.”

High velocity is one possible characteristic of Big Data, but not every Big Data application requires real-time processing.

3. “Big Data is always better than small data.”

Large datasets can contain errors, biases and irrelevant observations. Data quality and relevance remain essential.

4. “Data Analytics and Data Science are exactly the same.”

They overlap substantially, but Data Science is broader and may include data engineering, statistical modelling, machine learning and other computational activities in addition to analytics.

5. “Predictive analytics tells us exactly what will happen.”

Predictions are estimates based on available information and assumptions. They involve uncertainty.

6. “Prescriptive analytics automatically makes every decision.”

Prescriptive analytics provides recommendations or evaluates possible actions. Human judgment, organizational constraints and ethical considerations may still be necessary.

7. “A correlation automatically proves causation.”

Two variables may change together without one directly causing the other. Analytical conclusions must therefore be interpreted carefully.

13.14 Key Points

  • Big Data refers to data environments whose characteristics create substantial challenges for conventional data-processing approaches.
  • The commonly discussed characteristics of Big Data are Volume, Velocity, Variety, Veracity and Value.
  • Volume concerns the amount of data.
  • Velocity concerns the speed at which data is generated, transmitted and processed.
  • Variety concerns the different forms and sources of data.
  • Veracity concerns the reliability and quality of data.
  • Value concerns the useful benefit that can be obtained from data.
  • Big Data integration combines or connects information from multiple sources so that it can be analyzed consistently.
  • Big Data can support intelligent decision-making when data is properly processed, analyzed and interpreted.
  • Major Big Data challenges include storage, processing, integration, data quality, security, privacy, cost and skills.
  • Data Analytics is the systematic examination of data to generate useful insights and support decisions.
  • Descriptive analytics asks what happened.
  • Diagnostic analytics investigates why something happened.
  • Predictive analytics estimates what is likely to happen.
  • Prescriptive analytics considers what should be done.
  • Big Data, Data Analytics and Data Science are related but distinct concepts.
  • The value of Big Data depends not merely on its size but on the ability to convert it into reliable and useful insights.

13.15 Chapter Summary

Big Data has emerged from the rapid growth of digital information generated by individuals, organizations, machines and connected systems. It describes data environments characterized by properties that can make conventional approaches to storage, processing, integration and analysis inadequate.

The major characteristics of Big Data are commonly summarized using the five Vs: Volume, Velocity, Variety, Veracity and Value. These characteristics explain both the opportunities and the challenges associated with modern large-scale data environments.

Big Data integration is important because useful information is often distributed across multiple systems and formats. Combining these sources allows organizations to develop a more complete view of their activities, customers, operations or environments.

Data Analytics provides methods for transforming data into useful insights. The four major categories of analytics provide progressively different levels of understanding: descriptive analytics explains what happened, diagnostic analytics investigates why it happened, predictive analytics estimates what is likely to happen, and prescriptive analytics considers what should be done.

Big Data and Data Analytics are important components of modern Data Science, but they are not identical. Big Data addresses the challenges associated with complex data environments, while Data Analytics focuses on extracting useful meaning from data. Data Science brings together these and other disciplines to solve problems and develop data-driven solutions.

The central principle of this chapter can therefore be expressed as:

Big Data provides extensive information; Data Analytics transforms that information into insight; and insight supports informed decision-making.

CHAPTER FOURTEEN

Data Science Applications and Introduction to Programming

Chapter Introduction

Data Science is applied to many forms of data, including images, text, audio and video. Although these data types may appear very different, they can all be collected, processed, analysed and used to support decision-making. Modern Data Science therefore extends beyond traditional tables and spreadsheets into areas such as computer vision, natural language processing, speech analysis and multimedia analytics.

Programming is an essential part of this process. A data scientist frequently needs to write programs to collect data, clean datasets, perform calculations, build visualizations, train models, evaluate results and automate repetitive tasks. Programming also provides the flexibility required to work with large datasets and specialized Data Science tools.

This chapter introduces the major applications of Data Science to image, natural language, audio and video data and then establishes the foundation for programming in Data Science. Particular attention is given to the role of programming and to the two widely used languages Python and R.

14.1 Data Science and Different Forms of Data

Data Science is not restricted to numerical tables. In practical applications, information may be represented in many forms.

Data Type Examples Typical Data Science Tasks
Tabular data Customer records, sales figures, examination results Statistical analysis, prediction, classification
Image data Photographs, medical scans, satellite images Object recognition, image classification, detection
Text data Emails, articles, social-media posts, reports Text classification, sentiment analysis, information extraction
Audio data Speech recordings, music, machine sounds Speech recognition, speaker identification, sound classification
Video data Security footage, sports recordings, traffic cameras Object tracking, activity recognition, event detection

The major challenge is that non-tabular data often contains complex structures. A photograph contains thousands or millions of numerical pixel values. A sentence contains words whose meaning depends on context. Audio contains signals that change over time, while video contains sequences of images that may also contain sound.

Data Science provides methods for converting these complex representations into forms that computers can analyse.

14.2 Data Science Applications in Image Data

An image can be represented digitally as a collection of pixels. A pixel is a small element of an image to which numerical values are assigned. In a grayscale image, a pixel may be represented by a single intensity value. In a colour image, several numerical values may be used to represent colour channels.

Because images can be represented numerically, mathematical and computational techniques can be applied to them.

14.2.1 Image Classification:

Image classification involves assigning an image to one or more predefined categories.

For example, a system may be trained to classify images as:

  • cat or dog;
  • healthy or diseased crop;
  • defective or non-defective product;
  • road or non-road image; or
  • different categories of medical images.

A classification system generally learns patterns from labelled training examples and uses those patterns to classify previously unseen images.

14.2.2 Object Detection:

Object detection goes beyond determining what an image contains. It attempts to identify the locations of particular objects within the image.

For example, a traffic-monitoring system may identify several vehicles in an image and determine approximately where each vehicle is located.

The distinction can be summarized as follows:

Task Main Question
Image classification What category does this image belong to?
Object detection What objects are present, and where are they?
Image segmentation Which pixels belong to particular objects or regions?

14.2.3 Applications of Image Data Science:

Image-based Data Science has applications in many fields.

Healthcare: Medical images such as X-rays, CT scans and MRI scans can be analysed to assist qualified professionals in identifying patterns associated with diseases or abnormalities.

Agriculture: Images captured by drones or satellites can be analysed to monitor crops, identify areas of stress and assess vegetation.

Manufacturing: Cameras can inspect products for defects and identify objects that do not meet specified quality requirements.

Security: Computer vision can assist with object detection, movement analysis and identity-related tasks where appropriate safeguards and legal requirements are satisfied.

Transportation: Image analysis can support traffic monitoring, road-condition assessment and driver-assistance systems.

14.3 Data Science and Natural Language

Human language is one of the most important forms of information produced by society. Books, emails, news articles, customer reviews, reports, social-media posts and online discussions contain large quantities of textual information.

Unlike a simple numerical dataset, natural language contains grammar, ambiguity, context and relationships between words. The same word can have different meanings depending on the sentence in which it occurs.

Natural Language Processing (NLP) applies computational methods to human language so that computers can analyse, understand, transform or generate language.

14.3.1 Common NLP Tasks:

Text classification: Assigning text to categories.

Sentiment analysis: Estimating the expressed attitude or sentiment in a piece of text, such as positive, negative or neutral sentiment.

Language identification: Determining the language used in a text.

Information extraction: Identifying useful information such as names, dates, locations and organizations from text.

Text summarization: Producing a shorter representation of a longer document while preserving important information.

Machine translation: Automatically converting text from one language into another.

Question answering: Producing answers to questions using information contained in text or other sources.

14.3.2 Example of Text Classification:

Consider an organization that receives thousands of customer emails. Each email can be classified into categories such as billing, technical support, account access or general enquiry.

A Data Science system can learn from previously labelled emails and then assign new emails to the most appropriate category.

The process can be represented as:

Customer email → Text processing → Feature/model representation → Classification → Appropriate category

This does not mean that the computer understands language in exactly the same way as a human. Rather, computational methods identify patterns in the available data and use those patterns to perform the specified task.

14.4 Data Science Applications in Audio

Audio data represents sound in digital form. Examples include human speech, music, machine sounds, environmental noise and recorded conversations.

Digital audio can be analysed as a signal that changes over time. Data Science techniques can therefore be used to identify patterns in the signal and associate those patterns with meaningful categories or events.

14.4.1 Speech Recognition:

Speech recognition involves converting spoken language into a computer-readable representation, often text.

For example, a user may speak a sentence into a smartphone and receive a written transcription of the speech.

Speech recognition is useful in:

  • voice-controlled applications;
  • automatic transcription;
  • accessibility technologies;
  • customer-service systems;
  • meeting transcription; and
  • voice search.

14.4.2 Sound Classification:

Data Science can also be used to classify sounds. A system may be trained to distinguish between different environmental or machine sounds.

For example, an industrial monitoring system may analyse the sound produced by machinery and identify unusual patterns that could indicate a developing fault.

14.4.3 Speaker Identification:

Speaker identification involves determining which known speaker produced a particular voice recording. It is different from speech recognition: speech recognition focuses primarily on what was said, while speaker identification focuses on who said it.

14.5 Data Science Applications in Video

Video data can be considered a sequence of images captured over time. A video may also contain an audio track. Consequently, video analysis can involve image analysis, temporal analysis and, where appropriate, audio analysis.

14.5.1 Object Tracking:

Object tracking involves following an object as it moves through successive video frames.

For example, a traffic-monitoring system can track a vehicle as it moves through a sequence of camera frames.

14.5.2 Activity Recognition:

Video analysis can be used to identify activities or events. Examples include recognizing particular sports actions, monitoring industrial processes or identifying specific movements in a controlled environment.

14.5.3 Video Analytics Applications:

  • Transportation: traffic monitoring and vehicle counting.
  • Sports: player and ball tracking and performance analysis.
  • Manufacturing: monitoring production processes.
  • Security: detection of specified events or movements.
  • Retail: analysis of customer movement patterns.
  • Media: automatic classification and organization of video content.

Video analytics can involve substantial computational requirements because a single video may contain thousands of individual frames. Efficient processing methods and appropriate computing resources are therefore important.

14.6 Introduction to Programming for Data Science

Programming is the process of creating instructions that a computer can execute. A programming language provides the rules and vocabulary used to express those instructions.

In Data Science, programming is not simply about learning how to write software applications. It is primarily a means of instructing computers to manipulate data, perform calculations, analyse patterns, build models and automate workflows.

A simple Data Science task might involve the following sequence:

1. Read a dataset.

2. Inspect the data.

3. Clean missing or invalid values.

4. Transform the data.

5. Calculate statistics.

6. Create visualizations.

7. Build a predictive model.

8. Evaluate and communicate the results.

Programming allows these operations to be performed systematically and repeatedly.

14.7 Why Programming Is Important in Data Science

Automation:

Programming allows repetitive operations to be automated. Instead of manually performing the same operation on thousands of records, a program can apply the operation consistently across the dataset.

Data Processing:

Data scientists often work with datasets containing thousands, millions or even billions of records. Programming provides practical methods for reading, filtering, transforming and combining such data.

Statistical Analysis:

Programs can perform statistical calculations efficiently and reproducibly. Means, medians, standard deviations, correlations and other measures can be calculated using code.

Visualization:

Programming languages provide libraries for creating charts and graphs. A data scientist can generate visualizations directly from a dataset and modify them as the analysis changes.

Machine Learning:

Machine-learning workflows generally require programming to prepare data, train models, evaluate performance and make predictions.

Reproducibility:

A well-written program provides a record of the operations used to obtain an analytical result. Another analyst can execute the same code on the same data and, when the environment and inputs are appropriately controlled, reproduce the analysis.

Integration:

Programming can connect different stages of a Data Science workflow. For example, a program can collect data from a source, clean it, analyse it, generate a report and store the results.

14.8 Basic Programming Concepts for Data Science

A student beginning programming for Data Science should understand several fundamental concepts.

Variables:

A variable is a named reference used by a program to store or represent a value.

For example, a program may store the number of students in a class using a variable such as number_of_students.

Data Types:

Programming languages provide different types of data. Common examples include:

  • Integer: whole numbers such as 10, 25 and -4.
  • Floating-point number: numbers containing a fractional component, such as 3.14 or 12.5.
  • String: a sequence of characters such as "Data Science".
  • Boolean: a logical value such as true or false.

Operators:

Operators allow programs to perform operations on values.

For example, arithmetic operators can perform addition, subtraction, multiplication and division.

If a dataset contains two values, 15 and 5:

Addition: 15 + 5 = 20

Subtraction: 15 − 5 = 10

Multiplication: 15 × 5 = 75

Division: 15 ÷ 5 = 3

Conditional Statements:

A conditional statement allows a program to make a decision based on a condition.

For example, a program analysing examination results might classify a score of 50 or above as a pass.

Condition: Is the score greater than or equal to 50?

If yes: classify as Pass.

If no: classify as Fail.

Loops:

A loop allows a program to repeat an operation. Loops are particularly useful in Data Science because the same operation often needs to be applied to many observations.

For example, a program may examine each record in a dataset and determine whether a particular field contains a missing value.

Functions:

A function is a reusable block of code designed to perform a particular task. Functions help reduce repetition and make programs easier to organize and maintain.

14.9 Programming in a Data Science Workflow

Programming can be used at nearly every stage of the Data Science lifecycle.

Stage Example of Programming Use
Data collection Retrieving data from files, databases, sensors or permitted online sources.
Data cleaning Removing duplicates, handling missing values and correcting formats.
Transformation Changing variables into forms suitable for analysis.
Analysis Calculating descriptive statistics and examining relationships.
Visualization Creating charts and graphs from datasets.
Modelling Training and evaluating machine-learning models.
Reporting Generating tables, reports and analytical outputs.

14.10 Python for Data Science

Python is a general-purpose programming language widely used in Data Science. Its relatively readable syntax and extensive ecosystem of libraries have made it an important language for data analysis, machine learning and scientific computing.

Python can be used for both simple data-processing tasks and advanced computational applications.

14.10.1 Important Python Libraries:

Library Common Purpose
NumPy Numerical computing and array-based operations.
pandas Data manipulation and analysis, especially tabular data.
Matplotlib Data visualization and plotting.
scikit-learn Machine-learning algorithms and model evaluation.
TensorFlow Machine learning and deep-learning development.
PyTorch Machine learning and deep-learning development.

14.10.2 A Simple Python Example:

Suppose a student wants to calculate the average of three examination scores: 60, 70 and 80.

scores = [60, 70, 80]

average = sum(scores) / len(scores)

print(average)

The program stores the scores in a collection, calculates their total using sum(), determines the number of scores using len(), and divides the total by the number of observations.

The calculation is:

Average = (60 + 70 + 80) / 3 = 210 / 3 = 70

The program therefore produces an average of 70.

14.11 R for Data Science

R is a programming language and computing environment designed particularly for statistical analysis, data manipulation and visualization.

R is widely used in statistics, research, academia and data analysis. It provides extensive facilities for statistical modelling and graphical representation.

14.11.1 Characteristics of R:

  • strong emphasis on statistical computing;
  • powerful facilities for data visualization;
  • large collection of packages for specialized analysis;
  • strong support for statistical modelling;
  • useful tools for exploratory data analysis; and
  • active use in academic and research environments.

14.11.2 Simple R Example:

The average of the same three scores can be calculated in R as follows:

scores <- c(60, 70, 80)

average <- mean(scores)

print(average)

The function mean() calculates the arithmetic mean of the values in the collection.

Therefore:

Mean = (60 + 70 + 80) / 3 = 70

14.12 Python and R Compared

Python and R are both important Data Science languages, but they have different historical backgrounds and areas of emphasis.

Feature Python R
General nature General-purpose programming language Language and environment strongly oriented toward statistical computing
Data analysis Very strong Very strong
Statistics Extensive libraries Particularly strong historical emphasis
Machine learning Extensive ecosystem Extensive packages and tools
Visualization Strong Strong
General software development Widely used Less commonly used as a general software-development language

There is no universal rule that one language is always superior to the other. The appropriate choice depends on the problem, available tools, team expertise and intended application.

Important: A student should not think of Python and R as competing subjects in which one must replace the other. The fundamental objective is to understand computational and analytical principles. Programming languages are tools for applying those principles.

14.13 Programming, Data Analysis and Machine Learning

It is important to distinguish between programming, data analysis and machine learning.

Programming is the process of creating executable instructions.

Data analysis involves examining data to identify patterns, relationships, trends and useful findings.

Machine learning involves computational methods that allow systems to learn patterns from data and use those patterns for tasks such as prediction or classification.

These areas overlap but are not identical.

Concept Primary Question
Programming How can we instruct the computer to perform the task?
Data analysis What can we learn from the available data?
Machine learning Can a computational system learn useful patterns from data for a specified task?

14.14 An Integrated Example: Analysing Customer Reviews

Consider an online retailer that receives thousands of customer reviews every month.

The organization wants to determine whether customers are generally satisfied and identify the major issues mentioned in the reviews.

A Data Science workflow could involve the following:

Step 1 — Data collection: Customer reviews are collected from an authorized source.

Step 2 — Data preparation: Duplicate records and unusable entries are identified and handled.

Step 3 — Text processing: The written reviews are processed using appropriate natural language techniques.

Step 4 — Sentiment analysis: Reviews may be classified according to sentiment.

Step 5 — Information extraction: Frequently mentioned subjects such as delivery, product quality or customer service can be identified.

Step 6 — Visualization: Results can be presented using charts showing the frequency of different issues.

Step 7 — Interpretation: Analysts interpret the findings in relation to the business question.

Step 8 — Decision-making: Management can use the evidence to investigate recurring problems and improve services.

This example demonstrates that Data Science is not simply about writing a program. Programming, statistics, data preparation, domain knowledge, visualization and interpretation work together to produce useful results.

14.15 Common Mistakes and Misconceptions

1. “Data Science is just programming.” Programming is an important tool, but Data Science also involves statistics, mathematics, data management, domain knowledge, communication and critical reasoning.

2. “A data scientist must know every programming language.” Proficiency in a small number of appropriate tools is more valuable than superficial familiarity with many languages.

3. “Python is the only language used in Data Science.” Python is widely used, but R and other languages are also important in appropriate contexts.

4. “R is only useful for beginners.” R is a serious statistical computing environment used in research, industry and advanced data analysis.

5. “More complicated code produces better Data Science.” Good Data Science emphasizes correctness, clarity, reproducibility and suitability for the problem. Unnecessary complexity can make analysis harder to verify.

6. “A machine-learning model automatically produces correct conclusions.” A model can produce inaccurate or misleading results when data are poor, biased, inappropriate or incorrectly interpreted.

7. “Image, audio and video data are completely different from numerical data.” At the computational level, these forms of information can be represented using numerical structures that computers can process.

8. “Programming eliminates the need for human judgment.” Programs execute instructions, but humans remain responsible for defining appropriate questions, selecting suitable methods, checking assumptions and interpreting results.

14.16 Key Points

  • Data Science can be applied to numerical, textual, image, audio and video data.
  • Image Data Science includes classification, object detection and segmentation.
  • Computer vision enables computers to extract useful information from visual data.
  • Natural Language Processing allows computational systems to process and analyse human language.
  • Common NLP tasks include classification, sentiment analysis, information extraction, translation and summarization.
  • Audio Data Science can support speech recognition, speaker identification and sound classification.
  • Video analytics can involve object tracking, activity recognition and event detection.
  • Programming provides instructions that allow computers to perform Data Science tasks.
  • Programming can support data collection, cleaning, transformation, analysis, visualization, modelling and reporting.
  • Python is a general-purpose language with a large Data Science ecosystem.
  • R is particularly strong in statistical computing, analysis and visualization.
  • Python and R are both useful Data Science tools, and the appropriate choice depends on the task and context.
  • Programming, data analysis and machine learning are related but distinct concepts.
  • Effective Data Science requires both computational skills and sound analytical judgment.

14.17 Comprehensive Course Review

Chapter 14 brings together several important ideas developed throughout DTS 201: Introduction to Data Science.

Data Science begins with the understanding that useful knowledge can be obtained from data through systematic processes involving collection, preparation, analysis, modelling, interpretation and communication.

Earlier chapters introduced the nature of data, data classification, applications of Data Science, the Data Science lifecycle, data preprocessing, visualization, probability, simulation, prediction, knowledge extraction, data mining, Big Data and analytics.

The present chapter extends these ideas to more complex forms of data and introduces programming as a practical computational foundation.

The complete Data Science process can therefore be viewed as an interconnected system:

Problem → Data → Preparation → Analysis → Visualization → Models → Evaluation → Knowledge → Decision

Programming supports many of these stages. It provides the practical means through which data can be manipulated, analysed and transformed into useful outputs.

Major Areas Covered in DTS 201:

Topic Central Idea
Fundamentals of Data Science Understanding what Data Science is and how it relates to other disciplines.
Data and Classification Understanding different forms and classifications of data.
Scope and Applications Understanding where Data Science is applied.
Data Science Process Understanding the stages involved in solving data problems.
Data Collection and Preprocessing Preparing data for reliable analysis.
Data Visualization Representing information visually for understanding and communication.
Distributions and Probability Understanding uncertainty and patterns in data.
Simulation and Analysis Using computational experiments to investigate uncertain systems.
Predictions and Models Using data and models to make informed predictions.
Knowledge Extraction Transforming processed data into useful information and knowledge.
Data Mining Discovering useful patterns and relationships in datasets.
Big Data and Analytics Understanding large-scale data and the different purposes of analytics.
Applications and Programming Applying Data Science to complex data and using programming as a computational tool.

14.18 Chapter Summary

Data Science can be applied to many forms of information beyond conventional tables. Images can be analysed using computer-vision techniques for tasks such as classification, object detection and segmentation. Text can be processed using Natural Language Processing techniques for classification, sentiment analysis, information extraction, summarization and translation.

Audio data can be analysed for speech recognition, speaker identification and sound classification, while video data can be analysed for object tracking, activity recognition and event detection.

Programming provides the computational foundation for carrying out many Data Science tasks. It allows data scientists to collect, clean, transform, analyse and visualize data and to develop and evaluate computational models.

Python and R are two important programming tools in Data Science. Python is a general-purpose programming language with an extensive ecosystem for data analysis, machine learning and scientific computing. R has a particularly strong emphasis on statistical analysis, visualization and research-oriented computing.

The central lesson of this chapter is that Data Science is multidisciplinary. Programming is essential, but it works together with mathematics, statistics, domain knowledge, data management and critical reasoning. The goal is not merely to produce code or models, but to transform data into reliable information and useful knowledge that can support sound decisions.