Need to map(create dataframe) my test prediction (test_pred) with actual data set which have Customer column

r
data_wrangling
data_science

#1

I have actual dataset (Mydata). after cleaning/model building , I have predicted my result with test data (test_matrix). Now I need to map(create dataframe) my test prediction (test_pred) with actual data set which have Customer column. Please suggest me, how to connect test_pred with Customer for production purpose.

str(Mydata)
‘data.frame’: 1686584 obs. of 39 variables:
customer : Factor w/ 843292 levels "00000D47-1756-E311-8772-0050569C51C6",..: 527360 790193 150129 140965 417954 101988 473840 278324 807556 832400 ... year : int 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 …

test_pred <- predict(bst_model, newdata = test_matrix)


#2

Hi KumarP,

Copy the customer column from your original data frame and store it in another variable like,
cust <- Mydata$customer
OR
cust <- Mydata[[COLUMN_NUMBER]]

After that, use test_pred to make a data frame along with the factor cust.

NEW_DF <- data.frame(cust,test_pred)

Hope this helps.