Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.