Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # remove the id
- x <- data3 %>% select(-id) %>% as.matrix()
- # do the scaling
- x <- predict(preProcess(x, method = c("center","scale")), x)
- # load the model
- model <- load_model_hdf5("[path]/[model_name].h5")
- # calculate the probability of churn
- output <- data3 %>%
- mutate(prev_prob_churn=100*predict_proba(model,x)) %>%
- select(id,prev_prob_churn) %>%
- sdf_import(sc,'spark_output',overwrite=T)
- # save the outcome in a S3 bucket
- path_s3 <- 's3://[path]'
- output %>%
- sdf_coalesce(1) %>%
- spark_write_json(path=path_s3,mode='overwrite')
- # disconnect spark
- spark_disconnect(sc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement