{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\nprint(os.listdir(\"../input/igneural1024newfeats\"))\nprint(os.listdir(\"../input/egneural512newfeats\"))\n\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"igPred=pd.read_csv('../input/igneural1024newfeats/subm_0.028309_2018-12-14-21-37.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"bf4c0c5a1b953631abfae5fd2215fef41514e06c"},"cell_type":"code","source":"egPred=pd.read_csv('../input/egneural512newfeats/subm_0.836138_2018-12-14-22-54.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"301c11e0d93f2c96072f60030a415300f9e15092"},"cell_type":"code","source":"print(igPred.shape)\nprint(egPred.shape)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3b66b8b01e04d6222381939ea2355e1eb4e2c01c"},"cell_type":"code","source":"for cindex in igPred.columns:\n    if cindex not in egPred.columns:\n        egPred[cindex]=0\n        \nfor cindex in egPred.columns:\n    if cindex not in igPred.columns:\n        igPred[cindex]=0\n        ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"dcc28782e6acc20ae8344a4c2df59814387c3406"},"cell_type":"code","source":"igPred.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e8863b138067dc8fae8f9fc81da254838472368a"},"cell_type":"code","source":"egPred.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9f8d316b2fa0752fb18aad9b5b56868d78c761f7"},"cell_type":"code","source":"pdf=pd.concat([igPred, egPred], sort=True)\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"472f20c7ca1db4f0722020c4d3e929d354ab75f7"},"cell_type":"code","source":"pdf.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5fa911bf8495e958735ec5ffbc7d11e1a99f17ed"},"cell_type":"code","source":"pdf=pdf.fillna(0)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6c3ae8bdec6591175b5a3d1470107370f65051a1"},"cell_type":"code","source":"pdf.describe()\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5e638fec1ae509fa3637b2e2065d363bc576540a"},"cell_type":"code","source":"#from Scirpus discussion:\n\ndef GenUnknown(data):\n    return ((((((data[\"mymedian\"]) + (((data[\"mymean\"]) / 2.0)))/2.0)) + (((((1.0) - (((data[\"mymax\"]) * (((data[\"mymax\"]) * (data[\"mymax\"]))))))) / 2.0)))/2.0)\n\nfeats = ['class_6', 'class_15', 'class_16', 'class_42', 'class_52', 'class_53',\n         'class_62', 'class_64', 'class_65', 'class_67', 'class_88', 'class_90',\n         'class_92', 'class_95']\n\ny = pd.DataFrame()\ny['mymean'] = pdf[feats].mean(axis=1)\ny['mymedian'] = pdf[feats].median(axis=1)\ny['mymax'] = pdf[feats].max(axis=1)\n\npdf['class_99'] = GenUnknown(y)\npdf.describe()\npdf.to_csv('mergeNeuralNTPost99.csv', index=False)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3ff7c7f8f63c482d40b34d59411f73113b50c8de"},"cell_type":"code","source":"import copy\nmeta=pd.read_csv('../input/PLAsTiCC-2018/test_set_metadata.csv')\nmeta.describe()\n\ndef modUnknown(opdf, meta, ddfMult=0.5, mwMult=0.5, preserveMed=False):\n    pdf=copy.deepcopy(opdf)\n    mdf=pdf.merge(meta,on='object_id')\n    ddfilter=mdf.loc[:,'ddf']==1\n    mwfilter=mdf.loc[:,'hostgal_photoz']==0\n    print(ddfilter.sum())\n    print(mwfilter.sum())\n    \n    mdf.loc[mwfilter,'class_99']=mwMult*mdf.loc[mwfilter,'class_99']\n    mdf.loc[ddfilter,'class_99']=ddfMult*mdf.loc[ddfilter,'class_99']\n    pdf.loc[:,'class_99']=mdf.loc[:,'class_99']\n    \n    return pdf\n\nnpdf=modUnknown(pdf, meta)\nnpdf.describe()\npdf.to_csv('mergeNeuralNTPost99igless.csv', index=False)\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"08cee2d542b182deff68f39134f960c58d801d5b"},"cell_type":"code","source":"npdf.to_csv('mergeNeuralNTPost99.csv', index=False)","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}