{"cells":[{"metadata":{"_uuid":"3c1a23d7dc213e5ffef5dc1b8c7087c433ecc654","_cell_guid":"877c21f5-e1be-4983-9a33-54ac37c835b7"},"cell_type":"markdown","source":"## Introduction\n\n> TalkingData, China’s largest independent big data service platform, covers over 70% of active mobile devices nationwide. \n>  They handle 3 billion clicks per day, of which 90% are potentially fraudulent. Their current approach to prevent click fraud for app \n> developers is to measure the journey of a user’s click across their portfolio, and flag IP addresses who produce lots of clicks, but never\n> end up installing apps. With this information, they've built an IP blacklist and device blacklist.\n\n## Libraries"},{"metadata":{"_uuid":"b3714a6d1e34076208332082ddc384e27241b730","trusted":false,"_cell_guid":"4d06ae20-1b43-4dc1-8690-97b69b49036d"},"cell_type":"code","source":"# Data manipulation\nsuppressMessages(library(data.table))\nsuppressMessages(library(dplyr))\n\n# graphics capabilities\nsuppressMessages(library(gridExtra))\nsuppressMessages(library(grid))\nsuppressMessages(library(ggplot2))\n\n# h2o modeling kit\nsuppressMessages(library(h2o))\n\n# AuC Evaluation\nsuppressMessages(library(pROC))\n\n# work with dates\nsuppressMessages(library(lubridate))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"3eb8bc5949033e9656e57db8973c95df3c5ad600","_cell_guid":"57458b2f-418c-447b-b0ff-eb26d72e2b63"},"cell_type":"markdown","source":"## Loading data\nFirst Load data"},{"metadata":{"_uuid":"12560e6473c0c1fba3299a9c6e1eed4e720f6bf9","trusted":false,"_cell_guid":"adbc8451-7a6b-4f11-bedb-203884c61d9c"},"cell_type":"code","source":"rm(list=ls())","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"437c1ab60d2149f46d1bcb7f99c501342b4b0728","trusted":false,"_cell_guid":"c7151001-45e7-4a70-a956-77b9a6b05016"},"cell_type":"code","source":"# load train.csv\ntrain <- fread(\"../input/train.csv\", showProgress=F)\nset.seed(7)\nDstTrain <- train[sample(.N, 2000000), -7]\nrm(\"train\")","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ec2bc42c01a674390e1c76137d99bcd91f6e5677","_cell_guid":"0ad53426-1eaf-448f-b8d8-e43647eea305"},"cell_type":"markdown","source":"**Check a sample of rows**"},{"metadata":{"_uuid":"8cfd1056cbe0e606e367af9e6449df2671dc844d","trusted":false,"_cell_guid":"da7d195d-cf99-4746-baf6-2cc8bd23b746"},"cell_type":"code","source":"head(DstTrain)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"3d2590ec3008a9d4f9795b5f97a5a5002ea75322","trusted":false,"_cell_guid":"066b06c6-666a-43e0-9615-790d5f4bbe68"},"cell_type":"code","source":"table(DstTrain$is_attributed)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"25dd01f57b90b77a0c3168b6de2267311f0ca7dc","_cell_guid":"defc0d93-45b9-4df5-b195-c592c6363624"},"cell_type":"markdown","source":"**Check for unique values per colum**"},{"metadata":{"_uuid":"8794314a1fdb0243ed30da2ee53ddaa06ec4b35d","trusted":false,"_cell_guid":"57f9e914-4d13-45a5-9599-a29b18dd63d5"},"cell_type":"code","source":"# Unique values per column\napply(DstTrain,2,function(x) length(unique(x)))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"0c4d4aa64ba65c4abba54c5dffd6560444727b69","trusted":false,"_cell_guid":"abbb8067-de23-4a48-b735-2fa869640420"},"cell_type":"code","source":"# The missing data percentage by variable (exclude target variable)\nsapply(DstTrain, function(x) round((sum(is.na(x))/length(x)*100),4))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"afcd5cbaac41af825805421f2acf48ed75ae8112","_cell_guid":"5f3d9f34-981a-4d3f-a710-b13656e7a13f"},"cell_type":"markdown","source":"**Create Hour and Day**"},{"metadata":{"_uuid":"2a33b3f32e8aeaf02490c5817eb192ec4561270d","trusted":false,"_cell_guid":"fad3d517-afb4-4a2c-bd4c-69c94b1c6a34"},"cell_type":"code","source":"DstTrain$Hour <- hour(ymd_hms(DstTrain$click_time))\nDstTrain$Day <- day(ymd_hms(DstTrain$click_time))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ee3af2a33311c042222a72f798efc2743acb17b5","trusted":false,"_cell_guid":"1b226d77-637f-4e78-b8d5-eb8f77d16a95"},"cell_type":"code","source":"HourTable <- table(DstTrain$Hour)\nbarplot(HourTable,col=heat.colors(15), space=0.1, cex.axis=0.8, las=1)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"354c910d0057482edab7afe1c39e8ea8471ba43b","trusted":false,"_cell_guid":"637fad9e-03b7-41fb-a501-e41cab20707b"},"cell_type":"code","source":"# create type of period feacture\nFreqHour <- c(\"4\",\"5\",\"10\",\"13\",\"14\")\nNotFreqHour <- c(\"19\",\"20\",\"21\")\n# the period type formula\nDstTrain$PeriodType <- ifelse(DstTrain$Hour %in% FreqHour,1, \n                            ifelse(DstTrain$Hour %in% NotFreqHour, 3, 2))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"6ccd65751e39b5b9e021f73ca901497d6826a122","_cell_guid":"b6ea8da3-b7fb-4ded-86cb-7545ba596fbf"},"cell_type":"markdown","source":"**Exploratory Data Analysis (EDA)**"},{"metadata":{"_uuid":"cfdbe5c856c18eb33c8d691065cbb3b50234c036","trusted":false,"_cell_guid":"bc287e4e-5954-44d9-b3a5-7e8335be291f"},"cell_type":"code","source":"# my plots will be very similar lets simplify using a function for it\ncreateplot <- function(dst, column, name) {\n    plt <- ggplot(dst, aes(x=column, fill = factor(is_attributed))) + \n        ggtitle(name) + \n        xlab(name) +\n        ylab(\"Percentage\")  +\n        geom_bar(aes(y = 100*(..count..)/sum(..count..)), width = 0.7) + \n        theme_minimal() +\n        theme(axis.text.x = element_text(angle = 45, hjust = 1)) +\n        scale_fill_manual(values=c(\"#D0D0D0\",\"#228B22\"))\n    return(plt)\n}","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"bfaffbe9a8209b143a3eb583d14b8834761fcb02","trusted":false,"_cell_guid":"46d7fd1a-ebdd-42ab-9adc-a499d4961d52"},"cell_type":"code","source":"createplot(DstTrain, DstTrain$Day, \"Attributed by Day\") ","execution_count":null,"outputs":[]},{"metadata":{"scrolled":true,"_uuid":"49529070586300b10954c8f60d6f74aec9421cd1","trusted":false,"_cell_guid":"2d36d16c-1a50-42f3-9396-b37e3769aa20"},"cell_type":"code","source":"createplot(DstTrain, DstTrain$Hour, \"Attributed by Hour\") ","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"de26b56bb7a0586f028d40e9097261248163c340","trusted":false,"_cell_guid":"24882a37-4a2b-45cb-976f-791c2111059f"},"cell_type":"code","source":"# top 10 by apps\ntopApps <- data.frame(table(DstTrain$is_attributed, DstTrain$app))\ntopApps <- topApps[topApps$Var1==1,2:3]\ntopApps <- topApps[with(topApps, order(-Freq)), ]\n\n# draw the plot\nggplot(data=topApps[1:10,], aes(x=Var2, y=Freq)) +\n  geom_bar(stat=\"identity\", fill=\"#D0D0D0\")+\n  xlab(\"App\") +\n  ylab(\"Frequency\") +\n  geom_text(aes(label=Freq), vjust=1.6, color=\"#228B22\", size=3.5)+\n  theme_minimal()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"da56e42bb10512f68bafc657f7cdee275a8e81ba","trusted":false,"_cell_guid":"73913cbe-e707-4c5a-96c1-5fbcafb2eded"},"cell_type":"code","source":"# top 10 by device\ntopDevice <- data.frame(table(DstTrain$is_attributed, DstTrain$device))\ntopDevice <- topDevice[topDevice$Var1==1,2:3]\ntopDevice <- topDevice[with(topDevice, order(-Freq)), ]\n\n# draw the plot\nggplot(data=topDevice[1:10,], aes(x=Var2, y=Freq)) +\n  geom_bar(stat=\"identity\", fill=\"#D0D0D0\")+\n  xlab(\"Device\") +\n  ylab(\"Frequency\") +\n  geom_text(aes(label=Freq), vjust=1.6, color=\"#228B22\", size=3.5)+\n  theme_minimal()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"2e9ff3af84627c0497a0d65b7ca9ca47cb082628","trusted":false,"_cell_guid":"fbc95dd5-fcde-4026-874f-0fb433865dcc"},"cell_type":"code","source":"# top 10 OS\ntopOs <- data.frame(table(DstTrain$is_attributed, DstTrain$os))\ntopOs <- topOs[topOs$Var1==1,2:3]\ntopOs <- topOs[with(topOs, order(-Freq)), ]\n\n# draw the plot\nggplot(data=topOs[1:10,], aes(x=Var2, y=Freq)) +\n  geom_bar(stat=\"identity\", fill=\"#D0D0D0\")+\n  xlab(\"OS\") +\n  ylab(\"Frequency\") +\n  geom_text(aes(label=Freq), vjust=1.6, color=\"#228B22\", size=3.5)+\n  theme_minimal()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"8e3af21a6145a86f1354a41250f432e3c9e7be1f","trusted":false,"_cell_guid":"ea556819-439c-4754-a4e4-4fbc6ebc70ed"},"cell_type":"code","source":"# top 10 channel\ntopChannel <- data.frame(table(DstTrain$is_attributed, DstTrain$channel))\ntopChannel <- topChannel[topChannel$Var1==1,2:3]\ntopChannel <- topChannel[with(topChannel, order(-Freq)), ]\n\n# draw the plot\nggplot(data=topChannel[1:10,], aes(x=Var2, y=Freq)) +\n  geom_bar(stat=\"identity\", fill=\"#D0D0D0\")+\n  xlab(\"Channel\") +\n  ylab(\"Frequency\") +\n  geom_text(aes(label=Freq), vjust=1.6, color=\"#228B22\", size=3.5)+\n  theme_minimal()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"933398ad7ed29f4bc18c26a1d8807936e10794e0","_cell_guid":"e0209560-c80a-4d46-9a39-600450ee68de"},"cell_type":"markdown","source":"## Modeling\n\nStart up a 1-node H2O server on your local machine, and allow it to use all CPU cores and up to 1GB of memory:"},{"metadata":{"_uuid":"beef662a58ebbc8df932067cef5667defb200460","trusted":false,"_cell_guid":"1e97e7bc-a348-4ce8-b080-aef8efb82129"},"cell_type":"code","source":"h2o.init(nthreads=-1, max_mem_size=\"6G\")\nh2o.removeAll()    # clean slate - just in case the cluster was already running\nh2o.no_progress()  # Don't show progress bars in RMarkdown output","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"24e4bfa6de207e121f47719cb773c3dfa397168a","trusted":false,"_cell_guid":"2a5ef09d-addf-4aff-be43-375582bf2f2a"},"cell_type":"code","source":"dropVars <- c(\"ip\",\"click_time\")\n\n# vars to drop\nToDrop <- -which(names(DstTrain) %in% dropVars)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"0d617d6248fbbad57d852f58276a69874cbd980e","trusted":false,"_cell_guid":"fe563fee-94ba-4ccf-84a2-5325f6e8e1fa"},"cell_type":"code","source":"DstTrainTest <- DstTrain[,..ToDrop]\n\n# as factor\nDstTrainTest$is_attributed <- as.factor(DstTrainTest$is_attributed)\nlevels(DstTrainTest$is_attributed) = make.names(unique(DstTrainTest$is_attributed))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"267978761e851f3a83094db625ec8f272d57a7f8","trusted":false,"_cell_guid":"fdd39979-14e0-43bd-8e83-d9d25ec6df3a"},"cell_type":"code","source":"# convert to h2o frame \nh2o_TrainAux = as.h2o(DstTrainTest)\n\n# define the splits\nh2o_splits <- h2o.splitFrame(h2o_TrainAux, 0.8, seed=1234)\nh2o_DstTrain  <- h2o.assign(h2o_splits[[1]], \"train.hex\") # 80%\nh2o_DstTest  <- h2o.assign(h2o_splits[[2]], \"test.hex\") # 20%","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"2ed8dc02e0758966a0517c7745e243b8a2c4e71d","trusted":false,"_cell_guid":"2ca15cc9-660c-43dc-b110-4f74b08c6cf5"},"cell_type":"code","source":"# Identify predictors and response\nresponse <- \"is_attributed\"\npredictors <- setdiff(names(h2o_DstTrain), response)\n\n# Number of CV folds (to generate level-one data for stacking)\ncvfolds <- 5","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"8f2717b075959f7d84dff0566d65d29372d9281c","trusted":false,"_cell_guid":"07eb3296-0eb3-4c71-88a0-7f6f385c02d8"},"cell_type":"code","source":"get_auc <- function(mm) h2o.auc(h2o.performance(h2o.getModel(mm), newdata = h2o_DstTest))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ab6e7da7bdaab19556fd10be8e4f358676c5c845","_cell_guid":"3779a63f-9f77-43de-8f62-f64e3f66f508"},"cell_type":"markdown","source":"**H2O base models**"},{"metadata":{"_uuid":"e8e8205188989ef30ba2086b86b872386fba88ce","trusted":false,"_cell_guid":"86be4e97-38d0-4dc5-a104-76680ca997ea"},"cell_type":"code","source":"# look at the frequencies of each class\nprint(h2o.table(h2o_TrainAux['is_attributed']))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"a13437aadaeb7ceb6f29f98113b26cfdfb5f18fa","trusted":false,"_cell_guid":"b34e6b51-e0b8-4c60-a4e3-42e612c2c3a1"},"cell_type":"code","source":"# Train & Cross-validate a GBM\nmy_gbm <- h2o.gbm(x = predictors,\n                  y = response,\n                  training_frame = h2o_DstTrain,\n                  validation_frame = h2o_DstTest,\n                  distribution = \"bernoulli\",\n                  max_depth = 3,\n                  min_rows = 2,\n                  learn_rate = 0.2,\n                  nfolds = cvfolds,\n                  fold_assignment = \"Modulo\",\n                  keep_cross_validation_predictions = TRUE,\n                  balance_classes = TRUE,\n                  max_after_balance_size = 0.85,\n                  class_sampling_factors = c(0.2, 1.0),\n                  seed = 1)\n\n# print the logloss for your model\nh2o.logloss(my_gbm, valid = TRUE)\n# print model auc\nget_auc(my_gbm@model_id)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"aad647c191fbadb35d6cbc1653b2205ff28da3e1","trusted":false,"_cell_guid":"239cbe99-d935-456d-abeb-9716fbeb2fa6"},"cell_type":"code","source":"# Train & Cross-validate a RF\nmy_rf <- h2o.randomForest(x = predictors,\n                          y = response,\n                          training_frame = h2o_DstTrain,\n                          validation_frame = h2o_DstTest,\n                          nfolds = cvfolds,\n                          fold_assignment = \"Modulo\",\n                          keep_cross_validation_predictions = TRUE,\n                          balance_classes = TRUE,\n                          max_after_balance_size = 0.85,\n                          class_sampling_factors = c(0.3, 1.0),\n                          seed = 1)\n\n# print the logloss for your model\nh2o.logloss(my_rf, valid = TRUE)\n# print model auc\nget_auc(my_rf@model_id)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"3fa2a1980766057024016dfca87f6a1e83fe0489","trusted":false,"_cell_guid":"b1eebe2c-1b49-4729-9224-73100ae1d5ab"},"cell_type":"code","source":"# # Train & Cross-validate a DNN\n# my_dl <- h2o.deeplearning(x = predictors,\n#                           y = response,\n#                           training_frame = h2o_DstTrain,\n#                           validation_frame = h2o_DstTest,\n#                           l1 = 0.001,\n#                           l2 = 0.001,\n#                           hidden = c(200, 200, 200),\n#                           epoch = 2,\n#                           nfolds = cvfolds,\n#                           fold_assignment = \"Modulo\",\n#                           keep_cross_validation_predictions = TRUE,\n#                           seed = 1)\n\n# # print the logloss for your model\n# h2o.logloss(my_dl, valid = TRUE)\n# # print model auc\n# get_auc(my_dl@model_id)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"e42a543f997114ce21481202601ed845980a4df6","_cell_guid":"c43da56c-cab0-4b25-bc80-57fbe9b15f70"},"cell_type":"markdown","source":"**XGBoost base models**"},{"metadata":{"_uuid":"4dbff67589528e5641823d8628ae41a0c73f8f76","trusted":false,"_cell_guid":"4da8c33d-ae55-4c62-b7ff-c89eb30f7ded"},"cell_type":"code","source":"# # Train & Cross-validate a (shallow) XGB-GBM\n# my_xgb1 <- h2o.xgboost(x = predictors,\n#                        y = response,\n#                        training_frame = h2o_DstTrain,                       \n#                        distribution = \"bernoulli\",\n#                        ntrees = 50,\n#                        max_depth = 3,\n#                        min_rows = 2,\n#                        learn_rate = 0.2,\n#                        nfolds = cvfolds,\n#                        fold_assignment = \"Modulo\",\n#                        keep_cross_validation_predictions = TRUE,\n#                        seed = 1)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"847aeb78a19312e5ad8b4f7b4627242845f174cf","trusted":false,"_cell_guid":"abf38f17-4d3b-40f8-91c5-d18b30fe2548"},"cell_type":"code","source":"# Train & Cross-validate another (deeper) XGB-GBM\nmy_xgb2 <- h2o.xgboost(x = predictors,\n                       y = response,\n                       training_frame = h2o_DstTrain,\n                       distribution = \"bernoulli\",\n                       ntrees = 50,\n                       max_depth = 8,\n                       min_rows = 1,\n                       learn_rate = 0.1,\n                       sample_rate = 0.7,\n                       col_sample_rate = 0.9,\n                       nfolds = cvfolds,\n                       fold_assignment = \"Modulo\",\n                       keep_cross_validation_predictions = TRUE,\n                       seed = 1)\n\n# print model auc\nget_auc(my_xgb2@model_id)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"f85ba47a2defaed7d06227312d0202b3e31dbe4c","trusted":false,"_cell_guid":"cf25776d-0160-4ecd-89c0-2ea53f0cb32c"},"cell_type":"code","source":"# Train a stacked ensemble using the H2O and XGBoost models from above\nbase_models <- list( \n                    my_gbm@model_id, \n                    my_rf@model_id,\n#                     my_dl@model_id,  \n#                     my_xgb1@model_id, \n                    my_xgb2@model_id)\n\n\nensemble <- h2o.stackedEnsemble(x = predictors,\n                                y = response,\n                                training_frame = h2o_DstTrain,\n                                base_models = base_models)\n\n# Eval ensemble performance on a test set\nperf <- h2o.performance(ensemble, newdata = h2o_DstTest)\n\n\n# Compare to base learner performance on the test set\nbaselearner_aucs <- sapply(base_models, get_auc)\nbaselearner_best_auc_test <- max(baselearner_aucs)\nensemble_auc_test <- h2o.auc(perf)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"9bd0e950952c6986b83b5f0eb01b6df2b8c6821f","_cell_guid":"5529877b-0a10-4bc5-af17-237b566412c7"},"cell_type":"markdown","source":"Compare the test set performance of the best base model to the ensemble."},{"metadata":{"_uuid":"aff71069d6ea2429d9175f2ed1203b0fff468d20","trusted":false,"_cell_guid":"a486f579-657a-4aa9-a0d4-061daf6542bd"},"cell_type":"code","source":"print(sprintf(\"Best Base-learner Test AUC:  %s\", baselearner_best_auc_test))\nprint(sprintf(\"Ensemble Test AUC:  %s\", ensemble_auc_test))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"634359a7ad49b2128db65d83d31910b81fdd8d9b","_cell_guid":"0600352f-22cc-4156-ae0d-073f034884f5"},"cell_type":"markdown","source":"## Final submition"},{"metadata":{"_uuid":"2905457ce712d474838199da5aa7d5ca405a02b3","trusted":false,"_cell_guid":"42ab006e-b627-478e-878a-858b490bac0a"},"cell_type":"code","source":"# load test.csv\nDstTest  <- read.csv('../input/test.csv', stringsAsFactors = FALSE, na.strings = c(\"NA\", \"\"))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"e53040d99b0b433b634726f2f3653e69b41b8478","trusted":false,"_cell_guid":"ddc71a6f-45db-4cb6-9119-83b50334826f"},"cell_type":"code","source":"DstTest$Hour <- hour(ymd_hms(DstTest$click_time))\nDstTest$Day <- day(ymd_hms(DstTest$click_time))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d9e6f1b243194ef2c86ad8cf71b2cad0e77caac4","trusted":false,"_cell_guid":"18652b1e-8480-4998-82f3-b361125663d0"},"cell_type":"code","source":"# the period type formula\nDstTest$PeriodType <- ifelse(DstTest$Hour %in% FreqHour,1, \n                            ifelse(DstTest$Hour %in% NotFreqHour, 3, 2))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"50df7013d8902556f271d6f43d57ca6fd80cdbd6","trusted":false,"_cell_guid":"bdf1a3d6-f391-4b41-8c66-347174ea3a87"},"cell_type":"code","source":"dropVars <- c(\"ip\",\"click_time\")\n\n# vars to drop\nToDropTest <- -which(names(DstTest) %in% dropVars)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ca1cbd129ea8d9be82bfec4bab9731f617573a28","trusted":false,"_cell_guid":"27fe62ec-aeca-4fea-99b2-ead7a5009476"},"cell_type":"code","source":"# convert to h2o frame \nh2o_FinalTest = as.h2o(DstTest[,ToDropTest])\n\n# predict with the model\npredictFinal <- h2o.predict(ensemble, h2o_FinalTest)\n\n# convert H2O format into data frame and save as csv\npredictFinal.df <- as.data.frame(predictFinal)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"f5cf433386990c257572a058f7033edaa524e19f","trusted":false,"_cell_guid":"027148b4-4523-4cc2-9ae1-d93f7bc17df9"},"cell_type":"code","source":"# create a csv file for submittion\nResult <- data.frame(click_id = DstTest$click_id, is_attributed = predictFinal.df$X1)\nhead(Result,n=5L)\n# write the submition file\nwrite.csv(Result,file = \"Result.csv\",row.names = FALSE)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"89bd65fe5f51d354737d8640985319d04043aa2c","trusted":false,"_cell_guid":"fa8e9d15-685e-4585-947f-e00e9e8b1861"},"cell_type":"code","source":"# shut down virtual H2O cluster\n h2o.shutdown(prompt = FALSE)","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"R","language":"R","name":"ir"},"language_info":{"mimetype":"text/x-r-source","name":"R","pygments_lexer":"r","version":"3.4.2","file_extension":".r","codemirror_mode":"r"}},"nbformat":4,"nbformat_minor":1}