yobx.sklearn.kernel_approximation.nystroem#

yobx.sklearn.kernel_approximation.nystroem.sklearn_nystroem(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: Nystroem, X: str, name: str = 'nystroem') str[source]#

Converts a sklearn.kernel_approximation.Nystroem into ONNX.

The out-of-sample transform replicates sklearn.kernel_approximation.Nystroem.transform():

  1. Compute the pairwise kernel matrix between X (shape (N, F)) and the stored components components_ (shape (C, F)):

    • linearK = X @ components_.T

    • rbfK[i,j] = exp(-gamma * ||X[i] - components_[j]||^2)

    • polyK = (gamma * X @ components_.T + coef0) ^ degree

    • sigmoidK = tanh(gamma * X @ components_.T + coef0)

    • cosineK[i,j] = (X[i]/||X[i]||) * (components_[j]/||components_[j]||)

    Callable and precomputed kernels are not supported.

  2. Project using the normalization matrix stored in normalization_:

    result = K @ normalization_.T     # (N, C)
    
Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes defined by scikit-learn

  • estimator – a fitted Nystroem

  • outputs – desired output names (transformed inputs)

  • X – input tensor name

  • name – prefix name for the added nodes

Returns:

output tensor name

Raises:

NotImplementedError – for callable kernels, kernel='precomputed', or unsupported kernel names