{"cells":[{"metadata":{"_uuid":"7984772e88543ec8ad6832d6ee9e56015de6f169"},"cell_type":"markdown","source":"Although Google Analytics Customer Revenue Prediction competition got much trouble, the two staged evaluation of this competition has succeeded to prevent LB probing.\nThis kernel shows how easy to probe the leaderboard of this competition.\nI make a prediction from only one feature, trunched `'visitNumber'`.\nAfter adjusting parameters by probing, it scores PS 0.88370, which is better than the 9th score of the final standing."},{"metadata":{"trusted":true,"_uuid":"192fb3600a0d2f229dabe47f16e90d8387d044ed"},"cell_type":"code","source":"# tuned parameters\nMEAN  <- 0.1\nthres_visit  <- 30","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"874892d37551609f8e3fa9fdec5b915e033a7aad","_execution_state":"idle","trusted":true,"_kg_hide-input":true,"_kg_hide-output":true},"cell_type":"code","source":"## Importing packages\n\n# This R environment comes with all of CRAN and many other helpful packages preinstalled.\n# You can see which packages are installed by checking out the kaggle/rstats docker image: \n# https://github.com/kaggle/docker-rstats\n\nlibrary(tidyverse) # metapackage with lots of helpful functions\n\n## Running code\n\n# In a notebook, you can run a single code cell by clicking in the cell and then hitting \n# the blue arrow to the left, or by clicking in the cell and pressing Shift+Enter. In a script, \n# you can run code by highlighting the code you want to run and then clicking the blue arrow\n# at the bottom of this window.\n\n## Reading in files\n\n# You can access files from datasets you've added to this kernel in the \"../input/\" directory.\n# You can see the files added to this kernel by running the code below. \n\nlist.files(path = \"../input\")\n\n## Saving data\n\n# If you save any files or images, these will be put in the \"output\" directory. You \n# can see the output directory by committing and running your kernel (using the \n# Commit & Run button) and then checking out the compiled version of your kernel.","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5636445d4a91571c2aca57db075faf21b2581afe"},"cell_type":"code","source":"test <- read_csv(\"../input/test_v2.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"636315423a98c77d54224a2763dded5b10b38c7c"},"cell_type":"code","source":"sub_pred <- test$visitNumber %>% ifelse(.>thres_visit, thres_visit, .)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2e29c91821be3bccce7c3cf9c4843cea6ace2781"},"cell_type":"code","source":"sub_pred_adj <- sub_pred/mean(sub_pred) *MEAN","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0f6912e4bb69e15233e22570e7fa536999f4f735"},"cell_type":"code","source":"sub_pred_adj %>% summary %>% print","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"24dbbc216b5bc917299e908375ba69f0803ae467"},"cell_type":"code","source":"test2 <- test %>% \nselect(fullVisitorId) %>% \nmutate(PredictedLogRevenue = sub_pred_adj)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7b3bf91d999d099f13c3c632452c494f83a77d1a"},"cell_type":"code","source":"test3 <- test2 %>% group_by(fullVisitorId) %>% \nsummarise_all(first) %>% \nungroup ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5e82b7446c66ae2ce0dbf3afb6cb86f058729d03"},"cell_type":"code","source":"test3 %>% head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"ea90992c1fa9330b1499fe2810ea1b5516ef8b55"},"cell_type":"code","source":"write_csv(test3, \"submission.csv\")","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}