Biodiesel has emerged as a compelling substitute for conventional diesel fuel, providing a sustainable and eco-friendly choice for fueling compression ignition engines. This comprehensive study investigates the influence of biodiesel, specifically derived from sunflower oil, through the esterification method, on crucial engine performance parameters and environmental effects. The study examines the impact of varying engine torque on the performance of a single-cylinder, four-stroke compression ignition engine, encompassing parameters such as brake thermal efficiency (BTE) and brake specific fuel consumption (BSFC), as well as exhaust emissions, including unburned hydrocarbons (HC), carbon monoxide (CO), and nitrogen oxides (NOx). Four distinct biodiesel blends (B10, B20, B30, B40) with varying sunflower oil content are systematically compared to pure diesel (B0). The engine operates at a consistent speed of 1700 rpm, while the torque undergoes controlled adjustments from 0 to 10 Nm. Subsequently, this study explores the application of an alternating model tree (AMT) machine learning algorithm to establish relationships between independent factors, specifically torque and biodiesel volume (%vol), and dependent variables, including BTE, BSFC, CO, and NOx in a combustion engine. Additionally, the study employs a multi-objective ameliorative whale optimization algorithm (AWOA) to optimize the model's output. The objective is to identify optimal values for torque and%vol that maximize engine performance (BTE) while minimizing engine emissions (CO and NOx) and reducing fuel consumption (BSFC). The optimization process yields noteworthy results, with AWOA achieving peak BTE at 29.714 %, BSFC at 0.262 kg.kWh-1, and NOx emissions at 992 ppm at torque 7.3 N.m and 13% vol. In contrast, particle swarm optimization (PSO) secured the minimum CO level at 0.123 %, with torque set at 7.6 N.m and 26% vol. The AMT models demonstrate high prediction accuracy, with coefficient of determination (R2) values exceeding 0.98.