Documentation ¶
Overview ¶
Package gini contain function to calculating Gini gain.
Gini gain, which is an impurity-based criterion that measures the divergences between the probability distribution of the target attributes' values.
Index ¶
- func FindMaxGain(gains *[]Gini) (maxGainIdx int)
- func FindMinGiniIndex(ginis *[]Gini) (minIndexIdx int)
- type Gini
- func (gini *Gini) ComputeContinu(src *[]float64, target, classes *[]string)
- func (gini *Gini) ComputeContinuFloat(src, target, classes *[]float64)
- func (gini *Gini) ComputeDiscrete(src, discval, target, classes *[]string)
- func (gini *Gini) GetMaxGainValue() float64
- func (gini *Gini) GetMaxPartGainValue() interface{}
- func (gini *Gini) GetMinIndexPartValue() interface{}
- func (gini *Gini) GetMinIndexValue() float64
- func (gini Gini) String() (s string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindMaxGain ¶
FindMaxGain find the attribute and value that have the maximum gain. The returned value is index of attribute.
func FindMinGiniIndex ¶
FindMinGiniIndex return the index of attribute that have the minimum Gini index.
Types ¶
type Gini ¶
type Gini struct { // Skip if its true, the gain value would not be searched on this // instance. Skip bool // IsContinue define whether the Gini index came from continuous // attribute or not. IsContinu bool // Value of Gini index for all value in attribute. Value float64 // MaxPartGain contain the index of partition which have the maximum // gain. MaxPartGain int // MaxGainValue contain maximum gain of index. MaxGainValue float64 // MinIndexPart contain the index of partition which have the minimum // Gini index. MinIndexPart int // MinIndexGini contain minimum Gini index value. MinIndexValue float64 // SortedIndex of attribute, sorted by values of attribute. This will // be used to reference the unsorted target attribute. SortedIndex []int // ContinuPart contain list of partition value for continuous attribute. ContinuPart []float64 // DiscretePart contain the possible combination of discrete values. DiscretePart libstrings.Table // Index contain list of Gini Index for each partition. Index []float64 // Gain contain information gain for each partition. Gain []float64 }
Gini contain slice of sorted index, slice of partition values, slice of Gini index, Gini value for all samples.
func (*Gini) ComputeContinu ¶
ComputeContinu Given an attribute "src" and the target attribute "target" which contain n classes, compute the information gain of "src".
The result of Gini partitions value, Gini Index, and Gini Gain is saved in ContinuPart, Index, and Gain.
func (*Gini) ComputeContinuFloat ¶
ComputeContinuFloat Given an attribute A and the target attribute T which contain N classes in C, compute the information gain of A.
The result of Gini partitions value, Gini Index, and Gini Gain is saved in ContinuPart, Index, and Gain.
Algorithm, (0) Sort the attribute. (1) Sort the target attribute using sorted index. (2) Create continu partition. (3) Create temporary space for gini index and gini gain. (4) Compute gini index for all target.
func (*Gini) ComputeDiscrete ¶
ComputeDiscrete Given an attribute "src" with discrete value 'discval', and the target attribute "target" which contain n classes, compute the information gain of "src".
The result is saved as gain value in MaxGainValue for each partition.
func (*Gini) GetMaxGainValue ¶
GetMaxGainValue return the value of partition which contain the maximum Gini gain.
func (*Gini) GetMaxPartGainValue ¶
func (gini *Gini) GetMaxPartGainValue() interface{}
GetMaxPartGainValue return the partition that have the maximum Gini gain.
func (*Gini) GetMinIndexPartValue ¶
func (gini *Gini) GetMinIndexPartValue() interface{}
GetMinIndexPartValue return the partition that have the minimum Gini index.
func (*Gini) GetMinIndexValue ¶
GetMinIndexValue return the minimum Gini index value.