Learning rich observation models in factor graphs