本文整理匯總了Golang中github.com/sjwhitworth/golearn/base.CategoricalAttribute.GetValues方法的典型用法代碼示例。如果您正苦於以下問題:Golang CategoricalAttribute.GetValues方法的具體用法?Golang CategoricalAttribute.GetValues怎麽用?Golang CategoricalAttribute.GetValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/sjwhitworth/golearn/base.CategoricalAttribute
的用法示例。
在下文中一共展示了CategoricalAttribute.GetValues方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Fit
// Fit creates n filtered datasets (where n is the number of values
// a CategoricalAttribute can take) and uses them to train the
// underlying classifiers.
func (m *OneVsAllModel) Fit(using base.FixedDataGrid) {
var classAttr *base.CategoricalAttribute
// Do some validation
classAttrs := using.AllClassAttributes()
for _, a := range classAttrs {
if c, ok := a.(*base.CategoricalAttribute); !ok {
panic("Unsupported ClassAttribute type")
} else {
classAttr = c
}
}
attrs := m.generateAttributes(using)
// Find the highest stored value
val := uint64(0)
classVals := classAttr.GetValues()
for _, s := range classVals {
cur := base.UnpackBytesToU64(classAttr.GetSysValFromString(s))
if cur > val {
val = cur
}
}
if val == 0 {
panic("Must have more than one class!")
}
m.maxClassVal = val
// Create individual filtered instances for training
filters := make([]*oneVsAllFilter, val+1)
classifiers := make([]base.Classifier, val+1)
for i := uint64(0); i <= val; i++ {
f := &oneVsAllFilter{
attrs,
classAttr,
i,
}
filters[i] = f
classifiers[i] = m.NewClassifierFunction(classVals[int(i)])
classifiers[i].Fit(base.NewLazilyFilteredInstances(using, f))
}
m.filters = filters
m.classifiers = classifiers
}