Learn R Programming

edl (version 1.1)

getUpdate: Retrieve the weight updates and their change for each learning event.

Description

For a given set of training data, the weight updating values are returned for each or specific outcomes. The values are returned as data frame.

Usage

getUpdate(
  wmlist,
  data,
  select.outcomes = NULL,
  split = "_",
  present.outcome = FALSE
)

Arguments

wmlist

A list with weightmatrices, generated by RWlearning or updateWeights.

data

Data with columns Cues and Outcomes, as generated with createTrainingData.

select.outcomes

Optional selection of outcomes to limit the number of activations that are returned. The value of NULL (default) will return all activations. Note that specified values that are not in the weightmatrices will return the initial value without error or warning. Please use getValues for returning all outcomes in the data.

split

String, separator between cues or outcomes.

present.outcome

Logical: whether or not to output the update for the present output only. Defaults to FALSE. Note that if set to true, this parameter cancels the effect of select.outcomes.

Value

Data frame.

Examples

Run this code
# 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