{"cells":[{"metadata":{},"cell_type":"markdown","source":"模型融合"},{"metadata":{},"cell_type":"markdown","source":"1. https://www.kaggle.com/filemide/distance-criskiev-hyparam-cont-1-662\n2. https://www.kaggle.com/criskiev/distance-is-all-you-need-lb-1-481\n3. https://www.kaggle.com/marcelotamashiro/lgb-public-kernels-plus-more-features\n4. https://www.kaggle.com/scaomath/no-memory-reduction-workflow-for-each-type-lb-1-28\n5. https://www.kaggle.com/fnands/1-mpnn/output?scriptVersionId=18233432\n6. https://www.kaggle.com/harshit92/fork-from-kernel-1-481\n7. https://www.kaggle.com/xwxw2929/keras-neural-net-and-distance-features\n8. https://www.kaggle.com/marcogorelli/criskiev-s-distances-more-estimators-groupkfold?scriptVersionId=18843561\n9. https://www.kaggle.com/toshik/schnet-starter-kit"},{"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","trusted":false},"cell_type":"code","source":"import os\nimport numpy as np \nimport pandas as pd \nimport matplotlib.pyplot as plt\nfrom scipy.stats.mstats import gmean\nimport seaborn as sns\n%matplotlib inline\nfrom subprocess import check_output\nprint(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))","execution_count":null,"outputs":[]},{"metadata":{"trusted":false},"cell_type":"code","source":"sub_path = \"../input/models\"\nall_files = os.listdir(sub_path)\nall_files","execution_count":null,"outputs":[]},{"metadata":{"trusted":false},"cell_type":"code","source":"all_files.remove('submission-1.701.csv')\nall_files.remove('submission-1.643.csv')\nall_files.remove('submission-1.481.csv')\nall_files.remove('submission-1.302.csv')\nall_files.remove('submission-1.619.csv')\nall_files.remove('submission-1.662.csv')\nall_files.remove('submission-1.696.csv')\nall_files.remove('submission-1.780.csv')\nall_files.remove('submission-1.708.csv')\nall_files.remove('submission-1.714.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":false},"cell_type":"code","source":"all_files","execution_count":null,"outputs":[]},{"metadata":{"trusted":false},"cell_type":"code","source":"import warnings\nwarnings.filterwarnings(\"ignore\")\nouts = [pd.read_csv(os.path.join(sub_path, f), index_col=0) for f in all_files]\nconcat_sub = pd.concat(outs, axis=1)\ncols = list(map(lambda x: \"mol\" + 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":false},"cell_type":"code","source":"#检查相关性\nconcat_sub.iloc[:,1:].corr()","execution_count":null,"outputs":[]},{"metadata":{"trusted":false},"cell_type":"code","source":"corr = concat_sub.iloc[:,1:].corr()\nmask = np.zeros_like(corr, dtype=np.bool)\nmask[np.triu_indices_from(mask)] = True\n\n\nf, ax = plt.subplots(figsize=(11, 9))\n\n#绘制热力图\nsns.heatmap(corr, mask=mask, cmap='prism', vmin=0.96, center=0, square=True, linewidths=1, annot=True, fmt='.4f')","execution_count":null,"outputs":[]},{"metadata":{"trusted":false},"cell_type":"code","source":"concat_sub['m_max'] = concat_sub.iloc[:, 1:].max(axis=1)\nconcat_sub['m_min'] = concat_sub.iloc[:, 1:].min(axis=1)\nconcat_sub['m_median'] = concat_sub.iloc[:, 1:].median(axis=1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":false},"cell_type":"code","source":"concat_sub.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":false},"cell_type":"code","source":"concat_sub.head(10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":false},"cell_type":"code","source":"cutoff_lo = 0.8\ncutoff_hi = 0.2","execution_count":null,"outputs":[]},{"metadata":{"trusted":false},"cell_type":"code","source":"concat_sub['scalar_coupling_constant'] = concat_sub['m_median']\nconcat_sub[['id', 'scalar_coupling_constant']].to_csv('stack_median.csv', \n                                        index=False, float_format='%.6f')","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}