Data Science Project
Mosammat Sadia Sultana
Department of Genetic Engineering and Biotechnology
University of Chittagong
Project-1
##Iris dataset
iris=read.csv("iris.csv")
iris
##Identifying numerical columns
,categorical columns, target variable
a)Here, sepal.length, sepal.width, petal.length, petal.width are
numerical columns.
b)variety is the categorical column & target variable.
str(iris)
'data.frame': 150 obs. of 5 variables:
$ sepal.length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
$ sepal.width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
$ petal.length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
$ petal.width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
$ variety : chr "Setosa" "Setosa" "Setosa" "Setosa" ...
There are 150 observations of 5 different variables, a mix of numerical and categorical. As there are no other categorical variables in the dataset apart from the target variable,no variable has been removed from the dataset.
a)Scatter plot
#Scatter plot-1 (x=sepal.length,y=sepal.width)
library (ggplot2)
ggplot(iris,aes(x=sepal.length,y=sepal.width,color=variety)) + geom_point() + theme_minimal() +
labs(title="Scatter plot 1 of iris dataset")
Explanation: The scatter plot demonstrates a positive relationship between sepal length and sepal width among different iris varieties: Setosa, Versicolor, and Virginica. Setosa displays the highest sepal width, reaching approximately 4.5 units, while typically having sepal lengths below 6 units. Versicolor tends to have sepal lengths ranging from 5 to 7 units, with sepal widths generally below 3.5 units. In contrast, Virginica shows sepal lengths spanning from 5.7 to 8 units, with sepal widths typically below 3.8 units.
#Scatter plot-2 (x= petal.length,y= petal.width)
ggplot(iris,aes(x= petal.length,y= petal.width,color=variety)) + geom_point() + theme_minimal() +
labs(title="Scatter plot 2 of iris dataset")
Explanation: Virginica exhibits the greatest sepal width, reaching around 8 units, and typically displays sepal lengths ranging from 5 to 8 units. Versicolor generally showcases sepal lengths between 3 and 5 units, accompanied by sepal widths typically falling within the range of 1 to 1.5 units. On the other hand, Setosa demonstrates sepal widths typically below 1 unit, with sepal lengths generally remaining under 2 units.
#Scatter plot-3 (x=sepal.length,y=petal.width)
ggplot(iris,aes(x=sepal.length,y= petal.width,color=variety)) + geom_point() + theme_minimal() +
labs(title="Scatter plot 3 of iris dataset")
b)Box plot
#Box plot-1 (sepal.length)
ggplot(iris, aes(x=variety,y=sepal.length , fill= variety))+ geom_boxplot() +
labs(title="Box plot 1 of iris dataset")
Explanation: The box plots depict the distribution of sepal lengths for the Setosa, Versicolor, and Virginica iris varieties. For Setosa, most sepal lengths range from 4.8 to 5.3 units, with the majority falling between 4.3 and 5.8 units. The median sepal length for Setosa is around 5 units. Versicolor typically has sepal lengths ranging from 4.9 to 7 units, with a concentration between 5.6 and 6.3 units. The median sepal length for Versicolor is close to 5.8 units. For Virginica, sepal lengths span from 5.6 to nearly 8 units, with the highest occurrence between 6.2 and 6.9 units. The median sepal length for Virginica is about 6.5 units, with one outlier observed at 4.9 units.
#Box plot-2 (sepal.width)
ggplot(iris, aes(x=variety,y=sepal.width,fill= variety)) + geom_boxplot() +
labs(title="Box plot 2 of iris dataset")
Explanation:
For Setosa, the majority of sepal widths range from 2.9 to 4.2 units, with most falling between 3.3 and 3.7 units. Two outliers are visible at 2.3 and 4.4 units. The median sepal width for Setosa is around 3.4 units. Versicolor typically has sepal widths ranging from 2 to 3.3 units, with a concentration between 2.5 and 3 units. The median sepal width for Versicolor is close to 2.8 units. In the case of Virginica, sepal widths span from 2.5 to 3.6 units, with the most common values observed between 2.8 and 3.2 units. The median sepal width for Virginica is about 3 units, with outliers at 2.3 and 3.8 units.
#Box plot-3 (petal.length)
ggplot(iris, aes(x=variety,y=petal.length,fill= variety)) + geom_boxplot()+
labs(title="Box plot 3 of iris dataset")
#Box plot-4 (petal.width)
ggplot(iris, aes(x=variety,y=petal.width,fill= variety)) + geom_boxplot()+
labs(title="Box plot 4 of iris dataset")
c)Violin plot
#Violin plot-1 (sepal.length)
ggplot(iris, aes(x=variety,y=sepal.length , fill= variety)) + geom_violin()+
labs(title="Violin plot 1 of iris dataset")
Explanation: The violin plot reveals that while the maximum sepal length for Setosa is close to 6 units, the majority of the dataset exhibits sepal lengths around 5 units. Similarly, for Versicolor, although the maximum sepal length approaches 7 units, most data points cluster around 5.6 units. Lastly, while the maximum sepal length for Virginica is nearly 8 units, the majority of observations have sepal lengths near 6.4 units.
#violin plot-2 (sepal.width)
ggplot(iris, aes(x=variety,y=sepal.width , fill= variety)) + geom_violin()+
labs(title="Violin plot 2 of iris dataset")
#violin plot-3 (petal.length)
ggplot(iris, aes(x=variety,y=petal.length , fill= variety)) + geom_violin()+
labs(title="Violin plot 3 of iris dataset")
#violin plot-4 (petal.width)
ggplot(iris, aes(x=variety,y=petal.width , fill= variety)) + geom_violin()+
labs(title="Violin plot 4 of iris dataset")
Project-2
a)Interactive violin plot
library (plotly)
plot_ly(data=iris,x=~variety,y=~petal.width , fill= ~variety,type="violin")
Warning: 'violin' objects don't have these attributes: 'fill'
Valid attributes include:
'alignmentgroup', 'bandwidth', 'box', 'customdata', 'customdatasrc', 'fillcolor', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hoveron', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'jitter', 'legendgroup', 'legendgrouptitle', 'legendrank', 'line', 'marker', 'meanline', 'meta', 'metasrc', 'name', 'offsetgroup', 'opacity', 'orientation', 'pointpos', 'points', 'scalegroup', 'scalemode', 'selected', 'selectedpoints', 'showlegend', 'side', 'span', 'spanmode', 'stream', 'text', 'textsrc', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'visible', 'width', 'x', 'x0', 'xaxis', 'xhoverformat', 'xsrc', 'y', 'y0', 'yaxis', 'yhoverformat', 'ysrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
Warning: 'violin' objects don't have these attributes: 'fill'
Valid attributes include:
'alignmentgroup', 'bandwidth', 'box', 'customdata', 'customdatasrc', 'fillcolor', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hoveron', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'jitter', 'legendgroup', 'legendgrouptitle', 'legendrank', 'line', 'marker', 'meanline', 'meta', 'metasrc', 'name', 'offsetgroup', 'opacity', 'orientation', 'pointpos', 'points', 'scalegroup', 'scalemode', 'selected', 'selectedpoints', 'showlegend', 'side', 'span', 'spanmode', 'stream', 'text', 'textsrc', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'visible', 'width', 'x', 'x0', 'xaxis', 'xhoverformat', 'xsrc', 'y', 'y0', 'yaxis', 'yhoverformat', 'ysrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
plot_ly(data=iris,x=~variety,y=~sepal.width , fill= ~variety,type="violin")
Warning: 'violin' objects don't have these attributes: 'fill'
Valid attributes include:
'alignmentgroup', 'bandwidth', 'box', 'customdata', 'customdatasrc', 'fillcolor', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hoveron', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'jitter', 'legendgroup', 'legendgrouptitle', 'legendrank', 'line', 'marker', 'meanline', 'meta', 'metasrc', 'name', 'offsetgroup', 'opacity', 'orientation', 'pointpos', 'points', 'scalegroup', 'scalemode', 'selected', 'selectedpoints', 'showlegend', 'side', 'span', 'spanmode', 'stream', 'text', 'textsrc', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'visible', 'width', 'x', 'x0', 'xaxis', 'xhoverformat', 'xsrc', 'y', 'y0', 'yaxis', 'yhoverformat', 'ysrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
Warning: 'violin' objects don't have these attributes: 'fill'
Valid attributes include:
'alignmentgroup', 'bandwidth', 'box', 'customdata', 'customdatasrc', 'fillcolor', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hoveron', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'jitter', 'legendgroup', 'legendgrouptitle', 'legendrank', 'line', 'marker', 'meanline', 'meta', 'metasrc', 'name', 'offsetgroup', 'opacity', 'orientation', 'pointpos', 'points', 'scalegroup', 'scalemode', 'selected', 'selectedpoints', 'showlegend', 'side', 'span', 'spanmode', 'stream', 'text', 'textsrc', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'visible', 'width', 'x', 'x0', 'xaxis', 'xhoverformat', 'xsrc', 'y', 'y0', 'yaxis', 'yhoverformat', 'ysrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
b)Interactive boxplot
plot_ly(data=iris,x=~variety,y=~petal.width , fill= ~variety,type="box")
Warning: 'box' objects don't have these attributes: 'fill'
Valid attributes include:
'alignmentgroup', 'boxmean', 'boxpoints', 'customdata', 'customdatasrc', 'dx', 'dy', 'fillcolor', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hoveron', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'jitter', 'legendgroup', 'legendgrouptitle', 'legendrank', 'line', 'lowerfence', 'lowerfencesrc', 'marker', 'mean', 'meansrc', 'median', 'mediansrc', 'meta', 'metasrc', 'name', 'notched', 'notchspan', 'notchspansrc', 'notchwidth', 'offsetgroup', 'opacity', 'orientation', 'pointpos', 'q1', 'q1src', 'q3', 'q3src', 'quartilemethod', 'sd', 'sdsrc', 'selected', 'selectedpoints', 'showlegend', 'stream', 'text', 'textsrc', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'upperfence', 'upperfencesrc', 'visible', 'whiskerwidth', 'width', 'x', 'x0', 'xaxis', 'xcalendar', 'xhoverformat', 'xperiod', 'xperiod0', 'xperiodalignment', 'xsrc', 'y', 'y0', 'yaxis', 'ycalendar', 'yhoverformat', 'yperiod', 'yperiod0', 'yperiodalignment', 'ysrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
Warning: 'box' objects don't have these attributes: 'fill'
Valid attributes include:
'alignmentgroup', 'boxmean', 'boxpoints', 'customdata', 'customdatasrc', 'dx', 'dy', 'fillcolor', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hoveron', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'jitter', 'legendgroup', 'legendgrouptitle', 'legendrank', 'line', 'lowerfence', 'lowerfencesrc', 'marker', 'mean', 'meansrc', 'median', 'mediansrc', 'meta', 'metasrc', 'name', 'notched', 'notchspan', 'notchspansrc', 'notchwidth', 'offsetgroup', 'opacity', 'orientation', 'pointpos', 'q1', 'q1src', 'q3', 'q3src', 'quartilemethod', 'sd', 'sdsrc', 'selected', 'selectedpoints', 'showlegend', 'stream', 'text', 'textsrc', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'upperfence', 'upperfencesrc', 'visible', 'whiskerwidth', 'width', 'x', 'x0', 'xaxis', 'xcalendar', 'xhoverformat', 'xperiod', 'xperiod0', 'xperiodalignment', 'xsrc', 'y', 'y0', 'yaxis', 'ycalendar', 'yhoverformat', 'yperiod', 'yperiod0', 'yperiodalignment', 'ysrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
plot_ly(data=iris,x=~variety,y=~sepal.width , fill= ~variety,type="box")
Warning: 'box' objects don't have these attributes: 'fill'
Valid attributes include:
'alignmentgroup', 'boxmean', 'boxpoints', 'customdata', 'customdatasrc', 'dx', 'dy', 'fillcolor', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hoveron', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'jitter', 'legendgroup', 'legendgrouptitle', 'legendrank', 'line', 'lowerfence', 'lowerfencesrc', 'marker', 'mean', 'meansrc', 'median', 'mediansrc', 'meta', 'metasrc', 'name', 'notched', 'notchspan', 'notchspansrc', 'notchwidth', 'offsetgroup', 'opacity', 'orientation', 'pointpos', 'q1', 'q1src', 'q3', 'q3src', 'quartilemethod', 'sd', 'sdsrc', 'selected', 'selectedpoints', 'showlegend', 'stream', 'text', 'textsrc', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'upperfence', 'upperfencesrc', 'visible', 'whiskerwidth', 'width', 'x', 'x0', 'xaxis', 'xcalendar', 'xhoverformat', 'xperiod', 'xperiod0', 'xperiodalignment', 'xsrc', 'y', 'y0', 'yaxis', 'ycalendar', 'yhoverformat', 'yperiod', 'yperiod0', 'yperiodalignment', 'ysrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
Warning: 'box' objects don't have these attributes: 'fill'
Valid attributes include:
'alignmentgroup', 'boxmean', 'boxpoints', 'customdata', 'customdatasrc', 'dx', 'dy', 'fillcolor', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hoveron', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'jitter', 'legendgroup', 'legendgrouptitle', 'legendrank', 'line', 'lowerfence', 'lowerfencesrc', 'marker', 'mean', 'meansrc', 'median', 'mediansrc', 'meta', 'metasrc', 'name', 'notched', 'notchspan', 'notchspansrc', 'notchwidth', 'offsetgroup', 'opacity', 'orientation', 'pointpos', 'q1', 'q1src', 'q3', 'q3src', 'quartilemethod', 'sd', 'sdsrc', 'selected', 'selectedpoints', 'showlegend', 'stream', 'text', 'textsrc', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'upperfence', 'upperfencesrc', 'visible', 'whiskerwidth', 'width', 'x', 'x0', 'xaxis', 'xcalendar', 'xhoverformat', 'xperiod', 'xperiod0', 'xperiodalignment', 'xsrc', 'y', 'y0', 'yaxis', 'ycalendar', 'yhoverformat', 'yperiod', 'yperiod0', 'yperiodalignment', 'ysrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
c)Correlation matrix
cor_mat=cor(iris[1:4])
cor_mat
sepal.length sepal.width petal.length petal.width
sepal.length 1.0000000 -0.1175698 0.8717538 0.8179411
sepal.width -0.1175698 1.0000000 -0.4284401 -0.3661259
petal.length 0.8717538 -0.4284401 1.0000000 0.9628654
petal.width 0.8179411 -0.3661259 0.9628654 1.0000000
The correlation matrix indicates a notable positive correlation of 0.9628 between petal width and petal length, suggesting a strong relationship between these two variables. Additionally, there is a weaker negative correlation of -0.4284 observed between petal length and sepal width, indicating a modest inverse relationship between these variables.
d)Plot correlation matrix (lower triangle) with values
library (ggcorrplot)
ggcorrplot(cor_mat,type ="lower",
colors=c("blue", "yellow", "purple"),
lab=TRUE)
e)pair plot of all feature
library (GGally)
ggpairs(iris,aes(color=variety))
f)Principal Component Analysis (PCA)
library (stats)
iris_pca = prcomp(iris[,1:4], scale = TRUE, center = TRUE)
summary(iris_pca)
Importance of components:
PC1 PC2 PC3 PC4
Standard deviation 1.7084 0.9560 0.38309 0.14393
Proportion of Variance 0.7296 0.2285 0.03669 0.00518
Cumulative Proportion 0.7296 0.9581 0.99482 1.00000
Interpreting the proportion of variance involves assessing which components carry the most information and how much of the original data’s variability is captured. Components 1 and 2 explain around 95% proportion of the variance; it suggests that components 1 and 2 capture a certain amount of information from the original variables. Subsequent components (Components 2, 3, and 4) explain decreasing proportions of variance.
i)Bar plot of PCAs (Percentage of explained variance vs PCs)
library (factoextra)
fviz_eig(iris_pca, addlabels = TRUE)
ii)Contribution plot of PCs (Circular plot)
fviz_pca_var(iris_pca,
col.var = "contrib")
iii)Cluster plot after PCA
library(corrplot)
var = get_pca_var(iris_pca)
corrplot(var$cos2)
fviz_pca_ind(iris_pca,
geom.ind = "point",
col.ind = iris$variety,
addEllipses = TRUE)
g)Support Vector Machine (SVM)
library (caret)
library(e1071)
library ( lattice)
train_idx = createDataPartition(iris$variety, p = 0.8, list = FALSE)
train_data = iris[train_idx, ]
test_data = iris[-train_idx, ]
svm_model = svm(as.factor(variety)~sepal.length+sepal.width+petal.length+petal.width,data=train_data,kernel="linear")
pred=predict(svm_model,train_data)
pred
1 2 3 4 5 6
Setosa Setosa Setosa Setosa Setosa Setosa
7 8 9 10 12 13
Setosa Setosa Setosa Setosa Setosa Setosa
14 16 17 18 19 20
Setosa Setosa Setosa Setosa Setosa Setosa
21 22 24 27 28 29
Setosa Setosa Setosa Setosa Setosa Setosa
30 31 32 35 37 38
Setosa Setosa Setosa Setosa Setosa Setosa
39 40 41 42 43 44
Setosa Setosa Setosa Setosa Setosa Setosa
45 46 49 50 52 53
Setosa Setosa Setosa Setosa Versicolor Versicolor
54 55 56 57 58 59
Versicolor Versicolor Versicolor Versicolor Versicolor Versicolor
60 61 64 65 66 67
Versicolor Versicolor Versicolor Versicolor Versicolor Versicolor
70 71 72 73 74 75
Versicolor Versicolor Versicolor Virginica Versicolor Versicolor
76 79 80 81 82 83
Versicolor Versicolor Versicolor Versicolor Versicolor Versicolor
84 85 86 87 88 90
Virginica Versicolor Versicolor Versicolor Versicolor Versicolor
92 93 94 95 96 97
Versicolor Versicolor Versicolor Versicolor Versicolor Versicolor
99 100 101 102 103 104
Versicolor Versicolor Virginica Virginica Virginica Virginica
105 106 107 108 109 111
Virginica Virginica Virginica Virginica Virginica Virginica
112 114 116 117 119 120
Virginica Virginica Virginica Virginica Virginica Virginica
121 122 123 124 125 126
Virginica Virginica Virginica Virginica Virginica Virginica
129 130 131 133 134 136
Virginica Virginica Virginica Virginica Versicolor Virginica
137 139 140 141 142 143
Virginica Virginica Virginica Virginica Virginica Virginica
144 145 147 148 149 150
Virginica Virginica Virginica Virginica Virginica Virginica
Levels: Setosa Versicolor Virginica
test_data
ii)Plot the Confusion Matrix
predictions = predict(svm_model, newdata = test_data)
conf_mat= confusionMatrix(predictions, as.factor(test_data$variety))
conf_mat
Confusion Matrix and Statistics
Reference
Prediction Setosa Versicolor Virginica
Setosa 10 0 0
Versicolor 0 8 0
Virginica 0 2 10
Overall Statistics
Accuracy : 0.9333
95% CI : (0.7793, 0.9918)
No Information Rate : 0.3333
P-Value [Acc > NIR] : 8.747e-12
Kappa : 0.9
Mcnemar's Test P-Value : NA
Statistics by Class:
Class: Setosa Class: Versicolor Class: Virginica
Sensitivity 1.0000 0.8000 1.0000
Specificity 1.0000 1.0000 0.9000
Pos Pred Value 1.0000 1.0000 0.8333
Neg Pred Value 1.0000 0.9091 1.0000
Prevalence 0.3333 0.3333 0.3333
Detection Rate 0.3333 0.2667 0.3333
Detection Prevalence 0.3333 0.2667 0.4000
Balanced Accuracy 1.0000 0.9000 0.9500
cm = as.data.frame(conf_mat$table)
ggplot(cm, aes(Prediction, Reference, fill = Freq)) +
geom_tile() +
geom_text(aes(label = Freq)) +
scale_fill_gradient(low="lavender", high="blue")
The true negative and positive section shows that this model works accurately. Although there are some false negative results so this model should be improved for better functioning.
2)Regression dataset:“US Admission”
Let’s break the chance of admit
probabilities into 3levels.
0-0.69:weak chance of admit
0.70-0.79:moderate chance of admit
0.80-1:high chance of admit
US_Admission=read.csv("US Admission.csv")
breaks<-c(0,0.7,0.8,1)
labels<-c("weak","moderate","high")
CA<-cut(US_Admission$Chance.of.Admit,breaks=breaks,labels=labels,include.lowest=TRUE)
US_Admission=cbind(US_Admission,CA)
US_Admission
NA
a)Remove the “Serial No” column from “US Admission”
US_Admission$Serial.No.<-NULL
US_Admission
b) Pair plot
ggpairs(US_Admission, aes(colour = CA ))
c)Linear regression Regression plot for chance of admission and GRE Score
ggplot(US_Admission, aes(x = Chance.of.Admit,y=GRE.Score)) +
geom_point() +
geom_smooth(method = "lm",color="purple", level = 0.95)+
labs(title = "Regression plot for Chance of admission and GRE Score", x = "Chance of admission",
y = "GRE Score")
Regression plot for chance of admission and TOEFL Score
ggplot(US_Admission, aes(x =Chance.of.Admit,y=TOEFL.Score,color=Chance.of.Admit)) +
geom_point() +
geom_smooth(method = "lm",color="purple",level = 0.95)+
labs(title = "Regression plot for chance of admission and TOEFL Score",
x = "Chance of admission",y = "TOEFL Score")
Regression plot for Chance of admission and University Rating
library (ggplot2)
ggplot(US_Admission, aes(x = `Chance.of.Admit`,y=`University.Rating`,color=Chance.of.Admit)) +
geom_point() +
geom_smooth(method = "lm",color="purple", level = 0.95)+
labs(title = "Regression plot for Chance of admission and University Rating",
x= "Chance of admission",y = "University Rating")
Regression plot for Chance of admission and Statement of Purpose
ggplot(US_Admission, aes(x = `Chance.of.Admit`,y=SOP,color=Chance.of.Admit)) +
geom_point() +
geom_smooth(method = "lm",color="purple", level = 0.95)+
labs(title = "Regression plot for Chance of admission and Statement of Purpose", x = "Chance of admission",
y = "Statement of Purpose")
Regression plot for Chance of admission and Letter of Recommendation Strength
ggplot(US_Admission, aes(x = `Chance.of.Admit`, y=LOR,color=Chance.of.Admit)) +
geom_point() +
geom_smooth(method = "lm", color="purple",level = 0.95)+
labs(title = "Regression plot for Chance of admission and Letter of Recommendation Strength", x = "Chance of admission",
y = "Letter of Recommendation Strength")
Regression plot for Chance of admission and Undergraduate CGPA
ggplot(US_Admission, aes(x = `Chance.of.Admit`, y=CGPA,color=Chance.of.Admit)) +
geom_point() +
geom_smooth(method = "lm", color="purple",level = 0.95)+
labs(title = "Regression plot for Chance of admission and Undergraduate CGPA",
x = "Chance of admission",
y = "Undergraduate CGPA")
Regression plot for Chance of admission and Research Experience
ggplot(US_Admission, aes(x = `Chance.of.Admit`, y=Research ,color=Chance.of.Admit)) +
geom_point() +
geom_smooth(method = "lm",color="purple", level = 0.95)+
labs(title = "Regression plot for chance of admission and Research Experience", x = "Chance of admission",
y = "Research Experience")
The analysis conducted using linear regression plots showed a clear trend: all the factors examined regarding the likelihood of university admission displayed a positive relationship. This means that as these factors increase in value, the chance of university admission also tends to increase.
d) Polynomial regression Polynomial regression plot for chance of admission and GRE Score
ggplot(US_Admission, aes(x = `Chance.of.Admit`, y=`GRE.Score`,color=Chance.of.Admit)) +
geom_point() +
geom_smooth(method = "lm",color="yellow" ,formula = y~poly(x, 2), level = 0.95)+
labs(title = " Polynomial regression plot for chance of admission and GRE Score", x = "Chance of admission",
y = "GRE Score")
Polynomial regression plot for chance of admission and TOEFL.Score
ggplot(US_Admission, aes(x = `Chance.of.Admit`, y= TOEFL.Score,color=Chance.of.Admit)) +
geom_point() +
geom_smooth(method = "lm",color="yellow" , formula = y~poly(x, 2), level = 0.95)+
labs(title = " Polynomial regression plot for chance of admission and TOEFL.Score", x = "Chance of admission",
y = "TOEFL.Score")
Polynomial regression plot for chance of admission and University.Rating
ggplot(US_Admission, aes(x = `Chance.of.Admit`, y= University.Rating,color=Chance.of.Admit )) +
geom_point() +
geom_smooth(method = "lm",color="yellow" , formula = y~poly(x, 2), level = 0.95)+
labs(title = " Polynomial regression plot for chance of admission and University.Rating", x = "Chance of admission",
y = "University.Rating")
Polynomial regression plot for chance of admission and SOP
ggplot(US_Admission, aes(x = `Chance.of.Admit`, y= SOP,color=Chance.of.Admit )) +
geom_point() +
geom_smooth(method = "lm",color="yellow" , formula = y~poly(x, 2), level = 0.95)+
labs(title = " Polynomial regression plot for chance of admission and SOP", x = "Chance of admission",
y = "SOP")
Polynomial regression plot for chance of admission and LOR
ggplot(US_Admission, aes(x = `Chance.of.Admit`, y= LOR ,color=Chance.of.Admit)) +
geom_point() +
geom_smooth(method = "lm",color="yellow" , formula = y~poly(x, 2), level = 0.95)+
labs(title = " Polynomial regression plot for chance of admission and LOR", x = "Chance of admission",
y = "LOR")
Polynomial regression plot for chance of admission and CGPA
ggplot(US_Admission, aes(x = `Chance.of.Admit`, y= CGPA ,color=Chance.of.Admit )) +
geom_point() +
geom_smooth(method = "lm",color="yellow" , formula = y~poly(x, 2), level = 0.95)+
labs(title = " Polynomial regression plot for chance of admission and CGPA", x = "Chance of admission",
y = "CGPA")
Polynomial regression plot for chance of admission and Research
ggplot(US_Admission, aes(x = `Chance.of.Admit`, y= Research ,color=Chance.of.Admit)) +
geom_point() +
geom_smooth(method = "lm",color="yellow" , formula = y~poly(x, 2), level = 0.95)+
labs(title = " Polynomial regression plot for chance of admission and TResearch", x = "Chance of admission",
y = "Research")
The analysis carried out using polynomial regression plots revealed a notable trend: every factor examined regarding the probability of university admission demonstrated a positive correlation. This suggests that as the values of these factors increase, there is a tendency for the likelihood of university admission to also increase.