Dairy farming is a vital sector of agriculture that plays a significant role in the global food supply chain. It provides essential dairy products such as milk, cheese, and yoghurt, contributing to both economic stability and food security. However, the dairy industry faces a multitude of challenges, including environmental concerns, animal health and welfare, and economic fluctuations. Amidst these challenges, optimizing dairy farm operations is crucial to ensure sustainability and profitability. The objective of this work is a comprehensive approach to address data quality management and risk assessment within the context of dairy farming, with a specific focus on feed behaviour analysis. The study begins by addressing the proliferation of big data necessitates paradigm shifts from conventional approaches in applying machine learning techniques to this huge quantity of data with varying velocity. The research proposed Apache Spark HDFS is designed to process a huge volume of data. Proper nutrition management is essential to prevent ketosis. Enhancing context across multiple scales modules was developed to rage the structures of ResNet and YOLOv5, allowing for improved extraction of contextual information from images through cross-connected semantic feature extraction modules and backbone networks. Providing a balanced diet that meets the energy requirements of the cows is important in preventing negative energy balance. Additionally, monitoring feed intake and adjusting the diet as needed can help prevent ketosis in dairy cows. This study aimed to forecast the likelihood of ketosis occurrence in dairy cows through the use of machine learning algorithms of Cascade feedforward artificial neural network. In this work, the study applies the (BOA) to the process of Stacking ensemble to generate domain-specific configurations based on non-invasive prenatal indicators of parity, body condition score, dystocia score, daily activity, daily rumination time, and season of calving, drinking time, eating time, bolus, drinking gulps, chews per minute. The simulation of this experiment is implemented using Python software. The findings exhibited the proposed algorithm positions out with an imposing accuracy rate of 95.5%, highlighting its capability for precise classifications. These findings can improve dairy farm sustainability, profitability, and the welfare of cattle, benefiting the global food supply chain.