Fungal infections are associated with high morbidity and mortality in the intensive care unit (ICU), but their diagnosis is difficult. In this study, machine learning was applied to design and define the predictive model of ICU-acquired fungi (ICU-AF) in the early stage of fungal infections using Random Forest. This study aimed to provide evidence for the early warning and management of fungal infections. We analyzed the data of patients with culture-positive fungi during their admission to seven ICUs of the First Affiliated Hospital of Chongqing Medical University from January 1, 2015, to December 31, 2019. Patients whose first culture was positive for fungi longer than 48 h after ICU admission were included in the ICU-AF cohort. A predictive model of ICU-AF was obtained using the Least Absolute Shrinkage and Selection Operator and machine learning, and the relationship between the features within the model and the disease severity and mortality of patients was analyzed. Finally, the relationships between the ICU-AF model, antifungal therapy and empirical antifungal therapy were analyzed. A total of 1,434 cases were included finally. We used lasso dimensionality reduction for all features and selected six features with importance ≥0.05 in the optimal model, namely, times of arterial catheter, enteral nutrition, corticosteroids, broadspectrum antibiotics, urinary catheter, and invasive mechanical ventilation. The area under the curve of the model for predicting ICU-AF was 0.981 in the test set, with a sensitivity of 0.960 and specificity of 0.990. The times of arterial catheter (p = 0.011, OR = 1.057, 95% CI = 1.053-1.104) and invasive mechanical ventilation (p = 0.007, OR = 1.056, 95%CI = 1.015-1.098) were independent risk factors for antifungal therapy in ICU-AF. The times of arterial catheter (p = 0.004, OR = 1.098, 95%CI = 0.855-0.970) were an independent risk factor for empirical antifungal therapy. The most important risk factors for ICU-AF are the six time-related features of clinical parameters (arterial catheter, enteral nutrition, corticosteroids, broadspectrum antibiotics, urinary catheter, and invasive mechanical ventilation), which provide early warning for the occurrence of fungal infection. Furthermore, this model can help ICU physicians to assess whether empiric antifungal therapy should be administered to ICU patients who are susceptible to fungal infections.