module BC_BDTree: sig end
Binary decision trees
type ('b, 'a) btree =
| |
Leaf of 'a |
(* | a leaf of type 'b | *) |
| |
Node of 'b * ('b, 'a) btree * ('b, 'a) btree |
(* | a node consists of a (parameter for a) decision function of type 'a, and two child nodes | *) |
the type for binary decision trees
val bdtree : ('a, 'b) btree -> ('c -> 'a -> bool) -> 'c -> 'b
bdtree spec matcher creates a function for classification.
spec is the structure of the decision tree, and
matcher is a function for discrimination, using the element of type 'a at the node as a parameter
- 'a : parameter type at node of tree
- 'b : classification class type
- 'c : input type to binary decision tree (data type)
val prune_tree : ('a, 'b) btree -> ('a, 'b) btree
prune useless branches from a tree
val binary_id3 : ?maxdepth:int ->
?scoref:(int -> int -> int -> int -> float) ->
'a list ->
'a list ->
((int -> int -> int -> int -> float) -> 'a list -> 'a list -> 'b) ->
('a -> 'b -> bool) -> ('b, bool) btree
ID3 algorithm (Quinlan, 19??) for binary classes.
arguments in following order:
maxdepth: maximum depth of the tree. If negative, don't care. If positive, subtract 1.
If 0 don't go any further. Default is -1
scoref: score function. Arguments in order of: posmatch, negmatch, postotal, negtotal
pd positive data
nd negative data
bestfinder algorithm for finding the best parameter
('a in Node 'a) given scoref, pd, and nd
matcher interpreter of the parameter
val bdt_to_string : ('a, bool) btree -> ('a -> string) -> string
convert a boolean tree to a string.
the second argument is a function which converts the parameters at the node
to a string
val serialize : ('a, 'b) btree -> ('a -> string) -> ('b -> string) -> string
convert binary decision trees to strings which can be used as
internal representation
- first arg: tree
- second arg: conversion function for parameters at Nodes ('a -> string)
- third arg: conversion function for Leaves ('b -> string)
val entropy_gain : int -> int -> int -> int -> float
entropy gain score function: for ID3