Objective: Mechanical restraint (MR) is used to prevent patients from harming themselves or others during inpatient treatment. The objective of this study was to investigate whether incident MR occurring in the first 3 days following admission could be predicted based on analysis of electronic health data available after the first hour of admission. Methods: The dataset consisted of clinical notes from electronic health records from the Central Denmark Region and data from the Danish Health Registers from patients admitted to a psychiatric department in the period from 2011 to 2015. Supervised machine learning algorithms were trained on a randomly selected subset of the data and validated using an independent test dataset. Results: A total of 5050 patients with 8869 admissions were included in the study. One hundred patients were mechanically restrained in the period between one hour and 3 days after the admission. A Random Forest algorithm predicted MR with an area under the curve of 0.87 (95% CI 0.79–0.93). At 94% specificity, the sensitivity was 56%. Among the ten strongest predictors, nine were derived from the clinical notes. Conclusions: These findings open for the development of an early warning system that may guide interventions to reduce the use of MR.