In the fourth emph{Fermi} Large Area Telescope source catalog (4FGL), 5064 $gamma$-ray sources are reported, including 3207 active galactic nuclei (AGNs), 239 pulsars, 1336 unassociated sources, 92 sources with weak association with blazar at low Galactic latitude and 190 other sources. We employ two different supervised machine learning classifiers, combined with the direct observation parameters given by the 4FGL fits table, to search for sources potentially classified as AGNs and pulsars in the 1336 unassociated sources. In order to reduce the error caused by the large difference in the sizes of samples, we divide the classification process into two separate steps in order to identify the AGNs and the pulsars. First, we select the identified AGNs from all of the samples, and then select the identified pulsars from the remaining. Using the 4FGL sources associated or identified as AGNs, pulsars, and other sources with the features selected through the K-S test and the random forest (RF) feature importance measurement, we trained, optimized, and tested our classifier models. Then, the models are applied to classify the 1336 unassociated sources. According to the calculation results of the two classifiers, we show the sensitivity, specificity, accuracy in each step, and the class of unassociated sources given by each classifier. The accuracy obtained in the first step is approximately $95%$; in the second step, the obtained overall accuracy is approximately $80%$. Combining the results of the two classifiers, we predict that there are 583 AGN-type candidates, 115 pulsar-type candidates, 154 other types of $gamma$-ray candidates, and 484 of uncertain types.