Machine learning algorithms are attracting significant interest for predicting complex chemical phenomenon. In this work, a model to predict research octane number (RON) and motor octane number (MON) of pure hydrocarbons, hydrocarbon-ethanol blends and gasoline-ethanol blends has been developed using artificial neural networks (ANN) and molecular parameters from 1H nuclear Magnetic Resonance (NMR) spectroscopy. RON and MON of 128 pure hydrocarbons, 123 hydrocarbon-ethanol blends of known composition and 30 FACE (fuels for advanced combustion engines) gasoline-ethanol blends were utilized as a dataset to develop the ANN model. The effect of weight % of seven functional groups including paraffinic CH3 groups, paraffinic CH2 groups, paraffinic CH groups, olefinic -CH=CH2 groups, naphthenic CH-CH2 groups, aromatic C-CH groups and ethanolic OH groups on RON and MON was studied. The effect of branching (i.e., methyl substitution), denoted by a parameter termed as branching index (BI), and molecular weight (MW) were included as inputs along with the seven functional groups to predict RON and MON. The topology of the developed ANN models for RON (9-540-314-1) and MON (9-340-603-1) have two hidden layers and a large number of nodes, and was validated against experimentally measured RON and MON of pure hydrocarbons, hydrocarbon-ethanol and gasoline-ethanol blends; a good correlation (R2=0.99) between the predicted and the experimental data was obtained. The average error of prediction for both RON and MON was found to be 1.2 which is close to the range of experimental uncertainty. This shows that the functional groups in a molecule or fuel can be used to predict its ON, and the complex relationship between them can be captured by tools like ANN.