PurposeThe purpose of this paper is to present numerical simulations for magnetohydrodynamics natural convection of a nanofluid flow inside a cavity with an H-shaped obstacle based on combining artificial neural network (ANN) with the finite element method (FEM), and predict the heat transfer rate and system entropy.Design/methodology/approachThe enclosure is assumed to be inclined. Changing the inclination angle results in a different obstacle shape, which affects the buoyancy force. Hence, different configurations of the contours of the fluid flow, isotherms and the entropy of the system are obtained. The outer walls of the cavity as well as the central part of the obstacle are kept adiabatic. The left vertical portion of the hindrance is cooled, whereas the right vertical part of the obstacle is a heated wall. Using dimensionless variables allows obtaining a dimensionless version of the governing system of equations that is solved via the consistency FEM. The coupled problem of pressure and velocity is overcome via the Increment Pressure Correction Scheme, which is known for its accuracy and stability for similar simple problems. A numerical computation is performed across a broad range of the governing parameters. A total of 304 data sets were used in the development of an ANN model. That data set was conducted from the numerical simulations. The data set underwent optimization, with 70% sets used for training the model, 15% for validation and another 15% for the testing phase. The training of the network model used the Levenberg–Marquardt training algorithm.FindingsFrom the numerical simulations, it is concluded that the H-shaped obstacle boosts heat transfer rate in comparison with the I-shaped case. Also, raising the value of the inclination angle improves the entropy of the system presented by the Bejen number. Furthermore, strength heat transfer rate is obtained via decreasing the Hartmann number while this decrease decays the values of the Bejen number for both positive and negative amounts of the nonlinear Boussinesq parameter. Slower velocity and a better heat transfer rate characterize nanofluid compared with pure fluid. Leveraging the capabilities of the ANN, the developed model adeptly forecasts the values of both the average Nusselt and Bejen numbers with a high degree of accuracy.Originality/valueA novel fusion of FEM and ANN has been tailored to forecast the heat transfer rate and system entropy of MHD natural convective flow within an inclined cavity containing an H-shaped obstacle, amid various physical influences.