Newer
Older
linguistic_assignments / 07_final_assignment / finalAssignment.txt
@David-Elias Kuenstle David-Elias Kuenstle on 23 Feb 2016 6 KB Add instructions for updated final assignment
Grainger et al. (2012) trained baboons to do a lexical decision task, with
food as reward for correct decisions (paper on moodle).

From the perspective of discrimination learning (and prior work on animal
learning), the results are fun but not unexpected.

The words and nonwords used by Grainger and colleagues are available in the
excel file Grainger.Table.S2.xls .

I extracted the data for the first baboon in a separate file (dataDan.txt),
and the next bit of R code (which requires the ndl package and a special
function learnWeights.fnc available in the file learnWeights.R) shows that
just learning on the words and nonwords with a flat distribution already
picks up on the words.

#-------------------------------------------------------------------------

library(ndl)
source("learnWeights.R")        # creates learnWeights.fnc
dat = read.table("dataDan.txt", T, stringsAsFactors=FALSE)
dat$Cues = orthoCoding(dat$String, grams=2)
dat$Frequency=1
dat$Outcomes = dat$Type
# reshuffle order of learning events

# use Danks equilibrium equations 
wD = estimateWeights(dat, alpha=0.1, beta=0.1)
aD = estimateActivations(dat, wD)$activationMatrix
aD = aD[,order(colnames(aD))]
dat$ChoiceD = apply(aD, 1, FUN=function(v){
                   if(v[1]>=v[2]) {
                     return("nonword")
                   } else {
                     return("word")
                   }})
table(dat$Type, dat$ChoiceD)
#         
#          nonword word
#  nonword    7832    0
#  word        116  191




# use RW equations learning event by learning event
# now order becomes important
set.seed(314)
dat = dat[sample(1:nrow(dat)),]
cues = unique(unlist(strsplit(dat$Cues, "_")))
outcomes = unique(unlist(strsplit(dat$Outcomes, "_")))
wRW = learnWeights.fnc(dat, cues, outcomes, alpha=0.1, beta=0.1)
aRW = estimateActivations(dat, wRW)$activationMatrix
aRW = aRW[,order(colnames(aRW))]

dat$ChoiceRW = apply(aRW, 1, FUN=function(v){
                   if(v[1]>=v[2]) {
                     return("nonword")
                   } else {
                     return("word")
                   }})
table(dat$Type, dat$ChoiceRW)
#         
#          nonword word
#  nonword    7832    0
#  word        296   11


#-------------------------------------------------------------------------

With the overwhelming numbers of nonwords in the training data, iterative
learning is not as successful.  Interestingly, Grainger at al. trained
the monkeys in a more subtle (and for the monkeys, more encouraging) way:

   "Words and nonwords were presented randomly in blocks of 100 trials.  The
   100-trial sessions were composed of 25 presentations of a novel word to
   learn, 25 presentations of words randomly selected from already learned
   words, and 50 nonword trials. Each new word was added to the ever-increasing
   pool of already learned words, once responses to that word exceeded 80%
   correct within the preceding session. Thus, in terms of explicit information
   available to the baboons, a word was defined as a string of letters that was
   repeatedly presented, whereas a nonword was rarely repeated. The baboons
   responded by touching one of two shapes shown on the touch screen and were
   given a food reward after a correct response (Fig. 1C) (see the
   supplementary materials for more details)."

Let's create a fictive first block of 100 learning trials.


#-------------------------------------------------------------------------

dat = read.table("dataDan.txt", T, stringsAsFactors=FALSE)
dat$Cues = orthoCoding(dat$String, grams=2)
dat$Frequency=1
dat$Outcomes = dat$Type

set.seed(314)
words = dat[dat$Type=="word",]
nonwords = dat[dat$Type=="nonword",]
words1 = words[sample(1:nrow(words), 50),]
nonwords1 = nonwords[sample(1:nrow(nonwords),50),]
block1 = rbind(words1,nonwords1)
block1 = block1[sample(1:nrow(block1)),]

cues = unique(unlist(strsplit(block1$Cues, "_")))
outcomes = unique(unlist(strsplit(block1$Outcomes, "_")))
block1.w = learnWeights.fnc(datset=block1,cueset=cues, outcomeset=outcomes, 
                            alpha=sqrt(0.001), beta=sqrt(0.001), lambda=1.0)
block1.a = estimateActivations(block1, block1.w)$activationMatrix
block1.a = block1.a[,order(colnames(block1.a))]

block1$Choice = apply(block1.a, 1, FUN=function(v){
                   if(v[1]>=v[2]) {
                     return("nonword")
                   } else {
                     return("word")
                   }})
table(block1$Type, block1$Choice)
#         
#          nonword word
#  nonword      38   12
#  word          1   49


#-------------------------------------------------------------------------

Now, iterative learning fares much better (half of the stimuli are words).
In other words, after this first block, 49 out of 50 words would have been
learned.  Success rates will, of course, vary as we change the random
ordering of learning events.

Your final assignment is to simulate the learning of the six monkeys in the
Grainger et al. experiment.  Try to reconstruct, to the extent possible, the
kind of learning exposure that the six monkeys were given (see the above quote
and the paper itself).

These monkeys learn with different success rates.  Experiment with the values
of alpha, beta, and lambda to see if you can make your simulation model perform
with different success rates. Also investigate to what extent different orders
(and random selections of items) could give rise to different learning
performance.

It is likely that the iterative RW equations will perform at ceiling.
If so, you will want to make learning less effective, perhaps by letting
the monkey make random guesses instead of prediction - other ideas welcomed!

Your final paper should be in the form of a short report, with an abstract, a
statement of the problem, a short reportage of the simulations and results
obtained, and your conclusions about what is most likely to underlie the
different success rates of the baboons.  Also provide a list of references, and
add your R code in an appendix.  Your paper should be roughly APA compliant.

As before, you can make this into a group project if you would like to do so.

The grade for this assignment will have twice the weight of the five preceeding
assignments.