Recently, the combination of machine learning (ML) and simulation is gaining a lot of attention. This paper presents a novel application of ML within the simulation to improve patient flow within an emergency department (ED). An ML model used within a real ED simulation model to quantify the effect of detouring a patient out of the ED on the length of stay (LOS) and door-to-doctor time (DTDT) as a response to the prediction of patient admission to the hospital from the ED. The ML model trained using a set of six features including the patient age, arrival day, arrival hour of the day, and the triage level. The prediction model used a decision tree (DT) model, which is trained using historical data achieves a 75% accuracy. The set of rules extracted from the DT are coded within the simulation model. Given a certain probability of free inpatient beds, the predicted admitted patient is then pulled out from the ED to inpatient units to alleviate the crowding within the ED. The used policy combined with adding specific ED resources achieve 9.39% and 8.18% reduction in LOS and DTDT, respectively.