mirror of
https://github.com/sjwhitworth/golearn.git
synced 2025-04-26 13:49:14 +08:00
if block ends with a return statement -> drop this else and outdent its block
This commit is contained in:
parent
daac7a278d
commit
32f36f28c3
@ -15,9 +15,8 @@ func NewCranberra() *Cranberra {
|
||||
func cranberraDistanceStep(num float64, denom float64) float64 {
|
||||
if num == .0 && denom == .0 {
|
||||
return .0
|
||||
} else {
|
||||
return num / denom
|
||||
}
|
||||
return num / denom
|
||||
}
|
||||
|
||||
func (self *Cranberra) Distance(vectorX *mat64.Dense, vectorY *mat64.Dense) float64 {
|
||||
|
22
trees/id3.go
22
trees/id3.go
@ -156,18 +156,18 @@ func (d *DecisionTreeNode) Prune(using *base.Instances) {
|
||||
// If you're a leaf, you're already pruned
|
||||
if d.Children == nil {
|
||||
return
|
||||
} else {
|
||||
if d.SplitAttr == nil {
|
||||
return
|
||||
}
|
||||
// Recursively prune children of this node
|
||||
sub := using.DecomposeOnAttributeValues(d.SplitAttr)
|
||||
for k := range d.Children {
|
||||
if sub[k] == nil {
|
||||
continue
|
||||
}
|
||||
d.Children[k].Prune(sub[k])
|
||||
}
|
||||
if d.SplitAttr == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Recursively prune children of this node
|
||||
sub := using.DecomposeOnAttributeValues(d.SplitAttr)
|
||||
for k := range d.Children {
|
||||
if sub[k] == nil {
|
||||
continue
|
||||
}
|
||||
d.Children[k].Prune(sub[k])
|
||||
}
|
||||
|
||||
// Get a baseline accuracy
|
||||
|
Loading…
x
Reference in New Issue
Block a user