Welfare assessment of dairy cows by in-person farm visits provides only a snapshot of welfare and is time-consuming and costly. Possible solutions to reduce the need for in-person assessments would be to exploit sensor data and other routinely collected on-farm records. The aim of this study was to develop an algorithm to classify dairy cow welfare based on sensors (accelerometer and/or milk meter) and farm records (e.g. days in milk, lactation number). In total, 318 cows from six commercial farms located in Finland, Italy and Spain (two farms each) were enrolled for a pilot study lasting 135 days. During this time, cows were routinely scored using 14 animal-based measures of good feeding, health and housing based on the Welfare Quality® (WQ®) protocol. WQ® measures were evaluated daily or approximately every 45 days, using disease treatments from farm records and on-farm visits, respectively. WQ® measures were supplemented with daily temperature-humidity index to account for heat stress. The severity and duration of each welfare measure were evaluated, and the final welfare index was obtained by summing up the values for each cow on each pilot study day, and stratifying the result into three classes: good, moderate and poor welfare. For model building, a machine-learning (ML) algorithm based on gradient-boosted trees (XGBoost) was applied. Two model versions were tested: (1) a global model tested on unseen herd, and (2) a herd-specific model tested on unseen part of the data from the same herd. The version (1) served as an example on the model performance on a herd not previsited by the evaluator, while version (2) resembled a custom-made solution requiring in-person welfare evaluation for model training. Our results indicated that the global model had a low performance with average sensitivity and specificity of 0.44 and 0.68, respectively. For the herd-specific version, the model performance was higher reaching an average of 0.64 sensitivity and 0.80 specificity. The highest classification performance was obtained for cows in poor welfare, followed by cows in good and moderate welfare (balanced accuracy of 0.77, 0.71 and 0.68, respectively). Since the global model had low classification accuracy, the use of the developed model as a stand-alone system based solely on sensor data is infeasible, and a combination of in-person and sensor-based welfare evaluation would be preferable for a reliable welfare assessment. ML-based solutions, even with fair discriminative abilities, have the potential to enhance dairy welfare monitoring.