The combination of imitation and exploration strategies is used in this paper to transfer sensory-motor skills to robotic platforms. The aim is to be able to learn very different tasks with good generalization capabilities and starting from a few demonstrations. This goal is achieved by learning a task-parameterized model from demonstrations where a teacher shows the task corresponding to different possible values of preassigned parameters. In this manner, new reproductions can be generated for new situations by assigning new values to the parameters, thus achieving very precise generalization capabilities. In this paper we propose a novel algorithm that is able to learn the model together with its dependence from the task-parameters, without specifying a predefined relationship or structure. The algorithm is able to learn the model starting from a few demonstrations by applying an exploration strategy that refines the learnt model autonomously. The algorithm is tested on a reaching task performed with a Barrett WAM manipulator.