polylearn.kernels.safe_power

polylearn.kernels.safe_power(X, degree=2)[source]

Element-wise power supporting both sparse and dense data.

Parameters:

X : ndarray or sparse

The array whose entries to raise to the power.

degree : int, default: 2

The power to which to raise the elements.

Returns:

X_ret : ndarray or sparse

Same shape as X, but (x_ret)_ij = (x)_ij ^ degree