cnPredict-method {catnet}R Documentation

Prediction

Description

Predicts the 'not-available' elements in an incomplete sample.

Usage

cnPredict(object, data)

Arguments

object

a catNetwork

data

a data matrix or data.frame

Details

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.

Value

An updated sample matrix

Author(s)

N. Balov, P. Salzman

Examples

  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)

[Package catnet version 1.15.7 Index]