{"cells":[{"metadata":{},"cell_type":"markdown","source":"## Stacking the Best Models by Mode\n\nMode = the most frequently observed data value. <br>\nIf two submissions \"vote\" for the same result, then the result is correct. Probably.  <br>\nOr the both submissions are wrong ;)\n\n<pre><b>\nThis Kernel shows how the scores can be improved using Stacking Method.\nCredit Goes to the following kernels\nref:\nhttps://www.kaggle.com/roydatascience/cellular-stacking-1-5\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"import os\nimport numpy as np \nimport pandas as pd \nfrom scipy import stats\nimport warnings\nwarnings.filterwarnings(\"ignore\")\nimport glob\n\nall_files = glob.glob(\"../input/cellstack/*.csv\")\nall_files","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"outs = [pd.read_csv((f), index_col=0)['sirna'].values for f in all_files]\ncollected = np.array(outs)\n\n# getting the mode\nm = stats.mode(collected)[0][0]\n\nsubmission = pd.read_csv('../input/recursion-cellular-image-classification/sample_submission.csv')\nsubmission['sirna'] = m\nsubmission.to_csv('ModeStacker.csv', index=False)","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.6.6"}},"nbformat":4,"nbformat_minor":1}