Loneliness and social isolation are subjective measures associated with the feeling of discomfort and distress. Various factors associated with the feeling of loneliness or social isolation are: the built environment, long-term illnesses, the presence of disabilities or health problems, etc. One of the most important aspect which could impact feelings of loneliness is mobility. In this paper, we present a machine-learning based approach to classify the user loneliness levels using their indoor and outdoor mobility patterns. User mobility data has been collected based on indoor and outdoor sensors carried on by volunteers frequenting an elderly nursing house in Tampere region, Finland. The data was collected using Pozyx sensor for indoor data and Pico minifinder sensor for outdoor data. Mobility patterns such as the distance traveled indoors and outdoors, indoor and outdoor estimated speed, and frequently visited clusters were the most relevant features for classifying the user’s perceived loneliness levels.Three types of data used for classification task were indoor data, outdoor data and combined indoor-outdoor data. Indoor data consisted of indoor mobility data and statistical features from accelerometer data, outdoor data consisted of outdoor mobility data and other parameters such as speed recorded from sensors and course of a person whereas combined indoor-outdoor data had common mobility features from both indoor and outdoor data. We found that the machine-learning model based on XGBoost algorithm achieved the highest performance with accuracy between 90% and 98% for indoor, outdoor, and combined indoor-outdoor data. We also found that Lubben-scale based labelling of perceived loneliness works better for both indoor and outdoor data, whereas UCLA scale-based labelling works better with combined indoor-outdoor data.