Efficient thermal management is a critical challenge in various engineering configuration where overheating affects performance, such as electronics, industrial cooling, and HVAC applications. Traditional cooling methods often struggle with confined enclosures, leading to inefficiencies. Nanofluids and optimized heating mechanisms offer a promising solution, but their complex thermal behavior requires precise predictive modeling. This study addresses this challenge by conducting a numerical analysis of heat transfer in nanofluid-filled enclosures with sinusoidal heating. This study employs multi-expression programming technique to improve thermal performance by analyzing heating design and electromagnetic interactions. In this exploration a square enclosure filled with water-based copper oxide nanofluid is evaluated, featuring a centrally located sinusoidal heated element. The enclosure is also partially heated from below, cooled along the sidewalls, while the upper and remaining lower portions are insulated. The numerical simulation explores flow-controlling variables, including nanoparticles volume fraction, heating element amplitude, magnetic field strength and its orientation, viscous dissipation, and heat generation, to assess their impact on flow dynamics and thermal performance. The findings indicate that the Nusselt number increases by 26.68% when nanoparticle concentration reaches 4%, while a rise in Rayleigh number from 103 to 106 results in an approximate 75.40% increase. Moreover, the average percentage decrease in Nusselt number against Qg from 0 to 30 is 20.71% while for Ha (10 to 100) it is 42.61%.The multi-expression programming model accurately predicts convective heat transfer trends, achieving a high correlation coefficient (CR = 0.99 for training, CR = 0.94 for testing) and low error metrics (RMSE = 0.02, MAE = 0.03, PI = 0.06 for training), ensuring strong agreement with numerical results.