Choose first alpha Steps: 1: First loop over all samples 2: Second loop over all non-bound samples until no non-bound samples violate the KKT condition. 3: Repeat these two processes until no samples violate the KKT condition
(self)
| 224 | return loci |
| 225 | |
| 226 | def _choose_a1(self): |
| 227 | """ |
| 228 | Choose first alpha |
| 229 | Steps: |
| 230 | 1: First loop over all samples |
| 231 | 2: Second loop over all non-bound samples until no non-bound samples violate |
| 232 | the KKT condition. |
| 233 | 3: Repeat these two processes until no samples violate the KKT condition |
| 234 | after the first loop. |
| 235 | """ |
| 236 | while True: |
| 237 | all_not_obey = True |
| 238 | # all sample |
| 239 | print("Scanning all samples!") |
| 240 | for i1 in [i for i in self._all_samples if self._check_obey_kkt(i)]: |
| 241 | all_not_obey = False |
| 242 | yield from self._choose_a2(i1) |
| 243 | |
| 244 | # non-bound sample |
| 245 | print("Scanning non-bound samples!") |
| 246 | while True: |
| 247 | not_obey = True |
| 248 | for i1 in [ |
| 249 | i |
| 250 | for i in self._all_samples |
| 251 | if self._check_obey_kkt(i) and self._is_unbound(i) |
| 252 | ]: |
| 253 | not_obey = False |
| 254 | yield from self._choose_a2(i1) |
| 255 | if not_obey: |
| 256 | print("All non-bound samples satisfy the KKT condition!") |
| 257 | break |
| 258 | if all_not_obey: |
| 259 | print("All samples satisfy the KKT condition!") |
| 260 | break |
| 261 | return False |
| 262 | |
| 263 | def _choose_a2(self, i1): |
| 264 | """ |
no test coverage detected