MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / predict

Method predict

machine_learning/sequential_minimum_optimization.py:143–159  ·  view source on GitHub ↗
(self, test_samples, classify=True)

Source from the content-addressed store, hash-verified

141
142 # Predict test samples
143 def predict(self, test_samples, classify=True):
144 if test_samples.shape[1] > self.samples.shape[1]:
145 raise ValueError(
146 "Test samples' feature length does not equal to that of train samples"
147 )
148
149 if self._auto_norm:
150 test_samples = self._norm(test_samples)
151
152 results = []
153 for test_sample in test_samples:
154 result = self._predict(test_sample)
155 if classify:
156 results.append(1 if result > 0 else -1)
157 else:
158 results.append(result)
159 return np.array(results)
160
161 # Check if alpha violates the KKT condition
162 def _check_obey_kkt(self, index):

Callers 2

test_cancer_dataFunction · 0.95
plot_partition_boundaryFunction · 0.45

Calls 3

_normMethod · 0.95
_predictMethod · 0.95
appendMethod · 0.45

Tested by 1

test_cancer_dataFunction · 0.76