{"cells":[{"metadata":{"trusted":true},"cell_type":"code","source":"!ls ../input/1-mpn\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"!ls ../input/\n!ls ../input/nnet-b-seed-10\n!ls ../input/nnet-b-seed-11\n!ls ../input/nnet-b-seed-12","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"!ls ../input/champ-preds","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"import pandas as pd\n\ndef get_median_from_files(files):\n    print(len(files))\n    outs = [pd.read_csv(f, index_col=0) for f in files]\n    concat_sub = pd.concat(outs, axis=1, sort=True)\n    champ_median = concat_sub.median(axis=1).values\n    return champ_median\n\n\ntest = pd.read_csv(f\"../input/champs-scalar-coupling/test.csv\")\nTARGET = 'scalar_coupling_constant'\n\ntest['conservative']  =  pd.read_csv('../input/champs-ensemble-conservative/ensemble_sub_conservative.csv')[TARGET]\ntest['n1'] =  get_median_from_files(\n    [\n        '../input/champ-preds/gnn_median_2302.csv',\n        '../input/champ-preds/gnn_median_2301.csv',\n        '../input/champ-preds/gnn_median_adjusted_1JHC_2296.csv', \n    ]\n)\ngnn_2312 = pd.read_csv('../input/champ-preds/gnn_median_65_68_2312.csv')[TARGET]\nlastgnn = pd.read_csv('../input/champ-preds/gnn_median_69_73.csv')[TARGET]  # 2318\ntest['n1'] = lastgnn * 0.5 + gnn_2312 * 0.3 + test['n1'] *0.2\n\ntest['n2'] =  pd.read_csv('../input/champ-preds/gnn0_median_2068.csv')[TARGET]\ntest['lgb_a'] = get_median_from_files(\n    [\n        '../input/champ-preds/submission_type_2100.csv',\n        '../input/champ-preds/submission_type_2085.csv', \n    ]\n)\ntest['lgb_m'] = get_median_from_files(\n    [\n        '../input/champ-preds/lgb_type_full_f286_10.csv', # -2.027\n        '../input/champ-preds/lgb_type_full_f262_10.csv', # -2.016\n    ]\n)\ntest['nnet'] = get_median_from_files(\n    [\n        '../input/nnpvals-seed-20/nnet_sub_s11.csv',\n        '../input/champ-preds/nnet_sub.csv',  # version 6\n        '../input/nn-seed-10/nnet_sub.csv',\n        '../input/nn-seed-11/nnet_sub.csv',\n        '../input/nnet-c-seed-10/lgb_type_cv-1.7126_mae0.23572_fd5_10.csv',\n        '../input/nnet-c-seed-11/lgb_type_cv-1.70994_mae0.23497_fd5_11.csv',\n        '../input/nnet-c-seed-12/lgb_type_cv-1.71029_mae0.23523_fd5_12.csv',\n        '../input/nnet-b-seed-10/lgb_type_cv-1.72296_mae0.24019_bags-1_f120_fd5_10.csv',\n        '../input/nnet-b-seed-11/lgb_type_cv-1.70647_mae0.2376_bags-1_f120_fd5_11.csv',\n        '../input/nnet-b-seed-12/lgb_type_cv-1.69833_mae0.24106_bags-1_f120_fd5_12.csv',\n#         '../input/nnet-try/lgb_type_cv-2.108373877033157_mae0.12143527465528912_bags-1_f120_fd5_10.csv',\n        '../input/nnet-try-seed-11/lgb_type_cv-1.64944_mae0.23965_bags-1_f120_fd5_11.csv',\n#        '../input/nnet-try-seed-12/lgb_type_cv-1.64875_mae0.2412_bags-1_f120_fd5_12.csv',\n    ]    \n)\ntest['nnet_cont'] = get_median_from_files(\n    [\n        '../input/nncont-seed-23-p/nnetCont_sub_only_predict.csv', \n        '../input/nncont-seed-22/nnetCont_sub-1.8213.csv', # cv\n    ]   \n)\nnn_contof =  pd.read_csv('../input/nncont-seed-26/nnetCont_sub_-2.6677.csv')[TARGET]\ntest['nnet_cont'] = nn_contof * 0.6 + test['nnet_cont'] * 0.4\ntest['final_mpnn']  =  pd.read_csv('../input/champ-preds/final_mpnn.csv')[TARGET]\ntest['mpnn']  =  pd.read_csv('../input/champ-preds/mpnn_5_fold_pseudo_1449.csv')[TARGET]\n\ntest['lb'] = pd.read_csv('../input/chemistry-of-best-models-1-895/stack_median.csv')[TARGET]  # -1.895 or a bit more\ntest['stack15'] = pd.read_csv('../input/15th-stacking/test_stacking.csv')[TARGET]  # -2.8 :D\n# test['mpnn'] = pd.read_csv('../input/champ-preds/mpnn_5_fold_pseudo_1449.csv')[TARGET]\ntest.head(10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# test_with_preds = test_with_preds.sort_values('id')\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n%matplotlib inline  \n\ntest['nnet_ens'] = test['nnet_cont'] * 0.6 + test['nnet'] * 0.4\ntest['lgb_ens'] = test['lgb_a'] * 0.8 + test['lgb_m'] * 0.2\n\ntest['final_preds'] =(\n    test['n1']*0.5 +\n    test['n2']*0.1 +\n    test['lgb_ens']*0.15 +\n    test['nnet_ens']*0.1 +\n    test['lb']*0.1 +\n    test['final_mpnn'] * 0.03 + test['mpnn'] *0.02\n)\ntest.head(20)\n\nfig, ax = plt.subplots(1, 1, figsize=(12, 8))\ncols = [col for col in test.columns if col not in ['id', 'molecule_name', 'atom_index_0', 'atom_index_1']]\nfig = sns.heatmap(test[cols].corr(), cmap='viridis', square=True)\ntest[cols].corr()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# seeing only nnet\nsubmission = pd.DataFrame()\nsubmission['id'] = test.id\n# submission['scalar_coupling_constant'] = test['final_preds']\nsubmission['scalar_coupling_constant'] = test['final_preds'] * 0.1 + test['stack15'] * 0.9\nsubmission.to_csv('ensemble_sub.csv', index=False)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"submission.head(20)","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":1}