0% found this document useful (0 votes)
17 views4 pages

Experiment 1

Uploaded by

21bme145
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views4 pages

Experiment 1

Uploaded by

21bme145
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Experiment-1

roll no-
21bme145

Exercise 1
Answer the following questions by understanding the data set
1. How many rows are there in the data set? How many columns? What do the
rows and columns represent?
2. Make some pairwise scatterplot of the predictors(columns) in this data set.
Describe your findings
3. Do any of the suburbs of Boston appear to have particularly high crime
rates? Tax rates? Pupil-teacher rations? Comment on the range of each
predictor
4. What is the median pupil-teacher ratio among the towns in this data set?
5. Which suburbs of Boston has lowest median value of owner occupied
homes? what are the values of the other predictors for that suburbs, and how
do those values compare to the overall ranges for those predictors? Comment
on your findings.
6. In this data set, how many of the suburbs average more than seven rooms
per dwelling? More than eight rooms per dwelling? Comment on the suburbs
that average more than eight rooms per dwelling.

Code

library(MASS)
head(Boston)
dim(Boston)
str(Boston)
pairs(Boston)
summary(Boston$crim)
summary(Boston$tax)
summary(Boston$ptratio)
qplot(Boston$crim, binwidth=2 , xlab = "Crime rate", ylab="Number of Suburbs" )
qplot(Boston$tax, binwidth=5 , xlab = "Full-value property-tax rate per $10,000",
ylab="Number of Suburbs")
qplot(Boston$ptratio, binwidth=0.1, xlab ="Pupil-teacher ratio by town", ylab="Number of
Suburbs")
selection <- subset( Boston, crim > 10)
nrow(selection)/ nrow(Boston)
selection <- subset( Boston, crim > 50)
nrow(selection)/ nrow(Boston)
selection <- subset( Boston, tax< 600)
nrow(selection)/ nrow(Boston)
selection <- subset( Boston, tax> 600)
nrow(selection)/ nrow(Boston)
selection <- Boston[order(Boston$medv),]
selection[1,]
summary(selection)
rm_over_7 <- subset(Boston, rm>7)
nrow(rm_over_7)
rm_over_8 <- subset(Boston, rm>8)
nrow(rm_over_8)
summary(rm_over_8)

2)

3)
5)
Exercise 2

1. Remove the rows containing the mussing values


2. Using the full dataset, investigate the predictors graphically, using
scatterplot or other tools of your choice. Create some plots highlighting the
relationships among the predictors. Comment on your findings.
3. Suppose that we wish to predicr the gas milage (mpg) on the basis of the
other valrables. Do your plot suggest thatany of the other variables might be
useful in predicting mpg? Justify your answer

Code

head(Auto)
New=na.omit(Auto)
noname=New[,-9]
pairs(noname)
plot(noname$mpg,noname$cylinders, xlab="mpg", ylab="No.of cylinders")
plot(noname$mpg,noname$displacement, xlab="mpg", ylab="Displacement")
plot(noname$mpg,noname$horsepower, xlab="mpg", ylab="Horse Power")
plot(noname$mpg,noname$acceleration, xlab="mpg", ylab="Acceleration")

You might also like