cnPredict-method | R Documentation |
Predicts the 'not-available' elements in an incomplete sample.
cnPredict(object, data)
object |
a |
data |
a data |
Data
should be a matrix or data frame of categorical values or indices. If it is a matrix then the rows should represent object
's nodes; otherwise, the columns represent the nodes. Data
's values represent object
's categories either as characters or indices.
Indices should be integers in the range from 1 to the number of categories of the corresponding node.
Prediction is made for those nodes that are marked as not-available (NA
) in the data and is based on maximum probability criterion. For each data instance, the nodes are traversed in their topological order in object
and the categorical values with the maximum probability are assigned.
An updated sample matrix
N. Balov, P. Salzman
cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=3) ## generate a sample of size 2 and set nodes 8, 9 and 10 as not-available psamples <- matrix(as.integer(1+rbinom(10*2, 2, 0.4)), nrow=10) psamples[8, ] <- rep(NA, 2) psamples[9, ] <- rep(NA, 2) psamples[10, ] <- rep(NA, 2) ## make show sample rows are named after the network's nodes rownames(psamples) <- cnNodes(cnet) ## predict the values of nodes 8, 9 and 10 newsamples <- cnPredict(object=cnet, data=psamples)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.