Bovine brucellosis is a global zoonosis of public health importance. It is an endemic disease in many developing countries including Pakistan. This study aimed to estimate the seroprevalence and molecular detection of bovine brucellosis and to assess the association of potential risk factors with test results. A total of 176 milk and 402 serum samples were collected from cattle and buffaloes in three districts of upper Punjab, Pakistan. Milk samples were investigated using milk ring test (MRT), while sera were tested by Rose–Bengal plate agglutination test (RBPT) and indirect enzyme-linked immunosorbent assay (i-ELISA). Real-time PCR was used for detection of Brucella DNA in investigated samples. Anti-Brucella antibodies were detected in 37 (21.02%) bovine milk samples using MRT and in 66 (16.4%) and 71 (17.7%) bovine sera using RBPT and i-ELISA, respectively. Real-time PCR detected Brucella DNA in 31 (7.71%) from a total of 402 bovine sera and identified as Brucella abortus. Seroprevalence and molecular identification of bovine brucellosis varied in some regions in Pakistan. With the use of machine learning, the association of test results with risk factors including age, animal species/type, herd size, history of abortion, pregnancy status, lactation status, and geographical location was analyzed. Machine learning confirmed a real observation that lactation status was found to be the highest significant factor, while abortion, age, and pregnancy came second in terms of significance. To the authors' best knowledge, this is the first time to use machine learning to assess brucellosis in Pakistan; this is a model that can be applied for other developing countries in the future. The development of control strategies for bovine brucellosis through the implementation of uninterrupted surveillance and interactive extension programs in Pakistan is highly recommended.