{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nfrom matplotlib.pyplot import *\nimport os\nimport matplotlib.pyplot as plt\nfrom os import listdir\nfrom os.path import isfile, join\nprint(os.listdir(\"../input\"))\nimport os\nroot = '../input/'","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"csv_files = [f for f in listdir(root) if isfile(join(root, f)) and '.csv' in f ]\ndataframes = {}\nfor file in csv_files:\n    dataframes[os.path.splitext(file)[0]] = pd.read_csv(root+file)\nfor i,file in enumerate(csv_files,1):\n    print(i,'file name      :',file)\n    print('  dataframe shape:',dataframes[os.path.splitext(file)[0]].shape)\n    print('  data columns   : ',end='')\n    print(*dataframes[os.path.splitext(file)[0]].columns ,sep=', ',end='\\n\\n')","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"train = pd.read_csv('../input/train.csv')\ntest=pd.read_csv('../input/test.csv')\nsub=pd.read_csv('../input/sample_submission.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"structures = pd.read_csv('../input/structures.csv')\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"print(f'There are {train.shape[0]} rows in train data.')\nprint(f'There are {test.shape[0]} rows in test data.')\n\nprint(f\"There are {train['molecule_name'].nunique()} distinct molecules in train data.\")\nprint(f\"There are {test['molecule_name'].nunique()} distinct molecules in test data.\")\nprint(f\"There are {train['atom_index_0'].nunique()} unique atoms.\")\nprint(f\"There are {train['type'].nunique()} unique types.\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.columns\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Structure of molecules\n Molecule geometry\nTo begin with, the location of atoms can be found in structures.csv. The columns of interest are\n\natom : a letter for the atom type\nx, y, z: 3D coordinrates of each atom\n\n\nAtoms types¶"},{"metadata":{"trusted":true},"cell_type":"code","source":"structures.atom.unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.type.unique()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"There are only 8 different possible couplings types. "},{"metadata":{"trusted":true},"cell_type":"code","source":"from sklearn import linear_model\nfeautures=['atom_index_0','atom_index_1']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"y = train.scalar_coupling_constant\nX = train[feautures]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"lm = linear_model.LinearRegression()\nmodel = lm.fit(X,y)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"predictions = lm.predict(X)\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"lm.score(X,y)","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}