Currently, the interest in utilizing ammonia in internal combustion engines stems from the trend toward decarbonization, as ammonia is a zero-carbon footprint fuel. Existing studies on ammonia engines are limited and most of the available literature mainly considers the application of ammonia in gasoline converted engines. Accordingly, the objective of this study was to increase the knowledge of diesel engines modified for dedicated ammonia operation. A spark plug was added to the original compression ignition engine to control and initiate the ammonia combustion process. The available experimental results of such a modified engine including noise and the test conditions were randomly distributed without careful design. As a result, the machine learning model was utilized to assist in analyzing the ammonia engine performance by reducing the experimental uncertainty. The results showed that the random forest algorithm suffered from boundary underfitting, while the gradient boosting regression trees algorithm encountered overfitting problems. Moreover, the artificial neural network algorithm performed better than support vector regression, effectively learning the relationship between engine control variables and the ammonia engine performance. The parametric studies conducted by the well-trained machine learning model suggested that the combustion law of heavy-duty ammonia engines was consistent with that of traditional spark ignition engines. Most importantly, the regular compression ratio of diesel engines allowed efficient dedicated ammonia combustion with an equivalence ratio as lean as 0.7 despite the slow laminar flame speed of ammonia–air mixtures. Furthermore, a compression ratio of 18 contributed to optimal spark timing at 8 crank angle deg before top dead center when operated at stoichiometry, rather than a very large spark advance, which was favorable for engine control. Overall, the conversion of compression ignition engines to ammonia spark ignition operation is promising.