# NOT RUN {
# load example data:
data(dat)
# add obligatory columns Cues, Outcomes, and Frequency:
dat <- droplevels(dat[1:3,])
dat$Cues <- paste("BG", dat$Shape, dat$Color, sep="_")
dat$Outcomes <- dat$Category
dat$Frequency <- dat$Frequency1
head(dat)
# now use createTrainingData to sample from the specified frequencies:
train <- createTrainingData(dat)
head(train)
# this training data can actually be used train network:
wm <- RWlearning(train)
# retrieve update values for all outcomes:
updates1 <- getUpdate(data=train, wmlist=wm)
head(updates1)
# retrieve update values for observed outcomes:
updates2 <- getUpdate(data=train, wmlist=wm, present.outcome=TRUE)
head(updates2)
# plot:
n <- which("animal" == train$Outcomes)
plot(n, updates2[n], type='l',
ylim=c(0,.1),
ylab="Weight updates", xlab="Learning event")
# }
Run the code above in your browser using DataLab