Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. # remove the id
  2. x <- data3 %>% select(-id) %>% as.matrix()
  3.  
  4. # do the scaling
  5. x <- predict(preProcess(x, method = c("center","scale")), x)
  6.  
  7. # load the model
  8. model <- load_model_hdf5("[path]/[model_name].h5")
  9.  
  10. # calculate the probability of churn
  11. output <- data3 %>%
  12. mutate(prev_prob_churn=100*predict_proba(model,x)) %>%
  13. select(id,prev_prob_churn) %>%
  14. sdf_import(sc,'spark_output',overwrite=T)
  15.  
  16. # save the outcome in a S3 bucket
  17. path_s3 <- 's3://[path]'
  18. output %>%
  19. sdf_coalesce(1) %>%
  20. spark_write_json(path=path_s3,mode='overwrite')
  21.  
  22. # disconnect spark
  23. spark_disconnect(sc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement