Liver disease can cause death in millions of individuals worldwide. Early detection and accurate diagnosis improve patient outcomes and reduce mortality. Machine learning algorithms can detect and diagnose liver diseases more accurately and affordably. To test machine learning methods for early liver disease diagnosis, this study created a prediction model that distinguished those with liver illnesses from those without. Machine learning algorithms studied included Extra Tree, XGBoost, Random Forest, CatBoost, LogitBoost, Gradient Boosting, AdaBoost, and KNN. By using oversampling methodologies and assessing metrics like accuracy, recall, precision, and F1-score, the Extra Tree algorithm was found to be the most effective way for early liver problem detection with 99% accuracy. Undersampling, oversampling, and SMOTE reduced class imbalance. This problem is widespread in many machine learning applications. Machine learning algorithms may improve liver disease detection, early intervention, and healthcare costs. However, data protection, ethics, and healthcare professional training and understanding must be adequately addressed. This research is a major step toward a more accurate and practical liver disease diagnostic tool that could help individuals stay healthy and prevent liver illnesses.