Robot programming by demonstration is a robot programming paradigm in which a human operator directly demonstrates the task to be performed. In this paper, we focus on programming by demonstration of compliant motion tasks, which are tasks that involve contacts between an object manipulated by the robot and the environment in which it operates. Critical issues in this paradigm are to distinguish essential actions from those that are not relevant for the correct execution of the task and to transform this information into a robot-independent representation. Essential actions in compliant motion tasks are the contacts that take place, and therefore, it is important to understand the sequence of contact states that occur during a demonstration, called contact classification or contact segmentation. We propose a contact classification algorithm based on a supervised learning algorithm, in particular on a stochastic gradient boosting algorithm. The approach described in this paper is accurate and does not depend on the geometric model of the objects involved in the demonstration. It neither relies on the kinestatic model of the contact interactions nor on the contact state graph, whose computation is usually of prohibitive complexity even for very simple geometric object models.