MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __rbf

Method __rbf

machine_learning/support_vector_machines.py:85–99  ·  view source on GitHub ↗

RBF: Radial Basis Function Kernel Note: for more information see: https://en.wikipedia.org/wiki/Radial_basis_function_kernel Args: vector1 (ndarray): first vector vector2 (ndarray): second vector) Returns: float: exp

(self, vector1: ndarray, vector2: ndarray)

Source from the content-addressed store, hash-verified

83 return np.dot(vector1, vector2)
84
85 def __rbf(self, vector1: ndarray, vector2: ndarray) -> float:
86 """
87 RBF: Radial Basis Function Kernel
88
89 Note: for more information see:
90 https://en.wikipedia.org/wiki/Radial_basis_function_kernel
91
92 Args:
93 vector1 (ndarray): first vector
94 vector2 (ndarray): second vector)
95
96 Returns:
97 float: exp(-(gamma * norm_squared(vector1 - vector2)))
98 """
99 return np.exp(-(self.gamma * norm_squared(vector1 - vector2)))
100
101 def fit(self, observations: list[ndarray], classes: ndarray) -> None:
102 """

Callers

nothing calls this directly

Calls 1

norm_squaredFunction · 0.85

Tested by

no test coverage detected