MCPcopy Index your code
hub / github.com/datastream/libsvm / kernel_function

Method kernel_function

svm.go:171–185  ·  view source on GitHub ↗
(i, j int)

Source from the content-addressed store, hash-verified

169}
170
171func (this *Kernel) kernel_function(i, j int) float64 {
172 switch this.kernel_type {
173 case LINEAR:
174 return dot(this.x[i], this.x[j])
175 case POLY:
176 return powi(this.gamma*dot(this.x[i], this.x[j])+this.coef0, this.degree)
177 case RBF:
178 return math.Exp(-this.gamma * (this.x_square[i] + this.x_square[j] - 2*dot(this.x[i], this.x[j])))
179 case SIGMOID:
180 return math.Tanh(this.gamma*dot(this.x[i], this.x[j]) + this.coef0)
181 case PRECOMPUTED:
182 return this.x[i][int(this.x[j][0].value)].value
183 }
184 return 0
185}
186
187func NewKernel(l int, x_ [][]SVM_Node, param *SVM_Parameter) *Kernel {
188 this := new(Kernel)

Callers 6

NewSVC_QFunction · 0.80
get_QMethod · 0.80
NewONE_CLASS_QFunction · 0.80
get_QMethod · 0.80
NewSVR_QFunction · 0.80
get_QMethod · 0.80

Calls 2

dotFunction · 0.85
powiFunction · 0.85

Tested by

no test coverage detected