AI, MACHINE LEARNING, AND DATA SCIENCE
Artificial intelligence, Machine learning, and data science are all related to
each other.
However, all of these three fields are distinct depending on the context.
Following figure shows the relationship between artificial intelligence, machine
learning, and data science
AI (Artificial Intelligence)
Artificial intelligence is about giving machines the capability of mimicking human
behaviour.
AI aims to build intelligent machines capable of performing tasks that typically
require human intelligence, such as problem-solving, decision-making, and
understanding language.
Examples : facial recognition, automated driving, sorting mail based on postal code,
etc.
There are a range of techniques that fall under artificial intelligence: linguistics,
natural language processing, decision science, vision, robotics, planning, etc.
ML (Machine Learning)
Machine learning can either be considered a sub-field or one of the tools of artificial
intelligence, is providing machines with the capability of learning from experience.
Experience for machines comes in the form of data. Data that is used to teach
machines is called training data.
Machine Learning is applied using Algorithms to process the data and get trained for
delivering future predictions without human intervention.
Machine learning turns the traditional programing model upside down (see figure).
Machine learning algorithms, also called “learners”, take both the known input and
output (training data) to figure out a model for the program which converts input to
output.
Example :
Social media platforms are required to moderate posts and remove abusive content.
How can machines be taught to automate the removal of abusive content?
The machines need to be shown examples of both abusive and non-abusive
posts with a clear indication of which one is abusive.
The learners will generalize a pattern based on certain words or sequences of
words in order to conclude whether the overall post is abusive or not
The model can take the form of a set of “if-then” rules. Once the model is
developed machines can start categorizing the disposition of any new posts.
Implementations
The process of building an ML solution typically involves two tasks:
1. Select and prepare a training dataset
2. Choose a preexisting ML strategy or model, such as linear regression or a decision tree
Data scientists select important data features and feed them into the model for training.
They continuously refine the dataset with updated data and error checking. Data quality and
variety improve the accuracy of the ML model.
DATA SCIENCE
Data science is the business application of machine learning, artificial intelligence
or
Data science is a broader field that uses AI and ML, along with statistics and
computer science, to extract insights from data and inform decision-making.
Data Science is the complex study of the large amount of data in a company or
organization's repository.
It is an interdisciplinary field that extracts value from data. In the context of how
data science is used today, it relies heavily on machine learning and is sometimes
called data mining.
Example:
Recommendation engines that can recommend movies for a particular user.
A fraud alert model that detects fraudulent credit card transactions
Data science starts with data, which can range from a simple array of a few numeric
observations to a complex matrix of millions of observations with thousands of
variables.
Data science utilizes certain specialized computational methods in order to discover
meaningful and useful structures within a dataset.
data science is closely associated with a number of related areas such as database
systems, data analysis, experimentation, and business intelligence (BI).
Core Components of Machine Learning:
Data Processing: Preparing data for ML models through preprocessing techniques.
Model Selection: Choosing the appropriate model for the task (e.g., regression,
classification, clustering).
Training and Testing: Splitting data to evaluate model performance and optimize it
for real-world application.
Tools Used in Machine Learning:
Programming Languages: Python, R.
Data scientists select important data features and feed them into the model for training. They
continuously refine the dataset with updated data and error checking. Data quality and variety
improve the accuracy of the ML model.
Core Components of Data Science:
Data Collection: Gathering raw data from multiple sources.
Data Cleaning and Preprocessing: Removing inconsistencies, handling missing values,
and formatting data for analysis.
Data Analysis and Visualization: Finding patterns in data and presenting findings
through charts, graphs, and dashboards.
Predictive Modeling: Using algorithms to make predictions based on historical data.
Data Interpretation and Communication: Translating insights for business
stakeholders.
Tools Used in Data Science:
Programming Languages:Python, R
Essentially, data science provides the raw materials and analysis, ML provides the learning
algorithms, and AI provides the intelligent applications.
What’s the difference between AI and Machine Learning?
Artificial intelligence (AI) is an umbrella term for different strategies and techniques
you can use to make machines more humanlike.
AI includes everything from smart assistants like Alexa to robotic vacuum cleaners
and self-driving cars.
Machine learning (ML) is one among many other branches of AI. ML is the science of
developing algorithms and statistical models that computer systems use to perform
complex tasks without explicit instructions.
While machine learning is AI, not all AI activities are machine learning.
Conclusion
While Data Science and Machine Learning are closely related fields, they have
distinct purposes, techniques, and applications.
Data Science is a broad field focused on analyzing and interpreting data, whereas
Machine Learning is a subset that involves developing algorithms for predictive
insights.
DATA SCIENCE CLASSIFICATION
Data science problems can be broadly categorized into supervised or unsupervised learning
models.
Supervised or directed data science tries to infer a function or relationship based on labeled
training data and uses this function to map new unlabeled data.
Supervised techniques predict the value of the output variables based on a set of input
variables.
To do this, a model is developed from a training dataset where the values of input and
output are previously known.
The model generalizes the relationship between the input and output variables and uses it
to predict for a dataset where only input variables are known.
What is Supervised Learning?
Supervised learning is a machine learning approach in which the model learns from a dataset
that contains input–output pairs.
Input (features) → what you give to the model
Output (label/target) → the correct answer
The goal is for the model to learn the relationship between inputs and outputs so it can
predict the output for new, unseen data.
Supervised Learning Examples
In supervised learning, the model is trained using labeled data (input + correct output).
1. Email Spam Detection
Input: Email text
Output (Label): Spam / Not spam
Type: Classification
2. House Price Prediction
Input: Size, location, number of rooms
Output (Label): Price of the house
Type: Regression
3. Image Classification
Input: Image of an animal
Output (Label): Cat / Dog / Horse
Type: Classification
4. Student Grade Prediction
Input: Study hours, attendance
Output: Predicted marks
Type: Regression
What is Unsupervised Learning?
Unsupervised learning is an ML approach where the algorithm tries to discover hidden
patterns, group similar data without any guidance.
No labels
No correct answers provided
The model finds structure on its own
How Unsupervised Learning Works (Simple Steps)
1. Input: only raw data (no labels)
2. Algorithm: finds patterns or groups
3. Model: organizes data into clusters/patterns
4. Output: groups, patterns, or reduced features
Unsupervised Learning Examples
In unsupervised learning, the model is trained using unlabeled data (only input, no known
output).
1. Customer Segmentation
Input: Purchase behavior
Output: Groups of similar customers
Type: Clustering
2. Market Basket Analysis
Input: Items purchased together
Output: Associations (e.g., "People who buy bread also buy butter")
Type: Association rule mining
3. Anomaly Detection
Input: Normal system behavior
Output: Detect unusual behavior (fraud, network attacks)
Type: Outlier detection
4. Document Topic Modeling
Input: Collection of articles
Output: Discover hidden topics (politics, sports, tech, etc.)
Type: Topic modeling
Data science problems can also be classified into tasks as shown below:
Classification and regression techniques predict a target variable based on
input variables.
The prediction is based on a generalized model built from a previously known
dataset.
In regression tasks, the output variable is numeric (e.g., the mortgage interest
rate on a loan).
Classification tasks predict output vari ables, which are categorical or
polynomial (e.g., the yes or no decision to approve a loan).
Anomaly or outlier detection identifies the data points that are significantly dif
ferent from other data points in a dataset. Credit card transaction fraud detec
tion is one of the most prolific applications of anomaly detection.
Combined Example: Customer Segmentation +
Purchase Prediction
Step 1: Unsupervised Learning (Clustering)
A retail company has data about customers but no labels.
Features: age, income, purchase frequency, product categories
Apply K-Means Clustering
Output:
o Cluster 1 → Budget shoppers
o Cluster 2 → Regular shoppers
o Cluster 3 → Premium shoppers
Step 2: Supervised Learning (Prediction)
Now the company wants to predict whether a new customer will buy a specific product.
Input: customer features + cluster label (from Step 1)
Output: Will the customer buy? (Yes/No)
Model: Logistic Regression / Decision Tree
Why is this a combined example?
Unsupervised: Finds hidden patterns (customer groups).
Supervised: Uses the discovered groups to predict a future outcome.
DATA SCIENCE ALGORITHMS
In data science, it is the blueprint for how a particular data problem is solved.
A classification task can be solved using many different learning algo rithms such as decision
trees, artificial neural networks, k-NN
The choice of which algorithm to use depends on the type of dataset, objective, structure of
the data
data science tools or statistical programing tools, like R, RapidMiner, Python, SAS Enterprise
Miner, etc., which can implement these algorithms with ease.
These data science tools offer a library of algorithms as functions, which can be interfaced
through programming code or configurated through graphical user interfaces.
Introduction to RDBMS
Database
A database is a collection of related data. By data, we mean known facts
that can be recorded and that have implicit meaning.
For example: bank data base, university database, college database, etc.
Defining a database involves specifying the data types, structures, and
constraints of the data to be stored in the database.
DBMS
A database management system (DBMS) is a computerized system that
enables users to create and maintain a database.
The DBMS is a general-purpose software system that facilitates the
processes of defining, constructing, manipulating, and sharing databases
among various users and applications.
The database definition or descriptive information is also stored by the
DBMS in the form of a database catalog or dictionary; it is called meta-
data.
Constructing the database is the process of storing the data on some
storage medium that is controlled by the DBMS.
Manipulating a database includes functions such as querying the database
to retrieve specific data, updating the database.
We will call the database and DBMS software together a database
system. Figure 1.1 illustrates some of the concepts.
The Relational Data Model and Relational Database Constraints
Relational Model Concepts The relational model represents the database
as a collection of relations. Each relation resembles a table of values.
Each row in the table represents a collection of related data values.
In the formal relational model terminology, a row is called a tuple, a
column header is called an attribute, and the table is called a relation.
Domains, Attributes, Tuples, and Relations
A domain D is a set of atomic values.
■ Usa_phone_numbers. The set of ten-digit phone numbers valid in the
United States.
■ Names: The set of character strings that represent names of persons.
■ Employee_ages. Possible ages of employees in a company; each must
be an integer value between 15 and 80.
A relation schema R, denoted by R(A1, A2, … , An), is made up of a relation
name R and a list of attributes, A1, A2, … , An. Each attribute Ai is the name of
a role played by some domain D in the relation schema R. D is called the
domain of Ai and is denoted by dom(Ai).
The degree (or arity) of a relation is the number of attributes n of its
relation schema.
STUDENT(Name, Ssn, Home_phone, Address, Office_phone, Age, Gpa)
Figure 5.1 shows an example of a STUDENT relation.
Relational Model Constraints and Relational Database Schemas
The state of the whole database will correspond to the states of all its
relations at a particular point in time.
There are generally many restrictions or constraints on the actual values
in a database state.
Constraints on databases can generally be divided into three main categories:
1. Constraints that are inherent in the data model. We call these inherent
model-based constraints or implicit constraints.
2. Constraints that can be directly expressed in the schemas of the data model,
typically by specifying them in the DDL. We call these schema-based
constraints or explicit constraints.
3. Constraints that cannot be directly expressed in the schemas of the data
model, and hence must be expressed and enforced by the application
programs We call these application-based or semantic constraints.
The schema-based constraints include domain constraints, key
constraints, constraints on NULLs, entity integrity constraints, and
referential integrity constraints
Domain Constraints
Domain constraints specify that within each tuple, the value of each
attribute A must be an atomic value from the domain dom(A).
Key Constraints
In the formal relational model, a relation is defined as a set of tuples. By
definition, all elements of a set are distinct; hence, all tuples in a relation
must also be distinct. This means that no two tuples can have the same
combination of values for all their attributes.
Usually, there are other subsets of attributes of a relation schema R with
the property that no two tuples in any relation state r of R should have the
same combination of values for these attributes.
Suppose that we denote one such subset of attributes by SK; then for any
two distinct tuples t1 and t2 in a relation state r of R, we have the
constraint that:
t1[SK] ≠ t2[SK]
Any such set of attributes SK is called a superkey of the relation schema
R.
A superkey SK specifies a uniqueness constraint that no two distinct
tuples in any state r of R can have the same value for SK. Every
relation has at least one default superkey— the set of all its attributes.
A key k of a relation schema R is a superkey of R.
a key satisfies two properties:
1. Two distinct tuples in any state of the relation cannot have identical
values for (all) the attributes in the key. This uniqueness property also
applies to a superkey.
2. It is a minimal superkey—that is, a superkey from which we cannot
remove any attributes and still have the uniqueness constraint hold.
This minimality property is required for a key but is optional for a
superkey.
Hence, a key is a superkey but not vice versa. A superkey may be a
key (if it is minimal) or may not be a key (if it is not minimal).
In general, any superkey formed from a single attribute is also a key.
In general, a relation schema may have more than one key. In this
case, each of the keys is called a candidate key.
For example, the CAR relation in Figure 5.4 has two candidate keys:
License_number and Engine_serial_number.
It is common to designate one of the candidate keys as the primary
key of the relation.
It is usually better to choose a primary key with a single attribute or a
small number of attributes.
Relational Databases and Relational Database Schemas
A relational database usually contains many relations.
A relational database schema S is a set of relation schemas S = {R1,
R2, … , Rm} and a set of integrity constraints IC.
A relational database state DB of S is a set of relation states DB = {r1,
r2, … , rm} such that each ri is a state of Ri and relation states satisfy
the integrity constraints specified in IC.
Figure 5.5 shows a relational database schema
Figure 5.6 shows a relational database state corresponding to the
COMPANY schema.
Entity Integrity, Referential Integrity, and Foreign Keys
The entity integrity constraint states that no primary key value can be
NULL.
Key constraints and entity integrity constraints are specified on
individual relations.
The referential integrity constraint is specified between two relations.
The conditions for a foreign key, given below, specify a referential
integrity constraint between the two relation schemas R1 and R2.
A set of attributes FK in relation schema R1 is a foreign key of R1 that
references relation R2 if it satisfies the following rules:
1. The attributes in FK have the same domain(s) as the primary key
attributes PK of R2; the attributes FK are said to reference or refer to
the relation R2.
2. A value of FK in a tuple t1 of the current state r1(R1) either occurs
as a value of PK for some tuple t2 in the current state r2(R2) or is
NULL. In the former case, we have t1[FK] = t2[PK], and we say that
the tuple t1 references or refers to the tuple t2.
In this definition, R1 is called the referencing relation and R2 is the
referenced relation. If these two conditions hold, a referential integrity
constraint from R1 to R2 is said to hold.
Figure 5.7 shows the schema in Figure 5.5 with the referential
integrity constraints.
Relationship Types, Sets, and Instances
A relationship type R among n entity types E1, E2, . . . ,En defines a set
of associations—or a relationship set—among entities from these entity
types.
It can be defined as a subset of the Cartesian product of the entity sets E1
× E2 × . . . × En. Each of the entity types E1, E2, . . . ,En is said to
participate in the relationship type R.
Figure 3.9 illustrates this example, where each relationship instance ri is
shown connected to the EMPLOYEE and DEPARTMENT entities that
participate in ri.
Degree of a Relationship Type
The degree of a relationship type is the number of participating entity
types. Hence, the WORKS_FOR relationship is of degree two. A
relationship type of degree two is called binary, and one of degree three is
called ternary.
An example of a ternary relationship is SUPPLY, shown in Figure 3.10
Cardinality Ratios for Binary Relationships
The cardinality ratio for a binary relationship specifies the maximum
number of relationship instances that an entity can participate in. For
example, in the WORKS_FOR binary relationship type,
DEPARTMENT:EMPLOYEE is of cardinality ratio 1:N.
The possible cardinality ratios for binary relationship types are 1:1, 1:N,
N:1, and M:N.
SQL Basics
INSERT Command
INSERT is used to add a single tuple (row) to a relation (table).
A second form of the INSERT statement allows the user to specify
explicit attribute names that correspond to the values provided in the
INSERT command.
A variation of the INSERT command inserts multiple tuples into a
relation in conjunction with creating the relation and loading it with the
result of a query.
The DELETE Command
The DELETE command removes tuples from a relation.
Tuples are explicitly deleted from only one table at a time. However, the
deletion may propagate to tuples in other relations if referential triggered
actions are specified in the referential integrity constraints of the DDL.
The UPDATE Command
The UPDATE command is used to modify attribute values of one or more
selected tuples.
The SELECT-FROM-WHERE Structure of Basic SQL Queries
In SQL, the basic logical comparison operators for comparing attribute
values with one another and with literal constants are =, <=, >, >=, and
<>.
Figure 6.3(a) shows the result of query Q0 on the database of Figure 5.6.
The result of query Q1 is shown in Figure 6.3(b).
The result of query Q2 is shown in Figure 6.3(c).
It is also possible to rename the relation attributes within the query in
SQL by giving them aliases.
For example
Unspecified WHERE Clause and Use of the Asterisk
Tables as Sets in SQL
SQL usually treats a table not as a set but rather as a multiset; duplicate
tuples can appear more than once in a table, and in the result of a query.
Substring Pattern Matching and Arithmetic Operators
% replaces an arbitrary number of zero or more characters, and the
underscore (_) replaces a single character
Another feature allows the use of arithmetic in queries. The standard
arithmetic operators for addition (+), subtraction (−), multiplication (*),
and division (/) can be applied to numeric values
For string data types, the concatenate operator || can be used in a query to
append two string values.
Ordering of Query Results
The default order is in ascending order of values. We can specify the
keyword DESC if we want to see the result in a descending order of
values. The keyword ASC can be used to specify ascending order
explicitly.
Nested Queries
Query 4. Make a list of all project numbers for projects that involve an
employee whose last name is ‘Smith’, either as a worker or as a manager of the
department that controls the project.
The = ANY (or = SOME) operator returns TRUE if the value v is equal to some
value in the set V and is hence equivalent to IN. The two keywords ANY and
SOME have the same effect. Other operators that can be combined with ANY
(or SOME) include >, >=, <=, and <>. The keyword ALL can also be combined
with each of these operators. For example, the comparison condition (v > ALL
V) returns TRUE if the value v is greater than all the values in the set (or
multiset) V. An example is the following query, which returns the names of
employees whose salary is greater than the salary of all the employees in
department 5:
Correlated Nested Queries
Whenever a condition in the WHERE clause of a nested query references some
attribute of a relation declared in the outer query, the two queries are said to be
correlated.
Importance of RDBMS in Data Management for Data Science
Relational Database Management Systems (RDBMS) play a crucial role in modern data
science workflows because they provide a structured, reliable, and scalable way to store,
manage, and retrieve data.
1. Structured Data Storage
RDBMS organizes data into tables with rows and columns.
This structure:
Ensures data is consistent
Makes data easy to query
Allows efficient management of large datasets
Most enterprise data comes from RDBMS systems such as MySQL, PostgreSQL, SQL
Server, or Oracle.
2. Powerful Querying Using SQL
SQL (Structured Query Language) is the standard language for interacting with relational
databases.
Data scientists rely on SQL to:
Filter data
Join tables
Aggregate and summarize data
Clean and transform datasets
SQL is one of the most essential skills for data scientists.
3. Data Integrity and Accuracy
RDBMS ensures high-quality data through:
Constraints (PRIMARY KEY, UNIQUE, NOT NULL)
Relationships (FOREIGN KEYS)
Transaction management (ACID properties)
This prevents duplicate, inconsistent, or incomplete data—critical for building reliable
machine-learning models.
4. Scalability and Performance
RDBMS can efficiently handle:
Millions of records
Complex joins
Parallel processing
This allows data science teams to analyze large datasets without performance issues.
5. Security and Access Control
RDBMS systems provide:
User authentication
Role-based access
Encryption
Auditing
This protects sensitive business data, which is essential in data science applications like
finance, healthcare, and government analytics.
6. Integration with Data Science Tools
RDBMS connects easily with:
Python libraries (Pandas, SQLAlchemy)
R packages
BI tools (Power BI, Tableau)
Big data systems
This seamless integration supports end-to-end data pipelines.
7. Foundation for Data Warehousing
Many data warehouses and ETL processes are built on top of relational databases.
Data scientists rely on these systems for:
Clean historical data
Centralized storage
Reliable reporting and analytics
8. Supports Data Preprocessing
RDBMS helps with major preprocessing tasks such as:
Handling missing values
Merging datasets
Filtering large datasets
Standardizing formats
Clean data is the backbone of successful data science projects.