单独计算核函数 :param x1:向量1 :param x2: 向量2 :return: 核函数结果
(self, x1, x2)
| 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): |