gini

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2016 License: BSD-3-Clause Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindMaxGain

func FindMaxGain(gains *[]Gini) (MaxGainIdx int)

FindMaxGain find the attribute and value that have the maximum gain. The returned value is index of attribute.

func FindMinGiniIndex

func FindMinGiniIndex(ginis *[]Gini) (MinIndexIdx int)

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

func (gini *Gini) ComputeContinu(A *[]float64, T *[]string, C *[]string)

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

func (gini *Gini) ComputeDiscrete(A *[]string, discval *[]string, T *[]string,
	C *[]string)

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

func (gini *Gini) GetMaxGainValue() float64

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

func (gini *Gini) GetMinIndexValue() float64

GetMinIndexValue return the minimum Gini index value.

func (Gini) String

func (gini Gini) String() (s string)

String yes, it will print it JSON like format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL