Depression, a prevalent psychological disorder, increasingly affects individuals worldwide, leading to severe consequences such as a heightened risk of suicide when left undetected or untreated. Despite its widespread impact, depression often remains inadequately recognized within society, leaving many sufferers without necessary support. In this study, we leveraged machine learning techniques to address this issue, employing nine classifiers to detect depression using sociodemographic and psychosocial factors. Through three experiments utilizing different sampling techniques (SMOTE, SMOTETomek, and SMOTEETT), we identified key features using the SelectKBest method. Remarkably, the Light Gradient Boosting Machine (LightGBM) classifier, when applied with the SMOTEETT sampling technique, exhibited exceptional performance, achieving an accuracy of 0.9912 and outperforming other machine learning classifiers. Our findings underscore the effectiveness of machine learning approaches, particularly LightGBM, in detecting depression, highlighting their potential for early intervention and improved mental health outcomes.