{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Hints on Submitting Offline Kernel to a Kaggle Competition","metadata":{}},{"cell_type":"markdown","source":"### Why do they require to submit an offline notebook?\n- Public test datasets may be processed and labeled manually, so public test data is susceptible to cheating.\n- Competition may offer a private testing dataset hidden from the public and participants. That is why you may receive two scores - public and private. Sometimes, yet another testing dataset can be used by the competition organizers to build the final score and define winners.\n- Competition rules typically require disabling Internet access in the submission notebook to protect private testing data from leakage to the participants. However, the offline operation creates difficulties for the package and model installation. This is unfortunate because struggling around the offline environment consumes time and patience and does not contribute to science.\n- Submitted notebook will be executed two or more times using different testing datasets. Private testing datasets may be more extensive. Typically, people submit only inference notebooks to avoid repetitive training and failing the time limit.","metadata":{}},{"cell_type":"markdown","source":"### Typical problems I have encountered:\n- Internet access must be turned off, so all packages must be installed offline. How?\n- It is necessary to reload newly installed packages after installation. How?\n- Submit notebook: Notebook Threw Exception. What to do?","metadata":{}},{"cell_type":"markdown","source":"### How to reload newly installed packages?\n- Do not use IPython.Application.instance().kernel.do_shutdown(True) - it works in the Interactive mode only.\n- This should be the first cell in the notebook:","metadata":{}},{"cell_type":"code","source":"%load_ext autoreload\n%autoreload 2\n# these 2 lines above are very important\n# they enabled automatic reloading of the newly installed packages","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### How to instal packages offline?\n[under construction] see hints below","metadata":{}},{"cell_type":"markdown","source":"Extra resources:\n- Guide on Submitting Offline Kernels to a Kaggle Competition: https://towardsdatascience.com/submitting-model-predictions-to-kaggle-competition-ccb64b17132e\n- Easy Kaggle Offline Submission With Chaining Kernel Notebooks: https://towardsdatascience.com/easy-kaggle-offline-submission-with-chaining-kernels-30bba5ea5c4d","metadata":{}},{"cell_type":"markdown","source":"### Before clicking on Submit button\n- Turn off the Internet in Kernel Settings (right pane)\n- Use Save and Run All (Commit) from the Save Version pop-up menu. Ensure the notebook runs in a non-interactive mode without errors and exceptions and produces a good submission.csv output file.\n- Check the file name of the submission.csv - is it the same as required by the competition rules?\n- Check the submission file content by comparing it to the sample_submission file. Are all columns and column names the same? Is the amount of rows the same or as required?","metadata":{}},{"cell_type":"markdown","source":"### Submit notebook: Notebook Threw Exception. What to do?\n- There is no error code or hint. Official guidance starts with the words: 'Take a deep breath. Seriously, look at the guide: https://www.kaggle.com/code-competition-debugging\n- It may be a good idea to start working on the competition not from the model design and training but by submitting a dummy output file. Create a new submission notebook, install some offline environment, read a sample submission file, and copy it to the output. The objective here is to succeed with the submission without exceptions.","metadata":{}},{"cell_type":"markdown","source":"### Have a nice day!","metadata":{}},{"cell_type":"markdown","source":"## Please upvote, thanks!","metadata":{}}]}