{"cells":[{"metadata":{},"cell_type":"markdown","source":"I have tried different weights on the orginal kernel as suggested by kneroma. Please find link below of his original notebook. Credit to this notebook goes entirely to him.\n\nhttps://www.kaggle.com/kneroma/rfcx-bagging\n\nIncluded submission file from notebooks below as well\n\n* https://www.kaggle.com/aikhmelnytskyy/resnet-wavenet-my-best-single-model-ensemble\n* https://www.kaggle.com/hypnotu/automl-inference-audio-detection-soliset\n\nKindly encourage and upvote the original ideas behind the original notebooks as well"},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd, numpy as np\nimport os","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"paths = [\n    \"../input/best-submissions/submission_866.csv\",\n    \"../input/best-submissions/submission_869.csv\",\n    \"../input/bestsubmission/submission_879.csv\",\n    \"../input/best-submission/submission_876.csv\",\n]\n\nweights = np.array([0.038, 0.070, 0.745, 0.147])\n#weights = np.array([0.00, 0.35, 0.65])\nsum(weights)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df = pd.read_csv(paths[0]).sort_values(\"recording_id\").reset_index(drop=True)\ndf.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"cols = [f\"s{i}\" for i in range(24)]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"scores = []\nfor path in paths:\n    df = pd.read_csv(path).sort_values(\"recording_id\").reset_index(drop=True)\n    score = np.empty((len(df), 24))\n    o = df[cols].values.argsort(1)\n    score[np.arange(len(df))[:, None], o] = np.arange(24)[None]\n    scores.append(score)\nscores = np.stack(scores)\nscores.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sub_score = np.sum(scores*weights[:, None, None], 0)\nprint(sub_score.shape)\nsub_score","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sub = pd.DataFrame(sub_score, columns=cols)\nsub[\"recording_id\"] = df[\"recording_id\"]\nsub = sub[[\"recording_id\"] + cols]\nprint(sub.shape)\nsub.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sub.to_csv(\"submission.csv\", index=False)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","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}