{"cells":[{"metadata":{"_uuid":"b0ef2d37dbc3c340b5bf5952d2be612386faed69"},"cell_type":"markdown","source":"**Google Analytics Customer Revenue Prediction Contest**\n\n**-----  !!ALL ZEROS!! -----**\n\n* [http://www.kaggle.com/c/ga-customer-revenue-prediction](http://www.kaggle.com/c/ga-customer-revenue-prediction)\n\nCreated by Steve Black\n\nStarted on Oct.05.2018\n\nThis is a second try. \n\nMy first try was about exploring how to connect to data and exploring what it is. \n\nThe goal of this second Kernel-Submission is simple. I'm going to submit an answer where ALL users have zero revenue!\n\nWhy?\n* I believe the majority of users have zero revenue, thus predicting zero is acutally most accurate for most users.\n* 9,996 out of 714, 167 or 1.40% of users have revenue in the Train data set\n* This 'zero-answer' will then just test the error for this most basic case.\n* Of course, it should not win any prizes, but will be a great baseline.\n\nResults:\n* My RMS score after submitting is : 1.7804\n* This serves as a great baseline... If you don't do better than this, then your better off guessing zeros!\n\nHA! after submitting I can see many others with this exact same score... so my zeros idea is hardly unique!\nGreat thinkers, think alike?"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# ----- CREATED UPON CREATION OF KAGGLE PYTHON KERNEL -----\n# ----- KEPT AS IS -----\n# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"# Load data using BigQueryHelper:\nimport bq_helper\nprint(\"Loading Training Data Set...\")\nga_bq_train = bq_helper.BigQueryHelper(active_project= \"kaggle-public-datasets\", dataset_name = \"ga_train_set\")\nprint(\"Loading Test Data Set... \")\nga_bq_test = bq_helper.BigQueryHelper(active_project= \"kaggle-public-datasets\", dataset_name = \"ga_test_set\")\nprint(\"Data Loaded: done\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"81eafb896e0f99cb6bfe2d55f6f67f0b13671b24"},"cell_type":"code","source":"# Test query estimate\nqueryy = \\\n    \"\"\"\n    SELECT  fullVisitorId\n    FROM `kaggle-public-datasets.ga_test_set.ga_sessions_*` \n    GROUP BY fullVisitorId\n    ORDER BY fullVisitorId\n    \"\"\"\nprint(\"size = \" + str( ga_bq_test.estimate_query_size(queryy) * 1000 ) + \" MB\" )","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"08de31088c9dc2fbd0cd8494c22d7a0b50b76816"},"cell_type":"code","source":"# Test query final\nprint('starting queryy...')\ntest_as_pandas_data = ga_bq_test.query_to_pandas_safe(queryy)\nprint('done')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"77c656ce161fac636cb64451b082507eba9abe3c"},"cell_type":"code","source":"test_as_pandas_data.head(5)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"dfc410fb37197d9d1756c1e3026302567217521d"},"cell_type":"code","source":"# The predicted output needs to be the natural log of the sum + 1\n# which is all zeros as ln(1) = 0\ntest_as_pandas_data['PredictedLogRevenue'] = np.log(0+1)\ntest_as_pandas_data.head(5)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d7b3d19aa79347452b26454fbbb11ff56fba7c34"},"cell_type":"code","source":"test_as_pandas_data.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6b62389e10be6cf8a05413d048561ffa345c963e"},"cell_type":"code","source":"test_as_pandas_data.info()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"85e13c5de12cb46b8f5be7b08f88b4824679ed8a"},"cell_type":"code","source":"# Let's save it:\nprint('saving csv file...')\ntest_as_pandas_data.to_csv('submission_SteveBlack_v002_date_2018_1005_0959.csv', index = False)\nprint('done')","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}