Cognitive maps of social features enable flexible inference in social networks