Predict multi-class targets using underlying estimators. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) Data. Returns ------- y : ndarray of shape (n_samples,) Predicted multi-class targ
(self, X)
| 1238 | return self |
| 1239 | |
| 1240 | def predict(self, X): |
| 1241 | """Predict multi-class targets using underlying estimators. |
| 1242 | |
| 1243 | Parameters |
| 1244 | ---------- |
| 1245 | X : {array-like, sparse matrix} of shape (n_samples, n_features) |
| 1246 | Data. |
| 1247 | |
| 1248 | Returns |
| 1249 | ------- |
| 1250 | y : ndarray of shape (n_samples,) |
| 1251 | Predicted multi-class targets. |
| 1252 | """ |
| 1253 | check_is_fitted(self) |
| 1254 | # ArgKmin only accepts C-contiguous array. The aggregated predictions need to be |
| 1255 | # transposed. We therefore create an F-contiguous array to avoid a copy and have |
| 1256 | # a C-contiguous array after the transpose operation. |
| 1257 | Y = np.array( |
| 1258 | [_predict_binary(e, X) for e in self.estimators_], |
| 1259 | order="F", |
| 1260 | dtype=np.float64, |
| 1261 | ).T |
| 1262 | pred = pairwise_distances_argmin(Y, self.code_book_, metric="euclidean") |
| 1263 | return self.classes_[pred] |
| 1264 | |
| 1265 | def get_metadata_routing(self): |
| 1266 | """Get metadata routing of this object. |