{"cells":[{"metadata":{},"cell_type":"markdown","source":"Credit to origin author for MinMaxBestBaseStacking (https://github.com/QuantScientist/Deep-Learning-Boot-Camp/blob/master/Kaggle-PyTorch/PyTorch-Ensembler/utils.py)\n\n","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"1. Data from https://www.kaggle.com/truonghoang/siimisic-submission-files with max score: 0.868\n\n    I take 11 top submission files for this notebook and apply:\n>     * median           : 0.878\n>     * mean             : 0.867\n>     * minmax_mean      : 0.860\n>     * pushout_median   : 0.819\n\n2. Data from https://www.kaggle.com/truonghoang/siimisic-submission-files-cpu with max score: 0.884\n    \n    I take 10 top submission files for this notebook and apply:\n>     * median           : 0.893\n>     * mean             : 0.891\n>     * minmax_mean      : 0.888\n\n3. Data from https://www.kaggle.com/truonghoang/multi-size-eff-lb-0-912 with max score: 0.912\n\n    I take 5 submission files for this notebook and apply:\n>     * median           : 0.914","execution_count":null},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport os","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sub_path = \"../input/top-my-submission\"\nall_files = os.listdir(sub_path)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"outs = [pd.read_csv(os.path.join(sub_path, f), index_col=0) for f in all_files if '.csv' in f and '_me' in f]\nconcat_sub = pd.concat(outs, axis=1)\ncols = list(map(lambda x: \"target\" + str(x), range(len(concat_sub.columns))))\nconcat_sub.columns = cols\nconcat_sub.reset_index(inplace=True)\nconcat_sub.head()\nncol = concat_sub.shape[1]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# get the data fields ready for stacking\nconcat_sub['target_mean'] = concat_sub.iloc[:, 1:ncol].mean(axis=1)\nconcat_sub['target_median'] = concat_sub.iloc[:, 1:ncol].median(axis=1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"concat_sub.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"concat_sub['target'] = concat_sub['target_mean']\nconcat_sub[['image_name', 'target']].to_csv('submission_mean.csv', \n                                        index=False, float_format='%.6f')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"concat_sub['target'] = concat_sub['target_median']\nconcat_sub[['image_name', 'target']].to_csv('submission_median.csv', \n                                        index=False, float_format='%.6f')","execution_count":null,"outputs":[]}],"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":4}