Patients with chronic liver disease progressed to compensated advanced chronic liver disease (cACLD), the risk of liver-related decompensation increased significantly. This study aimed to develop prediction model based on individual bile acid (BA) profiles to identify cACLD. This study prospectively recruited 159 patients with hepatitis B virus (HBV) infection and 60 healthy volunteers undergoing liver stiffness measurement (LSM). With the value of LSM, patients were categorized as three groups: F1 [LSM ≤ 7.0 kilopascals (kPa)], F2 (7.1 < LSM ≤ 8.0 kPa), and cACLD group (LSM ≥ 8.1 kPa). Random forest (RF) and support vector machine (SVM) were applied to develop two classification models to distinguish patients with different degrees of fibrosis. The content of individual BA in the serum increased significantly with the degree of fibrosis, especially glycine-conjugated BA and taurine-conjugated BA. The Marco-Precise, Marco-Recall, and Marco-F1 score of the optimized RF model were all 0.82. For the optimized SVM model, corresponding score were 0.86, 0.84, and 0.85, respectively. RF and SVM models were applied to identify individual BA features that successfully distinguish patients with cACLD caused by HBV. This study provides a new tool for identifying cACLD that can enable clinicians to better manage patients with chronic liver disease.