PRANVEER SINGH INSTITUTE OF TECHNOLOGY,
KANPUR
DEPARTMENT OF ARTIFICIAL INTELLIGENCE
Even Semester 2025-26
B. Tech.- Third Year
Semester - VI
Lab File
DATA ANALYTICS (BADS-651)
Submitted To: Submitted By:
Faculty Name : Mr. Varundeep Singh Name :
Designation : Assistant Professor Roll No. :
Section :
Table of Contents
● Vision and Mission Statements of the Institute
● Vision and Mission Statements of the Department
● PEOs, POs, PSOs of the Department
● Course Objective and Outcomes
● List of Experiments
● Index
● Experiments
2
Department Vision Statement
To be recognized, the Department of Artificial Intelligence produces versatile computer
engineers, capable of adapting to the changing needs of computer and AI industry.
Department Mission Statements
The mission of the Department of Artificial Intelligence is:
i. To provide broad-based education with knowledge and attitude to succeed in AI Engineering
careers.
ii. To prepare students for emerging trends in computer and AI industry.
iii. To develop competence in students by providing them with skills and aptitude to foster
culture of continuous and lifelong learning.
iv. To develop practicing engineers who investigate research, design, and find workable
solutions to complex engineering problems with awareness & concern for society as well as
the environment.
Program Educational Objectives (PEOs)
i. The graduates will be efficient leading professionals with knowledge of AI discipline that
enables them to pursue higher education and/or successful careers in various domains.
ii. Graduates will possess the capability of designing successful innovative solutions to real life
problems that are technically sound, economically viable and socially acceptable.
iii. Graduates will be competent team leaders, effective communicators and capable of working
in multidisciplinary teams following ethical values.
3
iv. The graduates will be capable of adapting to new technologies/tools and constantly
upgrading their knowledge and skills with an attitude for lifelong learning
Department Program Outcomes (POs)
The students of the AI Department will be able:
1. Engineering knowledge: Apply the knowledge of mathematics, science, AI
fundamentals, and an engineering specialization to the solution of complex
engineering problems.
2. Problem analysis: Identify, formulate, review research literature, and analyze
complex engineering problems reaching substantiated conclusions using first
principles of mathematics, natural sciences, and AI sciences.
3. Design/development of solutions: Design solutions for complex AI problems and
design system components or processes that meet the specified needs with appropriate
consideration for public health and safety, and the cultural, societal, and
environmental considerations.
4. Investigation: Use research-based knowledge and research methods including design
of experiments, analysis and interpretation of data, and synthesis of the information to
provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modelling to complex AI
activities with an understanding of the limitations.
6. Engineering and Society: Apply reasoning informed by contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice in the field of AI.
7. Environment and sustainability: Understand the impact of the professional AI
solutions in societal and environmental contexts, and demonstrate the knowledge of,
and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the AI practice.
9. Individual and team work: Function effectively as an individual, and as a member
or leader in diverse teams, and in multidisciplinary settings.
4
10. Communication: Communicate effectively on complex AI activities with the
engineering community and with society at large, such as being able to comprehend
and write effective reports and design documentation, making effective presentations,
and giving and receiving clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the
Artificial Intelligence and management principles and apply these to one’s own work,
as a member and leader in a team, to manage projects and in multidisciplinary
environments.
12. Life-long learning: Recognize the need for and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.
Department Program Specific Outcomes (PSOs)
The students will be able to:
1. Use algorithms, data structures/management, software design, concepts of
programming languages and computer organization and architecture.
2. Understand the processes that support the delivery and management of information
systems within a specific application environment.
5
CO -PO Mapping
PO PO PO PO PO PO PO PO PO PO1 PO1 PO1
CO 1 2 3 4 5 6 7 8 9 0 1 2
BADS 3 - - - - - - - - - - -
-651-1
BADS - 3 - - - - - - - - - -
-651.2
BADS - - 3 - - - - - - - - -
-651.3
BADS - - - - 3 - - - - - - -
-651.4
BADS - - - - 3 - - - - - - -
-651.5
Avg. 3.00 3.00 3.00 - 3.00 - - - - - - -
BADS -651.1 Implement numerical and statistical analysis on various data
(CO1) sources
BADS -651.2 Apply data preprocessing and dimensionality reduction methods on
(CO2) raw data.
BADS -651.3 Implement linear regression techniques on numerical data for
(CO3) prediction.
BADS -651.4 Execute clustering and association rules mining algorithms on
(CO4) different datasets
BADS -651.5 Implement and evaluate the performance of KNN algorithm on
(CO5) different datasets
BADS -651.1 with PO1: Student would substantially be able to define the basic numerical and
PO1 statistical techniques
BADS -651.2 with PO2: Student would be able to apply data preprocessing techniques on datasets
PO2
BADS -651.3 with PO3: Students would be able to analyze linear regression algorithm for numerical
PO3 data.
BADS -651.4 with PO5: Students would be able to implement clustering algorithms using modern
PO5 tools.
BADS -651.5 with PO5: Students would be able to analyze the various visualization of KNN
PO5 algorithm through modern tools.
6
List of Experiments
Sr. Date of Date of
Experiment Name Signature Remarks
No. Experiment Submission
10
7
PROGRAM-1
OBJECTIVE-To get the input from user and perform numerical operations (MAX, MIN,
AVG, SUM, SQRT, ROUND) using in R.
Program-
#Create a Vector
> data=c(23,4,56,21,34,56,73)
> #Get the maximum value
> print(max(data))
[1] 73
> #Get the minimum value
> print(min(data))
[1] 4
> #Get the SUM-
> sum(data)
[1] 267
> #Get the AVG-
> print(mean(data))
[1] 38.14286
> #Get the SQRT-
> a=5
> print(sqrt(a))
[1] 2.236068
> a=5.2
> #Get the ROUND-
> print(round(a))
[1] 5
8
Sample Output-
MAX & MIN-
SUM & AVG-
SQRT & ROUND-
9
PROGRAM-2
OBJECTIVE- To perform data import/export (.CSV, .XLS, .TXT) operations using data
frames in R.
Program-
#.CSV
> [Link]<-[Link]("C:/Users/sidsh/OneDrive/Desktop/College Work/5th-Semester/D.A.V
Lab/[Link]")
> print([Link])
#.XLS
> [Link]("readxl")
> library(readxl)
> excel_data <- read_excel("C:/Users/sidsh/Downloads/file_example_XLS_10.xls")
> print(excel_data)
#.TXT
> txt_data <- [Link]("C:/Users/sidsh/OneDrive/Desktop/R_Language.txt", header = TRUE, sep =
"\t")
> print(excel_data)
10
Sample Output-
CSV FILE-
XML FILE-
11
TXT FILE-
12
PROGRAM-3
OBJECTIVE- To get the input matrix from user and perform Matrix addition, subtraction,
multiplication, inverse transpose and division operations using vector concept in R.
Program-
#MATRIX CREATION
> {r = readline("Enter the number of rows:")}
> r = [Link](r)
> {c = readline("Enter the number of columns:")}
> c = [Link](c)
#MTRIX VALUES:
> A = scan()
> B = scan()
> M1 = matrix(A,nrow = r,ncol = c,byrow = TRUE)
> M2 = matrix(B,nrow = r,ncol = c,byrow = TRUE)
#MATRIX M1:
> print(M1)
#MATRIX M2:
> print(M2)
#[Link]-
> print(M1+M2)
#[Link]-
>print(M1-M2)
#[Link]-
>print(M1*M2)
13
Sample Output-
14
PROGRAM-4
OBJECTIVE- To perform statistical operations (Mean, Median, Mode and Standard
deviation) using R.
Program-
# DEFINING VECTOR
> a=c(23,84,16,95,23,6,41,29,6,4,6)
#[Link]-
> print(mean(a))
#[Link]-
> print(median(a))
#[Link]-
> getmode <- function(a) {
uniqv <- unique(a)
uniqv[[Link](tabulate(match(a, uniqv)))]
}
> print(getmode(a))
#[Link] DEVIATION-
> print(sd(a))
Sample Output-
15
PROGRAM-5
OBJECTIVE- To perform data pre-processing operation (1) Handle mining data (2) Min-
Max normalization
Program-
#Handle Mining Data-
x = c(NA,3,4,NA,NA,NA)
[Link](x)
x = c(NA,3 4,NA,NA,0/0,0/0)
is. nan (x)
#Min-Max Normlization-
[Link]("caret")
library(caret)
data = [Link](Var1 = c(120, 345, 145, 522, 596, 285, 21), Var2 = c(10, 15, 45, 22, 53, 28, 12),
Var3 = c(-34, 0.05, 0-15, 0-12, -6, 0·85, 0.11))
#Creating Function To Implement Min-Max Scaling-
MinMax = function (x) {(x-min(x))/(max(x)-min(x))}
#Normalize Data Using Custom Function-
Normalized_My_Data = [Link](apply(data, 1, MinMax)) head(Normalized_My_Data)
#Checking Summary After Normalization-
>summary (Normalized_My_Data)
16
Sample Output-
17
PROGRAM-6
OBJECTIVE- To perform dimensionality reduction operation using PCA for houses data set
in R.
Program-
> data("USArrests")
> rawdf <- [Link](USArrests)
> names(rawdf)=c("Murder","Assault", "Assasination”, "UrbanPop")
> head(rawdf)
> [Link] <- prcomp(scale(USArrests),center = TRUE)
#Checking output of pca. prcomp function returns standard deviation (sdev), rotation and loadings-
> names([Link])
> print([Link])
> summary([Link])
> pcaCharts([Link])
> biplot([Link],scale=0, cex=.7)
> [Link] <- [Link]
> [Link]$rotation <- -[Link]$rotation
> [Link]$x <- -[Link]$x
> biplot([Link],scale=0, cex=.7)
> [Link]$rotation[,1:2]
18
Sample Output-
19
PROGRAM-7
OBJECTIVE- To perform single linear regression with R.
Program-
#Create the predictor and response variable:
> x <- c(151, 174, 138, 186, 128, 136, 179, 163, 152, 131)
> y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48)
> relation <- lm(y~x)
#Give the chart file a name:
> png(file = "[Link]")
#Plot the chart:
> plot(y,x,col = "blue",main = "Height & Weight Regression", abline(lm(x~y)),cex = 1.3,pch =
16,xlab = "Weight in Kg",ylab = "Height in cm")
#Save the file:
> [Link]()
Sample Output-
20
PROGRAM – 8
OBJECTIVE – To perform market basket analysis / Apriori algorithm on given
data set.
Program –
library(arules)
library(arulesViz)
library(RColorBrewer)
data("Groceries")
rules <- apriori(Groceries, parameter = list(supp = 0.01, conf = 0.2))
inspect(rules[1:10])
arules::itemFrequencyPlot(Groceries, topN = 20,
col = [Link](8, 'Pastel2'),
main = 'Relative Item Frequency Plot',
type = "relative",
ylab = "Item Frequency (Relative)")
Output –
21
22
PROGRAM-9
OBJECTIVE- To perform K-means clustering operation and visualize for iris
data set.
Program-
>[Link](“stats”)
>[Link](“cluster”)
>[Link](“ClusterR”)
>library(stats)
>library(cluster)
>library(ClusterR)
> # Removing initial label of
> # Species from original dataset
> iris_1 <- iris[, -5]
> # Fitting K-Means clustering Model
> # to training dataset
> [Link](240) # Setting seed
> [Link] <- kmeans(iris_1, centers = 3, nstart = 20)
> [Link]
> # Cluster identification for
> # each observation
> [Link]$cluster
> # Confusion Matrix
> cm <- table(iris$Species, [Link]$cluster)
> cm
> # Model Evaluation and visualization
> plot(iris_1[c("[Link]", "[Link]")])
> plot(iris_1[c("[Link]", "[Link]")],
+ col = [Link]$cluster)
> plot(iris_1[c("[Link]", "[Link]")],
+ col = [Link]$cluster,
+ main = "K-means with 3 clusters")
> ## Plotiing cluster centers
23
> [Link]$centers
> [Link]$centers[, c("[Link]", "[Link]")]
> # cex is font size, pch is symbol
> points([Link]$centers[, c("[Link]", "[Link]")],
+ col = 1:3, pch = 8, cex = 3)
> ## Visualizing clusters
> y_kmeans <- [Link]$cluster
> clusplot(iris_1[, c("[Link]", "[Link]")],
+ y_kmeans,
+ lines = 0,
+ shade = TRUE,
+ color = TRUE,
+ labels = 2,
+ plotchar = FALSE,
+ span = TRUE,
+ main = paste("Cluster iris"),
+ xlab = '[Link]',
+ ylab = '[Link]')
>
24
Sample Output-
25
26
PROGRAM-10
OBJECTIVE- Write R script to diagnose any disease using KNN classification
and plot the results.
Program-
>[Link]("class")
>[Link]("ggplot2")
>library(class)
>library(ggplot2)
>features <- iris[, c("[Link]", "[Link]")]
>diagnosis <- rep(c("Healthy", "Diseased"), each = 75)
>train_indices <- sample(1:nrow(diagnosis_data), 0.7 * >nrow(diagnosis_data))
>train_data <- diagnosis_data[train_indices, ]
>test_data <- diagnosis_data[-train_indices, ]
>k <- 3
>predicted_labels <- knn(train = train_data[, 1:2], test = test_data[, 1:2], cl = train_data$Diagnosis, k
= k)
>results <- [Link](Actual = test_data$Diagnosis, Predicted = predicted_labels)
>print("Actual vs. Predicted:")
>print(results)
>ggplot(results, aes(x = Actual, fill = Predicted)) +
geom_bar(position = "dodge", color = "black", stat = "count") +
labs(title = "Disease Diagnosis Results",
x = "Actual Diagnosis",
y = "Count",
fill = "Predicted Diagnosis") +
theme_minimal()
27
Sample Output-
28
29