Skip to content

Instantly share code, notes, and snippets.

@Harshit1694
Created June 29, 2019 06:17
Show Gist options
  • Save Harshit1694/68c94fcb60cbd75c96995d3095cb42b1 to your computer and use it in GitHub Desktop.
Save Harshit1694/68c94fcb60cbd75c96995d3095cb42b1 to your computer and use it in GitHub Desktop.
X<-train[c(2,6,8)]
names((X))
X$Item_Weight[is.na(X$Item_Weight)] <- mean(X$Item_Weight, na.rm = TRUE)
Y<-train[c(12)]
names((Y))
set.seed(567)
part <- sample(2, nrow(X), replace = TRUE, prob = c(0.7, 0.3))
X_train<- X[part == 1,]
X_cv<- X[part == 2,]
Y_train<- Y[part == 1,]
Y_cv<- Y[part == 2,]
train_2<-data.frame(Y_train,X_train)
model1<-lm(Y_train~Item_Weight+Item_MRP+Outlet_Establishment_Year,data =train_2 )
summary(model1)
predict_1<-predict(model1,X_cv)
m<-mean((Y_cv - predict_1)^2)
m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment