The classification of crude oils plays an important role in the petroleum transportation and production. In this paper, terahertz time-domain spectroscopy (THz-TDS) is used to assess seven various crude oils combined with machine-learning algorithms. From THz-TDS, frequency, refractive index and absorption coefficient are used to set models, which are based on Extreme Gradient Boosting (XGBoost), Random Forest (RF) and K-Nearest Neighbors (KNN), respectively. In order to evaluate the accuracy of each model, the confusion matrix and the Area under the curve (AUC) are introduced to access the classification ability, and 5-fold cross-validation are used to compare the generalization ability and robustness. Compared to other models, the classification accuracy of XGBoost reaches the maximum 0.9622. Meanwhile, the test 5-fold cross-validation F1-score and the AUC of XGBoost model are higher than other models, which indicates the high consistency and robustness. Experimental results suggests that terahertz time-domain spectroscopy may be a powerful tool for the identification of various crude oils.