Read the dataset-Computer sales

dt <- read.csv(“D:\t\drive-download-20190806T055124Z-001\Computer_Data.csv”)

#view the loaded dataset

View(dt)

Count the rows and columns of the dataset

dim(dt) attach(dt)

View the summary statistics of the dataset

summary(dt)

fetch only the columns to be used (price and hd)-based on HD we are predicting the price

new_dt <- as.data.frame(dt[,c(2,4)])

View the loaded dataset

View(new_dt)

to check if the output is following Normal distribution

qqnorm(hd) plot(price,hd)

check for r square value

cor(price,hd)

model 1

model1 <- lm(price ~ hd,data=new_dt) summary(model1)

Multiple R-squared: 0.1851 for model 1

pv1 <- predict(model1,new_dt) pv1 <- as.data.frame(pv1)

final1 <- cbind(new_dt,pv1) View(final1)

model 2

model2 <- lm(price ~log(hd),data=new_dt) summary(model2)

Multiple R-squared: 0.2114 for model 2

pv2 <- predict(model2,new_dt) pv2 <- as.data.frame(pv2)

final2 <- cbind(new_dt,pv2) View(final2)

model 3

model3 <- lm(log(price) ~ hd,data=new_dt) summary(model3)

Multiple R-squared: 0.1851 for model 3

model 4

model4 <- lm(price ~ sqrt(hd),data=new_dt) summary(model4)

Multiple R-squared: 0.2041 for model4