Code and data for "Bayesian analogy with relational transformations" (Lu, Chen, & Holyoak, 2012, Psych Review).
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE.txt
README.md
analogy_importance_mapping.m
analogy_test_OppC.m
analogy_test_OppR.m
analogy_test_OppS.m
analogy_test_SameO.m
analogy_test_SameOE.m
analogy_test_all.m
bayes_logit_fit_nonzero_mean.m
compute_score.m
create_emp_prior.m
create_emp_prior_HL.m
data_animals_leuven_all.mat
data_animals_leuven_fierceness.mat
data_animals_leuven_intelligence.mat
data_animals_leuven_size.mat
data_animals_leuven_speed.mat
data_animals_ratings_all.mat
data_animals_ratings_fierceness.mat
data_animals_ratings_intelligence.mat
data_animals_ratings_size.mat
data_animals_ratings_speed.mat
data_animals_topics_all.mat
data_animals_topics_fierceness.mat
data_animals_topics_intelligence.mat
data_animals_topics_size.mat
data_animals_topics_speed.mat
data_leuven_dim_means.mat
data_ratings_dim_means.mat
data_topics_dim_means.mat
evaluate_relation.asv
evaluate_relation.m
gen_learn_curve.m
get_relation_name.m
kldistnormmatrix.m
learn_all_predicates.m
learn_test_relations.m
log_prediction.m
logdet.m
reverse_roles_mu.m
reverse_roles_sigma.asv
reverse_roles_sigma.m
train_batch.m
variational_updates_t.m
variational_updates_t_sum.m

README.md

Overview

This is the code and data for "Bayesian analogy with relational transformations" (Lu, Chen, & Holyoak, 2012, Psych Review). You can download the paper here. This version of the code includes the basic relation learning model and the importance-guided mapping algorithm for solving analogy problems. Code for the distance effect and the extra simulations involving test items that go beyond the training data in various ways (e.g., containing different animals) are not included.

Main Files

The following three files are the main programs to run to test the model:

  • learn_test_relations.m: This program trains the model on comparative relations and evaluates its generalization performance. Many parameters can be set at the top of this file, for example, which input (ratings, Leuven, or topics) to use, whether to run BART or the baseline model, the number of training examples to use, etc. The generalization results are saved in the results/<input>/generalization folder, and the resulting relational representations are saved in the results/<input>/matrices folder (see Directory Structure below for more details).

  • analogy_test_all.m: Once learn_test_relations.m has been run to generate the appropriate relational representations, this program can be run to test all the analogy types using those relational representations. Many parameters can be changed in this file as well. In particular, controlindx can be used to control how much information about the relational representations (all means, variances, and covariances, only means and variances, or only means) to use.

  • gen_learn_curve.m: This program is for conveniently generating learning curves or running many simulations at once.

Other Files

Some info about the other files:

  • data*.mat files: Input files for ratings, Leuven, and topics.

  • learn_all_predicates.m: Learns representations for the single-place predicates (large, small, etc.).

  • create_emp_prior.m: Uses the training data for a comparative relation to select a single-place predidicate to construct the empirical prior for that relation.

  • evaluate_relation.m: Evaluates generalization performance on a relation, calculating absolute accuracy, relative accuracy, and Az.

  • analogy_test_*.m: Tests each type of analogy problem.

  • analogy_importance_mapping.m: Uses importance-guided mapping to compute the analogical distance of a single four-term analogy.

Directory Structure

The outputs are saved in the results/<input>/ directory, where <input> is ratings, leuven, or topics. Each input directory has the same structure:

results
    |__ <input>
            |__ analogy
            |       |__ BART
            |       |__ baseline
            |
            |__ generalization
            |       |__ BART
            |       |__ baseline
            |
            |__ matrices
                    |__ predicates
                    |__ relations
                            |__ BART
                            |__ baseline

The predicates folder under matrices contains the learned predicate representations, whereas the relations folder contains the learned relational representations.