yobx.sklearn.preprocessing.kernel_centerer#
- yobx.sklearn.preprocessing.kernel_centerer.sklearn_kernel_centerer(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: KernelCenterer, X: str, name: str = 'kernel_centerer') str[source]#
Converts a
sklearn.preprocessing.KernelCentererinto ONNX.KernelCenterercentres a pre-computed kernel matrixKof shape(N, M)using statistics gathered from the training kernel matrix. The transformation implemented here mirrorssklearn.preprocessing.KernelCenterer.transform():K_pred_cols = K.sum(axis=1, keepdims=True) / n_train → (N, 1) K_centered = K - K_fit_rows_ (broadcast: (N,M) - (M,)) - K_pred_cols (broadcast: (N,M) - (N,1)) + K_fit_all_ (scalar)where:
K_fit_rows_— column means of the training kernel matrix, shape(n_train,), stored as a constant initializer.K_fit_all_— grand mean of the training kernel matrix, scalar.n_train—K_fit_rows_.shape[0], used to compute the per-sample row mean of the prediction kernel matrix.
- Parameters:
g – the graph builder to add nodes to
sts – shapes defined by scikit-learn
outputs – desired output names
estimator – a fitted
KernelCentererX – input tensor name (the kernel matrix
K)name – prefix for added node names
- Returns:
output tensor name