# NOT RUN {
# Rescorla-Wagner
data(lexample)
lexample$Cues <- orthoCoding(lexample$Word, grams=1)
lexample.rw <- RescorlaWagner(lexample, nruns=25, traceCue="h",
traceOutcome="hand")
plot(lexample.rw)
mtext("h - hand", 3, 1)
data(numbers)
traceCues <- c( "exactly1", "exactly2", "exactly3", "exactly4", "exactly5",
"exactly6", "exactly7", "exactly10", "exactly15")
traceOutcomes <- c("1", "2", "3", "4", "5", "6", "7", "10", "15")
ylimit <- c(0,1)
par(mfrow=c(3,3), mar=c(4,4,1,1))
for (i in 1:length(traceCues)) {
numbers.rw <- RescorlaWagner(numbers, nruns=1, traceCue=traceCues[i],
traceOutcome=traceOutcomes[i])
plot(numbers.rw, ylimit=ylimit)
mtext(paste(traceCues[i], " - ", traceOutcomes[i], sep=""), side=3, line=-1,
cex=0.7)
}
par(mfrow=c(1,1))
# naive discriminative learning (for complete example, see serbianLex)
# This function uses a Unicode dataset.
data(serbianUniCyr)
serbianUniCyr$Cues <- orthoCoding(serbianUniCyr$WordForm, grams=2)
serbianUniCyr$Outcomes <- serbianUniCyr$LemmaCase
sw <- estimateWeights(cuesOutcomes=serbianUniCyr,hasUnicode=T)
desiredItems <- unique(serbianUniCyr["Cues"])
desiredItems$Outcomes=""
activations <- estimateActivations(desiredItems, sw)$activationMatrix
rownames(activations) <- unique(serbianUniCyr[["WordForm"]])
syntax <- c("acc", "dat", "gen", "ins", "loc", "nom", "Pl", "Sg")
activations2 <- activations[,!is.element(colnames(activations), syntax)]
head(rownames(activations2),50)
head(colnames(activations2),8)
image(activations2, xlab="word forms", ylab="meanings", xaxt="n", yaxt="n")
mtext(c("yena", "...", "zvuke"), side=1, line=1, at=c(0, 0.5, 1), adj=c(0,0,1))
mtext(c("yena", "...", "zvuk"), side=2, line=1, at=c(0, 0.5, 1), adj=c(0,0,1))
# naive discriminative classification
data(think)
think.ndl <- ndlClassify(Lexeme ~ Person + Number + Agent + Patient + Register,
data=think)
summary(think.ndl)
plot(think.ndl, values="weights", type="hist", panes="multiple")
plot(think.ndl, values="probabilities", type="density")
# }
Run the code above in your browser using DataLab