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

Method to_minimize

machine_learning/support_vector_machines.py:130–151  ·  view source on GitHub ↗

Opposite of the function to maximize Args: candidate (ndarray): candidate array to test Return: float: Wolfe's Dual result to minimize

(candidate: ndarray)

Source from the content-addressed store, hash-verified

128 (n,) = np.shape(classes)
129
130 def to_minimize(candidate: ndarray) -> float:
131 """
132 Opposite of the function to maximize
133
134 Args:
135 candidate (ndarray): candidate array to test
136
137 Return:
138 float: Wolfe's Dual result to minimize
139 """
140 s = 0
141 (n,) = np.shape(candidate)
142 for i in range(n):
143 for j in range(n):
144 s += (
145 candidate[i]
146 * candidate[j]
147 * classes[i]
148 * classes[j]
149 * self.kernel(observations[i], observations[j])
150 )
151 return 1 / 2 * s - sum(candidate)
152
153 ly_contraint = LinearConstraint(classes, 0, 0)
154 l_bounds = Bounds(0, self.regularization)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected