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(A *[]float64, T *[]string, C *[]string)
- func (gini *Gini) ComputeDiscrete(A *[]string, discval *[]string, T *[]string, C *[]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 tekstus.TableStrings // 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 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.
func (*Gini) ComputeDiscrete ¶
ComputeDiscrete Given an attribute A with discreate value 'discval', and the target attribute T which contain N classes in C, compute the information gain of A.
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.