We are privileged for being one of the pioneer projects of the HA Data Collaboration Lab (HADCL), where we have dedicated our efforts to developing innovative machine learning (ML) models for predicting the risk of hepatocellular carcinoma (HCC), one of the most fatal complications of chronic viral hepatitis. Accurate HCC risk prediction plays a crucial role in tailoring surveillance strategies and ultimately reducing cancer-related mortality. Our team has utilised the remarkable real-world dataset from HA to conduct a comprehensive territory-wide study in Hong Kong spanning from 2000 to 2018. This study was based on detailed clinical data, including viral markers, diagnosis codes, and antiviral treatment for chronic viral hepatitis. We rigorously evaluated five cutting-edge ML methods - logistic regression, ridge regression, AdaBoost, decision tree, and random forest - to identify the most effective prediction model. With a dataset comprising 124,006 patients with chronic viral hepatitis and complete information, we embarked on constructing these models. Ridge regression led to consistently good performance in both training and validation cohorts. The low threshold (0.07) of the HCC ridge score (HCC-RS) achieved an impressive 90.0% sensitivity and 98.6% negative predictive value (NPV) in the validation cohort. Alternatively, the high threshold (0.15) of the HCC-RS demonstrated exceptional specificity (90.0%) and NPV (95.6%), leaving only 31.1% of patients in the indeterminate category. In conclusion, the HCC-RS derived from the ridge regression machine-learning model exhibits remarkable accuracy in predicting HCC in patients with chronic viral hepatitis. These ML models could potentially be integrated as essential tools or calculators in electronic health systems to help mitigate cancer-related mortality.