{"cells":[{"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","trusted":true},"cell_type":"code","source":"import numpy as np\nimport pandas as pd \nimport scipy as sci\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport os\nimport warnings\nwarnings.filterwarnings(\"ignore\")\nprint(os.listdir(\"../input\"))","execution_count":1,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","collapsed":true,"trusted":true},"cell_type":"code","source":"#Changing the working directory\nos.chdir(\"../input/train_1\")","execution_count":2,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"63865da9e17c4dadd9717af8509aebbcc59a3427"},"cell_type":"code","source":"len(os.listdir())","execution_count":4,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"df4214c4700e70035c272b1640897dc5affb5731"},"cell_type":"code","source":"os.listdir()[:5]","execution_count":6,"outputs":[]},{"metadata":{"collapsed":true,"trusted":true,"_uuid":"f6dbe6debff024b04d751e0da1919eda60499a65"},"cell_type":"code","source":"types_of_csvs = [x.split('-')[1].split('.')[0] for x in os.listdir()]","execution_count":10,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b15a1ea2d5f75a3cd7e1838af47b9d6679e86115"},"cell_type":"code","source":"set(types_of_csvs)","execution_count":11,"outputs":[]},{"metadata":{"_uuid":"4dcec3bc33fea0a43985a7ec8749144f4cfb8424"},"cell_type":"markdown","source":"# READING ONE CSV FILE FROM EACH TYPE"},{"metadata":{"collapsed":true,"trusted":true,"_uuid":"0474fb1fc0e4d980f5e6971a37096684a69b62aa"},"cell_type":"code","source":"cells = pd.read_csv('event000001000-cells.csv')\nhits = pd.read_csv('event000001000-hits.csv')\nparticles = pd.read_csv('event000001000-particles.csv')\ntruth = pd.read_csv('event000001000-truth.csv')","execution_count":21,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"be4e9e17ed7e2ef70aa348772274871ce6167de3"},"cell_type":"code","source":"cells.shape","execution_count":22,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8a249d6b739d8f3bf98e50fec147549a4c4f4650"},"cell_type":"code","source":"hits.shape","execution_count":23,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"99adc7681842fedda1deff5c2317ed3d3dc10e45"},"cell_type":"code","source":"particles.shape","execution_count":24,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4756f9b44d66d4f485d246d8d9418ea44c2e3969"},"cell_type":"code","source":"truth.shape","execution_count":25,"outputs":[]},{"metadata":{"_uuid":"791317e2290bd9c97606deede6188490b16758f3"},"cell_type":"markdown","source":"# CELLS"},{"metadata":{"trusted":true,"_uuid":"4a64b7ca848b31ceabb888b81e54b5c774a2542c"},"cell_type":"code","source":"import missingno as msno\nmsno.bar(cells,figsize=(6,3))","execution_count":30,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"cdf95feed95f9ab67947130dd24e29bd8573efb3"},"cell_type":"code","source":"cells.head()","execution_count":26,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9b5711bba268e43bc713fb683ab1e8ef106a1a6a"},"cell_type":"code","source":"cells.describe()","execution_count":27,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"28cd147ce19db0f1cf366f026059b4e4db1b9016"},"cell_type":"code","source":"cells['hit_id'].value_counts().sort_values(ascending=False)[:10].plot(kind='bar',figsize=(10,5))","execution_count":58,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c4fa4fc8464b33a53fcbe47d128eb977421a34e5"},"cell_type":"code","source":"ax = sns.jointplot(x=\"ch0\", y=\"ch1\", data=cells.sample(5000), size=10)","execution_count":57,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2fa787cf06bae617acfcf8bd007bb3b5239ae66c"},"cell_type":"code","source":"sns.distplot(np.log(cells['value'] + 0.0001),kde=True,color='r',bins=100).set_title('Log Transformed Histogram of Value Column')","execution_count":86,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3b8d8a5b75cc01b2780bd6421e02658c04becded"},"cell_type":"code","source":"corr = cells.corr()\n\n# Set up the matplot figure\nf,ax = plt.subplots(figsize=(8,6))\n\n#Draw the heatmap using seaborn\nsns.heatmap(corr, cmap='inferno', annot=True)","execution_count":124,"outputs":[]},{"metadata":{"_uuid":"4cad99681fecddcd3ffa6c6f4899fe98414fddc3"},"cell_type":"markdown","source":"# HITS"},{"metadata":{"trusted":true,"_uuid":"011e9f76200977426f60258fc7980ce034384a78"},"cell_type":"code","source":"hits.head()","execution_count":88,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"34297ce64b1d7d74a2f671497e2079fe0e11a8c3"},"cell_type":"code","source":"hits.describe()","execution_count":89,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f90f7f384e5cf8362e89e8f73a177f6795346f88"},"cell_type":"code","source":"from pylab import rcParams\nrcParams['figure.figsize'] = 20, 10\ncolors=['purple', 'c', 'y', 'm', 'r','pink','orange']\nfrom mpl_toolkits.mplot3d import Axes3D\nax = plt.subplot(111, projection='3d')\n\nax.plot(hits[hits['layer_id'] == 2]['x'], hits[hits['layer_id'] == 2]['y'], hits[hits['layer_id'] == 2]['z'], 'x', color=colors[0], label='2')\nax.plot(hits[hits['layer_id'] == 4]['x'], hits[hits['layer_id'] == 4]['y'], hits[hits['layer_id'] == 4]['z'], 'o', color=colors[1], label='4')\nax.plot(hits[hits['layer_id'] == 6]['x'], hits[hits['layer_id'] == 6]['y'], hits[hits['layer_id'] == 6]['z'], '.', color=colors[2], label='6')\nax.plot(hits[hits['layer_id'] == 8]['x'], hits[hits['layer_id'] == 8]['y'], hits[hits['layer_id'] == 8]['z'], '^', color=colors[3], label='8')\nax.plot(hits[hits['layer_id'] == 10]['x'], hits[hits['layer_id'] == 10]['y'], hits[hits['layer_id'] == 10]['z'], '+', color=colors[4], label='10')\nax.plot(hits[hits['layer_id'] == 12]['x'], hits[hits['layer_id'] == 12]['y'], hits[hits['layer_id'] == 12]['z'], 'v', color=colors[5], label='12')\nax.plot(hits[hits['layer_id'] == 14]['x'], hits[hits['layer_id'] == 14]['y'], hits[hits['layer_id'] == 14]['z'], '_', color=colors[6], label='14')\n\nplt.legend(loc='upper left', numpoints=1, ncol=3, fontsize=18, bbox_to_anchor=(0, 0))\n\nplt.show()","execution_count":123,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"391a544506216187f738254d1891cffec8a29236"},"cell_type":"code","source":"rcParams['figure.figsize'] = 10,5\nhits['volume_id'].value_counts().plot(kind='bar',title = 'Volume ID bar Plot')","execution_count":130,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"00ff2df8638bd442b1f4bbe69886b3fb3ce2e35b"},"cell_type":"code","source":"hits['layer_id'].value_counts().plot(kind='bar',title = 'Layer ID bar Plot')","execution_count":131,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0e6eae2b841f27e64f79b634ebe57606f286863e"},"cell_type":"code","source":"hits['module_id'].value_counts()[:20].plot(kind='bar',title = 'Module ID bar Plot')","execution_count":133,"outputs":[]},{"metadata":{"_uuid":"74a441823c3ce86b400548c22c01a5579b5f8bcb"},"cell_type":"markdown","source":"# PARTICLES"},{"metadata":{"trusted":true,"_uuid":"56a3205b9a2b0708fb61571f0757e15c551d3e22"},"cell_type":"code","source":"particles.head()","execution_count":134,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"495e3febfcd15b65378d2e37e0e1c9ac8d74ebbd"},"cell_type":"code","source":"for i in list(particles.columns.values):\n    print(i, len(set(particles[i])))","execution_count":136,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"ac684393eee999919a269efe5b2b14d78b08e506"},"cell_type":"code","source":"rcParams['figure.figsize'] = 20, 10\ncolors=['purple', 'orange']\nax = plt.subplot(111, projection='3d')\n\nax.plot(particles[particles['q'] == -1]['px'], particles[particles['q'] == -1]['py'], particles[particles['q'] == -1]['pz'], '.', color=colors[0], label='-1')\nax.plot(particles[particles['q'] == 1]['px'], particles[particles['q'] == 1]['py'], particles[particles['q'] == 1]['pz'], '_', color=colors[1], label='1')\nplt.legend(loc='upper left', numpoints=1, ncol=3, fontsize=18, bbox_to_anchor=(0, 0))\n\nplt.show()","execution_count":141,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"01d49ccfecefee2700bb081ef26c6c1546ea0585"},"cell_type":"code","source":"pd.crosstab(particles['q'], particles['nhits'])","execution_count":148,"outputs":[]},{"metadata":{"_uuid":"4d73ea82567c435d62500d69c8a666bf6cf27129"},"cell_type":"markdown","source":"# TRUTH"},{"metadata":{"trusted":true,"_uuid":"05966afef03858888a820c6e069eec7fa9f2b64d"},"cell_type":"code","source":"truth.head()","execution_count":150,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"394f116a3491ae5e69bf327dea9c8206c5c4c588"},"cell_type":"code","source":"from pylab import rcParams\nrcParams['figure.figsize'] = 30, 15\nfrom mpl_toolkits.mplot3d import Axes3D\nax = plt.subplot(111, projection='3d')\n\nax.plot(truth['tpx'], truth['tpy'], truth['tpz'], '.')\nplt.legend(loc='upper left', numpoints=1, ncol=3, fontsize=18, bbox_to_anchor=(0, 0))\n\nplt.show()","execution_count":153,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"21047d0fb2e313695ff7c70264ad35eb7fb9944a"},"cell_type":"code","source":"np.log(truth['weight']+ 0.00001).plot(kind='hist',bins=50,title='Log Transformed Weight')","execution_count":156,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.5","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}