A model for learning structured representations of similarity and relative magnitude from experience