bpa: Basic Probability Assignment Objects

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/bpa.R

Description

These functions can be used to create, combine and print basic probability assignment objects for classificiation. A Basic Probabilty Assignment is a similar to a probabilty mass function, except that it has an additional mass for the concept for "ignorance".

Usage

1
2
3
bpa(n = 1, setlist = c(1:n, Inf), mlist = c(rep(0, n), 1))
## S3 method for class 'bpa'
print(x, verbose = FALSE, ...)

Arguments

n

The number of distinct values that need to be represented. Usually set to the number of classes in the data.

setlist

A subset of 1:n, indicating those elements that have positive mass. The special value 'Inf' is used to denote the whole set, which is ignorance in dempster-shafer terms.

mlist

The actual masses assigned to the elements in the setlist.

x

The bpa object to be printed.

verbose

If FALSE (default), simply prints out the basic probability assignment. If TRUE, prints a list of all member functions as well.

...

Additional arguments to print method. Not Used.

Details

It should be noted that these functions are fairly simplistic, since they were designed to be fast, and work with classification only. In particular, if you have set-valued elements, the combination function will likely give the wrong answer unless the sets are non-intersecting. For the same reason, belief functions have not been implemented either, since for atomic elements, bpa = belief function.

Value

The bpa function returns a list of functions which can be used to query and / or manipulate the create bpa object.

get.N

Get the number of distinct values represented in the bpa. Usually set to the number of classes.

get.setlist

Get the sets represented in the bpa

get.full.m

Get the masses assigned to each of the elements.

get.focal.elements

Get only those elements that have a positive mass attached to them. Such elements are called the focal elements of the bpa.

get.m

Get the masses attached only to the focal elements, that is the non-zero elements of the mlist.

get.mass

Get the masses attached to certain specified elements of the bpa. The elements are specifed as a vector via the argument s.

assign.bpa

Can be used to re-assign mass to certain specified elements of the bpa. The argument s is the same as the setlist, and m is the same as mlist.

get.assigned.class

Returns a vector of all possible classes, in decreasing order of assigned probabilty. (That is, the first element is the most likely class, and the last element is the least likely class.)

get.assigned.ratios

Returns a vector of length N-1, each of whose elements is the ratio of the probability assigned to the successive classes. That is, the first element is the ratio of the probability assigned to the most likely class to that assigned to the next most likely class, and so on.

set.name

Can be passed a string to name the bpa object. (Used by the bpamat function; names are set to the row number.)

get.name

Returns the name of the bpa object. If not assigned, returns NULL.

set.info

Can be used to store as auxiliary information. (Used internally by the bpamat function to store the random seed, or the special character 'C' if the bpa object resulted from a combination.)

get.info

Returns whatever was stored as info. If empty, NULL is returned.

Author(s)

Mohit Dayal

References

Gordon, J. and Shortliffe, E. H. (1984). The dempster-shafer theory of evidence. Rule-Based Expert Systems: The MYCIN Experiments of the Stanford Heuristic Programming Project, 3:832-838. Shafer, G. (1986). The combination of evidence. International Journal of Intelligent Systems, 1(3):155-179.

See Also

combine.bpa.bs, combine.bpa.ds, combine.bpa.list.ds, combine.bpa.list.ds

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
##Empty bpa - All mass is attached to ignorance
b1 <- bpa(3)
b1

##Add a set to this bpa
b1$assign.bpa(s = c(1,2), m = c(0.3,0.4))
print(b1, verbose = TRUE)

##The same thing in a different way - classes can be named
##Note that the print method omits empty classes
b0 <- bpa(3, c('A','B','C', Inf), c(0.3, 0.4, 0, 0.3))
b0

##Another bpa
##Again, class '2' has been omitted
b2 <- bpa(3)
b2$assign.bpa(s = c(1,3), m = c(0.7,0.1))
b2

##Combine
b3 <- combine.bpa.ds(b1,b2)
b3
combine.bpa.bs(b1,b2)

##As a list, should be same answer as above
b4 <- combine.bpa.list.ds(list(b1,b2))
b4
combine.bpa.list.bs(list(b1,b2))

Example output

Warning message:
no DISPLAY variable so Tk is not available 
A bpa object. 
Inf 
  1 
A bpa object. 
  1   2 Inf 
0.3 0.4 0.3 
The following functions are available:
 [1] "get.N"               "get.setlist"         "get.full.m"         
 [4] "get.focal.elements"  "get.m"               "get.mass"           
 [7] "assign.bpa"          "get.assigned.class"  "get.assigned.ratios"
[10] "set.name"            "get.name"            "set.info"           
[13] "get.info"           
A bpa object. 
  A   B Inf 
0.3 0.4 0.3 
A bpa object. 
  1   3 Inf 
0.7 0.1 0.2 
A bpa object. 
   1    2    3  Inf 
0.48 0.08 0.03 0.41 
A bpa object. 
        1       Inf 
0.7777778 0.2222222 
A bpa object. 
   1    2    3  Inf 
0.48 0.08 0.03 0.41 
A bpa object. 
        1       Inf 
0.7777778 0.2222222 

MuViCP documentation built on May 1, 2019, 7:56 p.m.