{"cells":[{"metadata":{},"cell_type":"markdown","source":"# How to be at the top of the Leader Board without too much hassle"},{"metadata":{},"cell_type":"markdown","source":"**I will demonstrate how you can easily get 100% public score by simply downloading the true labels of the test set and simply export that...** (fully inspired on the titanic version presented in this <a href=\"https://www.kaggle.com/tarunpaparaju/how-top-lb-got-their-score-use-titanic-to-learn\">notebook</a>).\n\nCheating is not the better option if your goal is to learn ML. So get to it and start digging but don't cheat it won't get you anywhere."},{"metadata":{},"cell_type":"markdown","source":"## Imports"},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Data Processing"},{"metadata":{"_cell_guid":"","_uuid":"","trusted":true},"cell_type":"code","source":"# Private dataset\ntrue_test = pd.read_csv(\"../input/mnist-in-csv/mnist_test.csv\")\ntrue_train = pd.read_csv(\"../input/mnist-in-csv/mnist_train.csv\")\n\n# Give dataset\nsample_submission = pd.read_csv(\"../input/digit-recognizer/sample_submission.csv\")\ngiven_test = pd.read_csv(\"../input/digit-recognizer/test.csv\")\ngiven_train = pd.read_csv(\"../input/digit-recognizer/train.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"cols = given_test.columns\n\ngiven_test['dataset'] = 'test'\ngiven_train['dataset'] = 'train'","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"given_dataset = pd.concat([given_train.drop('label', axis=1), given_test]).reset_index()\ntrue_mnist = pd.concat([true_train, true_test]).reset_index(drop=True)\n\nlabels = true_mnist['label'].values\ntrue_mnist.drop('label', axis=1, inplace=True)\ntrue_mnist.columns = cols","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"true_idx = true_mnist.sort_values(by=list(true_mnist.columns)).index\ndataset_from = given_dataset.sort_values(by=list(true_mnist.columns))['dataset'].values\noriginal_idx = given_dataset.sort_values(by=list(true_mnist.columns))['index'].values","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Submission"},{"metadata":{"trusted":true},"cell_type":"code","source":"for i in range(len(true_idx)):\n    if dataset_from[i] == 'test':\n        sample_submission.loc[original_idx[i], 'Label'] = labels[true_idx[i]]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Job done...\nsample_submission","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sample_submission.to_csv('submission.csv', index=False)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"I hope you learned something and if you don't want to see stuff like this anymore don't forget to upvote..."}],"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":4,"nbformat_minor":1}