{"cells":[{"metadata":{},"cell_type":"markdown","source":"**What is Quantum Mechanics?**\n\nQuantum mechanics is the branch of physics relating to the very small.It results in what may appear to be some very strange conclusions about the physical world. At the scale of atoms and electrons, many of the equations of classical mechanics, which describe how things move at everyday sizes and speeds, cease to be useful. In classical mechanics, objects exist in a specific place at a specific time. However, in quantum mechanics, objects instead exist in a haze of probability; they have a certain chance of being at point A, another chance of being at point B and so on.\n\n\nThree Concepts that we can relate to: \nQuantized properties:\nCertain properties, such as position, speed and color, can sometimes only occur in specific, set amounts, much like a dial that \"clicks\" from number to number. This challenged a fundamental assumption of classical mechanics, which said that such properties should exist on a smooth, continuous spectrum. To describe the idea that some properties \"clicked\" like a dial with specific settings, scientists coined the word \"quantized.\"\n\n\nhttps://www.livescience.com/33816-quantum-mechanics-explanation.html"},{"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\"))\n\n\n\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Reading the files:\n\n"},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"train=  pd.read_csv(\"../input/train.csv\")\n\n\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Descriptive Statistics: \n\nIndependent Varaibles:\nThe trianing set has molecule name, atom_index_1 (don't know what is that), type \n\nDependent and Target Variable:\nScalar coupling constant"},{"metadata":{"trusted":true},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**Distribution of the target Variable - Scalar coupling constant **\n\nThere are outliers in the target variable. I dont understand what it is but it has two modes. "},{"metadata":{"trusted":true},"cell_type":"code","source":"import matplotlib.pyplot as plt \nimport seaborn as sns\ntrain.scalar_coupling_constant.describe()\nsns.distplot( train.scalar_coupling_constant.values)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"** Molecule Type **"},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.countplot(train.type.values)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"By looking athe individual histograms it is pretty much obvious that the scalar coupling constants distribution is on the higher side for type 1HJCC"},{"metadata":{"trusted":true},"cell_type":"code","source":"train.boxplot(column=\"scalar_coupling_constant\",        # Column to plot\n                 by= \"type\",         # Column to split upon\n                 figsize= (8,8)) \n\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**Molecule Name **\nThey are not unique here. "},{"metadata":{"trusted":true},"cell_type":"code","source":"train.groupby('molecule_name',group_keys=False).size()\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Test dataset: \nIt has the molecule name and index type and no Scalar coupling constant"},{"metadata":{"trusted":true},"cell_type":"code","source":"test= pd.read_csv(\"../input/test.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.countplot(test.type.values)\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**Model Building ** \n\nStep 1: Spliting the training set into train and test \nStep 2: Data Cleaning\nSetp 3: Model building \nStep 4: Model Validation\n"},{"metadata":{},"cell_type":"markdown","source":"**Test Train Split**"},{"metadata":{"trusted":true},"cell_type":"code","source":"import sklearn\nfrom sklearn.model_selection import train_test_split\n\nnrow = len(train)\nX_train, X_test = sklearn.model_selection.train_test_split(train,test_size=int(nrow*0.1),random_state=1)\nX_train, X_val = sklearn.model_selection.train_test_split(X_train,test_size=int(nrow*0.2),random_state=1)\n\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**Finding the mean Values by type**"},{"metadata":{"trusted":true},"cell_type":"code","source":"dt=  X_train['scalar_coupling_constant'].groupby(X_train['type']).mean()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"X_train['Mean'] = X_train.groupby('type')['scalar_coupling_constant'].transform(np.average)  \nX_train.head()\n\nfrom sklearn.metrics import mean_squared_error\nfrom math import sqrt\n\nrms = sqrt(mean_squared_error(X_train.Mean.values, X_train.scalar_coupling_constant.values))\n\nprint(\"RMSE for mean by type is \"+ str(rms))\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sample_submission=  pd.read_csv(\"../input/sample_submission.csv\")\nsample_submission.head()\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Some background about what is Scalar coupling constant? \n\nI am not familiar with the terms but this is how it reads in Wiki: \nWhen rare isotopes (such as 13C at natural abundance) couple with an abundant nucleus (e.g. proton), each dominant peak in the spectrum of the abundant nucleus will be symmetrically surrounded by two small peaks arising due to the coupling with the rare isotope. Those peaks are called satellite signals. \n\nThe fact that magnitude of scalar coupling does not depend on the molecular orientation does not contradict another fact that scalar coupling does depend on molecular geometry and in particular - molecular conformation. \n\nScalar coupling is also sometimes called as indirect spin-spin coupling and indirect dipole-dipole coupling\n"},{"metadata":{},"cell_type":"markdown","source":"**Why Coupling Constants are necessary?**\nCoupling constants are very useful for discussing the structure and nature of chemical bonding in compounds containing fluorine. However, to date only a few relative signs of couplings have been reported, and it is not possible in all cases to establish with certainty the effect of the substituents and of the structure on the element–fluorine bond."},{"metadata":{"trusted":true},"cell_type":"code","source":"Poetential_energy= pd.read_csv(\"../input/potential_energy.csv\")","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"So we have the potential energy by molecules "},{"metadata":{"trusted":true},"cell_type":"code","source":"Poetential_energy.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":" Mulliken_charges= pd.read_csv(\"../input/mulliken_charges.csv\")","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"So we have a unique mulliken cahrge \n\nThe mulliken charges are charges based in the local electron density (charge density) its depend strongly of the basic set and the functional, because it is sensitive to the probability density . soo if you what to compare results you should use the same functional and basic set in the way to make a accurately comparison.  In other way the comparison is not adequate due to the change of probability density in each method .  It says there is something called as Fukui index which may need exploration\n\nhttps://www.researchgate.net/post/What_iare_mulliken_atomic_charges"},{"metadata":{"trusted":true},"cell_type":"code","source":"Mulliken_charges.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"scalar_coupling_contributions= pd.read_csv(\"../input/scalar_coupling_contributions.csv\")","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The question here is what is fc, sd, pso and dso ? \n\n\nThe analysis of NMR spin-spin coupling leads to a unique insight into the electronic structure of closed-shell molecules, provided one is able to decode the different features of the spin-spin coupling mechanism. For this purpose, the physics of spin-spin coupling is described and the way how spin-spin coupling constants (SSCCs) can be quantum mechanically determined.\n\n\nAnalysis method fulfills all requirements. J-OC-PSP makes it possible to partition the isotropic indirect SSCC J or its reduced analogue K as well as the four Ramsey terms (Fermi contact (FC), spin dipole (SD), diamagnetic spin orbit (DSO), paramagnetic spin orbit (PSO)) leading to J (or K) into Cartesian components (for the anisotropic Ramsey terms SD, DSO, PSO), orbital contributions or electron interaction terms. For the purpose of decoding the spin-spin coupling mechanism, FC, SD, DSO, and PSO coupling is discussed in detail and related to electronic and bonding features of the molecules in question. The myth of empirical and semiempirical relationships between SSCCs and bonding features is unveiled.\n\nhttps://www.ncbi.nlm.nih.gov/pubmed/17538726\n\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"scalar_coupling_contributions.head()","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}