{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"72ade65b-bab6-d75e-7d28-4618dd758f57"},"outputs":[],"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\nfrom subprocess import check_output\nprint(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n\n# Any results you write to the current directory are saved as output."},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"f8241f41-a911-14f8-f34f-c89a153f36ea"},"outputs":[],"source":"f = open('../input/train_numeric.csv', 'r')\n\ntrain_cols = f.readline()\n\ntrain = []\n\nfor i in range(100):\n    train.append(tuple(f.readline().split(',')))"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"e8bc3db0-7604-6fd5-c60d-e427b573d43b"},"outputs":[],"source":"train[0]"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"d8c833b9-7f87-d57a-4482-a490cd53e2b1"},"outputs":[],"source":"from collections import defaultdict"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"0e335d3e-d706-ba5f-841d-c51e0fb7bde0"},"outputs":[],"source":"P = defaultdict(dict)"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"d1ca5187-45fb-5311-1d2c-856611c9d621"},"outputs":[],"source":"for t in train:\n    pid = hash(' '.join(t)) % 65536\n    for i,v in enumerate(t):\n        if v:\n            try:\n                P[pid][i].append(float(v))\n            except KeyError:\n                P[pid][i] = [float(v)]"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"63a93bc3-fc59-d185-794c-1c4a813c49ca"},"outputs":[],"source":"for key in P:\n    for "},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"1bae81d3-30e0-7082-88da-bd144e672795"},"outputs":[],"source":"del P['2']"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"0cb77c69-3a64-dea8-246c-dfcf229650e5"},"outputs":[],"source":"P"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"4e7928c3-4eb5-90f3-d926-57c1fecd342e"},"outputs":[],"source":""}],"metadata":{"_change_revision":0,"_is_fork":false,"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.5.2"}},"nbformat":4,"nbformat_minor":0}