MCPcopy Index your code
hub / github.com/Dod-o/Statistical-Learning-Method_Code / calcSinglKernel

Method calcSinglKernel

SVM/SVM.py:342–353  ·  view source on GitHub ↗

单独计算核函数 :param x1:向量1 :param x2: 向量2 :return: 核函数结果

(self, x1, x2)

Source from the content-addressed store, hash-verified

340 self.supportVecIndex.append(i)
341
342 def calcSinglKernel(self, x1, x2):
343 '''
344 单独计算核函数
345 :param x1:向量1
346 :param x2: 向量2
347 :return: 核函数结果
348 '''
349 #按照“7.3.3 常用核函数”式7.90计算高斯核
350 result = (x1 - x2) * (x1 - x2).T
351 result = np.exp(-1 * result / (2 * self.sigma ** 2))
352 #返回结果
353 return np.exp(result)
354
355
356 def predict(self, x):

Callers 1

predictMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected