Coconut oil (CO) is commonly known to have health benefits and thus is a commonly used functional oil in numerous consumer products. Nevertheless, CO is rather expensive and highly demanded, which leads to economic profit through the adulteration with cheaper, low-quality vegetable oils. This adulteration does not only affect the quality of the oil but also creates great health and safety hazards for consumers. Conventional ways of identifying such adulteration tend to be time-consuming, are toxic, as well as complex in the preparation of the sample. Consequently, this necessitates the need to have faster, precise, and environmentally friendly methods of conducting analytical procedures to identify CO adulteration. This study developed an advanced method for processing CO using HSI camera and deep learning method for prediction of adulteration in CO. The proposed model named TKRnet, which is composed of a Transformer for feature enhancing in data, KBest for feature selection and Random Forest for prediction. Raw spectral data is transformed by the transformer and spectral indices with statistical features are integrated to give a rich feature set. This proposed architecture has several levels of feature engineering in which there is the calculation of normalized difference indices and statistical descriptors, and dimensionality reduction with SelectKBest to provide optimal feature selection. The designed features are fed into the RF model and this guarantees a powerful and effective performance in the regression and classification processes. The method of preprocessing can enhance the predictive accuracy and interpretability of the models because it retains meaningful spectral information at a low dimensionality. The performance appraisals show little variation with the 8 chosen features explaining 99.65 maximum performance of the model. The findings indicate that the TKRnet is better than the traditional models in their R2 score, root mean squared error (RMSE), and mean absolute error (MAE), and the proposed model has the highest predictive power. The experiment underscores the significance of integrating high-level feature selection and transformation with the state-of-the-art ensemble-based learning algorithms such as the Random Forest to get high predictive accuracy. We find that Random Forest models that are enhanced using transformers work well on tasks with high performance and robustness, especially on complex and high-dimensional data.