Documentation ¶
Overview ¶
Package cart implement the Classification and Regression Tree by Breiman, et al. CART is binary decision tree.
Breiman, Leo, et al. Classification and regression trees. CRC press, 1984.
The implementation is based on Data Mining book,
Han, Jiawei, Micheline Kamber, and Jian Pei. Data mining: concepts and techniques: concepts and techniques. Elsevier, 2011.
Index ¶
- Constants
- type Input
- func (in *Input) Build(D *dataset.Reader) (e error)
- func (in *Input) Classify(data dsv.Row) (class string)
- func (in *Input) ClassifySet(data *dataset.Reader) (e error)
- func (in *Input) CountOOBError(oob dataset.Reader) (errval float64, e error)
- func (in *Input) SelectRandomFeature(D *dataset.Reader)
- func (in *Input) String() (s string)
- type NodeValue
Constants ¶
View Source
const ( // ColFlagParent denote that the column is parent/split node. ColFlagParent = 1 // ColFlagSkip denote that the column would be skipped. ColFlagSkip = 2 )
View Source
const ( // SplitMethodGini if defined in Input, the dataset will be splitted // using Gini gain for each possible value or partition. // // This option is used in Input.SplitMethod. SplitMethodGini = 0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Input ¶
type Input struct { // SplitMethod define the criteria to used for splitting. SplitMethod int // NRandomFeature if less or equal to zero compute gain on all feature, // otherwise select n random feature and compute gain only on selected // features. NRandomFeature int // OOBErrVal is the last out-of-bag error value in the tree. OOBErrVal float64 // tree in classification. Tree binary.Tree }
Input data for building CART.
func (*Input) ClassifySet ¶
ClassifySet set the class attribute based on tree classification.
func (*Input) CountOOBError ¶
CountOOBError process out-of-bag data on tree and return error value.
func (*Input) SelectRandomFeature ¶
SelectRandomFeature if NRandomFeature is greater than zero, select and compute gain in n random features instead of in all features
type NodeValue ¶
type NodeValue struct { // Class of leaf node. Class string // SplitAttrName define the name of attribute which cause the split. SplitAttrName string // IsLeaf define whether node is a leaf or not. IsLeaf bool // IsContinu define whether the node split is continuous or discrete. IsContinu bool // Size define number of sample that this node hold before splitting. Size int // SplitAttrIdx define the attribute which cause the split. SplitAttrIdx int // SplitV define the split value. SplitV interface{} }
NodeValue of tree in CART.
Click to show internal directories.
Click to hide internal directories.