0% found this document useful (0 votes)
14 views

Shul Code

Uploaded by

Vedant Gade
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Shul Code

Uploaded by

Vedant Gade
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#Real estate prices prediction

#import necessary libraries


library(ggplot2)
#Load CSV data
raw_data <- read.csv("C:\\Users\\Bobby\\Downloads\\data.csv")
data <- head(raw_data, 1000)
#printing columns
colnames(data)
#Summary of data
summary(data)
str(data)
#plotting using ggplot2
ggplot(data, mapping = aes(x = yr_built, y = price, grouping(sqft_living), color =
price)) + geom_bar(inherit.aes = TRUE) + labs(title = "Comparison of year vs price:
")
ggplot(data, mapping = aes(x = yr_built, y = price, grouping(sqft_living), color =
price)) + geom_bar() + labs(title = "Comparison of year vs price: ")
ggplot(data, mapping = aes(x = yr_built, y = price, color = price)) +
geom_bar(stat = "identity") + labs(title = "Comparison of year vs price: ")
linear_model <- lm(price ~ yr_built + bedrooms + sqft_lot)
linear_model <- lm(price ~ yr_built + bedrooms + sqft_lot, data = data)
linear_model
#Summary of linear regression model
summary(linear_model)
predictions <- predict(linear_model, newdata = data.frame(yr_built =
c(head(data$yr_built, -50)), bedrooms = c(head(data$bedrooms, -50)), sqft_lot =
c(head(data$sqft_lot, -50))))
plot(data$yr_built, data$price, xlab = "Year Built", ylab = "Price", main =
"Scatter Plot of Year Built vs. Price")abline(linear_model, col = "red")
plot(data$yr_built, data$price, xlab = "Year Built", ylab = "Price", main =
"Scatter Plot of Year Built vs. Price")abline(linear_model, col = "red")
plot(data$yr_built, data$price, xlab = "Year Built", ylab = "Price", main =
"Scatter Plot of Year Built vs. Price")
abline(linear_model, col = "red")
library(scatterplot3d)
install.packages('scatterplot3d')
library(scatterplot3d)
scatterplot3d(data$yr_built, data$bedrooms, data$price, color = "red", main = "3D
Scatter Plot")
install.packages('rgl')
library(rgl)
plot3d(data$yr_built, data$bedrooms, data$sqft_lot, data$price, col = "red", type =
"s", size = 0.5, xlab = "Year Built", ylab = "Bedrooms", zlab = "Sqft Lot", main =
"Contour Plot")
library(rgl)
plot3d(data$yr_built, data$bedrooms, data$sqft_lot, data$price, col = "red", type =
"s", size = 0.5, xlab = "Year Built", ylab = "Bedrooms", zlab = "Sqft Lot", main =
"Contour Plot")
plot3d(data$yr_built, data$bedrooms, data$sqft_lot, data$price, col = "red", type =
"s", size = 0.5, xlab = "Year Built", ylab = "Bedrooms", zlab = "Sqft Lot", main =
"Contour Plot")
plot(linear_model, which = 1) # Residuals vs. Fitted

You might also like