Millions of people around the world are affected by liver disease, which can also result in life-threatening illnesses. For patients to have better outcomes and have lower death rates, early detection and precise diagnosis are essential. In the biomedical field, machine learning algorithms have become potent instruments with the potential to predict and diagnose liver illnesses more effectively and economically. This study developed a prediction model that successfully separated individuals with liver disorders from those who did not to investigate the use of machine learning algorithms in the early diagnosis of liver diseases. Extra tree, XGBoost, random forest, CatBoost, LogitBoost, gradient boosting, AdaBoost, and KNN were among the machine learning methods that were evaluated. The extra tree algorithm has been demonstrated to be the most efficient method for early identification of liver disorders, reached 92% accuracy, by comparing its performance with those utilizing oversampling approaches and measuring metrics such as accuracy, precision, recall, and F1-score. Class imbalance problems were reduced because of undersampling, oversampling, and SMOTE techniques. This problem is widespread in many machine learning applications. The outcomes show the prospect of machine learning algorithms in enhancing the detection of liver illness, enabling early intervention, and lowering health care expenses. However, it is important to properly handle issues relating to data protection, ethical issues, and the specific training and knowledge of health care professionals. Overall, this research is a significant step toward creating a more accurate and useful diagnostic tool for liver disease that could help people stay healthy and prevent liver diseases.