Learning the score under shape constraints