cnPredict: Prediction

Description Usage Arguments Details Value Author(s) Examples

Description

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

Usage

1
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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  cnet <- cnRandomCatnet(numnodes=10, maxpars=3, numcats=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)

sdnet documentation built on May 2, 2019, 12:43 a.m.