- aoclda.kernel_functions.rbf_kernel()#
Compute the RBF (Radial Basis Function) kernel matrix.
\[K(x, y) = \exp(-\gamma ||x - y||^2)\]If Y is not provided, the RBF kernel is computed between the rows of X, resulting in a matrix of shape (n_samples_X, n_samples_X). Otherwise, it computes the RBF kernel between X and Y, with shape (n_samples_X, n_samples_Y).
- Parameters:
X (array-like) – The feature matrix of shape (n_samples_X, n_features).
Y (array-like, optional) – The optional matrix of shape (n_samples_Y, n_features).
gamma (float, optional) – The kernel coefficient. Has to be greater or equal to 0.
- Returns:
The RBF kernel matrix of shape (n_samples_X, n_samples_X) if Y is None, or (n_samples_X, n_samples_Y) otherwise.
- Return type:
numpy.ndarray
- aoclda.kernel_functions.linear_kernel()#
Compute the linear kernel matrix.
\[K(x, y) = x * y\]If Y is not provided, the linear kernel is computed between the rows of X, resulting in a matrix of shape (n_samples_X, n_samples_X). Otherwise, it computes the linear kernel between X and Y, with shape (n_samples_X, n_samples_Y).
- Parameters:
X (array-like) – The feature matrix of shape (n_samples_X, n_features).
Y (array-like, optional) – The optional matrix of shape (n_samples_Y, n_features).
- Returns:
The linear kernel matrix of shape (n_samples_X, n_samples_X) if Y is None, or (n_samples_X, n_samples_Y) otherwise.
- Return type:
numpy.ndarray
- aoclda.kernel_functions.polynomial_kernel()#
Compute the polynomial kernel matrix.
\[K(x, y) = (\gamma x * y + c)^{d}\]If Y is not provided, the polynomial kernel is computed between the rows of X, resulting in a matrix of shape (n_samples_X, n_samples_X). Otherwise, it computes the polynomial kernel between X and Y, with shape (n_samples_X, n_samples_Y).
- Parameters:
X (array-like) – The feature matrix of shape (n_samples_X, n_features).
Y (array-like, optional) – The optional matrix of shape (n_samples_Y, n_features).
degree (int, optional) – The degree of the polynomial.
gamma (float, optional) – The kernel coefficient. Has to be greater or equal to 0.
coef0 (float, optional) – The independent term in the polynomial kernel.
- Returns:
The polynomial kernel matrix of shape (n_samples_X, n_samples_X) if Y is None, or (n_samples_X, n_samples_Y) otherwise.
- Return type:
numpy.ndarray
- aoclda.kernel_functions.sigmoid_kernel()#
Compute the sigmoid kernel matrix.
\[K(x, y) = \tanh(\gamma x * y + c)\]If Y is not provided, the sigmoid kernel is computed between the rows of X, resulting in a matrix of shape (n_samples_X, n_samples_X). Otherwise, it computes the sigmoid kernel between X and Y, with shape (n_samples_X, n_samples_Y).
- Parameters:
X (array-like) – The feature matrix of shape (n_samples_X, n_features).
Y (array-like, optional) – The optional matrix of shape (n_samples_Y, n_features).
gamma (float, optional) – The kernel coefficient. Has to be greater or equal to 0.
coef0 (float, optional) – The constant factor for the sigmoid kernel.
- Returns:
The sigmoid kernel matrix of shape (n_samples_X, n_samples_X) if Y is None, or (n_samples_X, n_samples_Y) otherwise.
- Return type:
numpy.ndarray
-
da_status da_rbf_kernel_s(da_order order, da_int m, da_int n, da_int k, const float *X, da_int ldx, const float *Y, da_int ldy, float *D, da_int ldd, float gamma)#
-
da_status da_rbf_kernel_d(da_order order, da_int m, da_int n, da_int k, const double *X, da_int ldx, const double *Y, da_int ldy, double *D, da_int ldd, double gamma)#
Compute the RBF (Radial Basis Function) kernel matrix for the matrices
Xand, optionally,Y.This function computes the RBF kernel between the matrix
X(sizem\(\times\)k) andY(sizen\(\times\)k) if provided. IfYis null, the kernel is computed between the rows ofX, ( \(XX^T\)). The results are stored inD.The RBF kernel is given by:
\[ K(x, y) = \exp(-\gamma \|\mathbf{x} - \mathbf{y}\|^2). \]- Parameters:
order – [in] da_order enum specifying column-major or row-major layout.
m – [in] the number of rows of matrix X. Constraint:
m\(\ge\) 1.n – [in] the number of rows of matrix Y. Constraint:
n\(\ge\) 1.k – [in] the number of columns of matrices X and Y. Constraint:
k\(\ge\) 1.X – [in] the matrix of size
m\(\times\)k, stored in column-major order by default.ldx – [in] the leading dimension of
X. Constraint:ldx\(\ge\)miforder=column_major, orldx\(\ge\)kiforder=row_major.Y – [in] the matrix of size
n\(\times\)k, or null if computing the kernel ofXwith itself.ldy – [in] the leading dimension of
Y. Constraint:ldy\(\ge\)niforder=column_major, orldy\(\ge\)kiforder=row_major.D – [out] the resulting kernel matrix of size
m\(\times\)nifYis not null, orm\(\times\)motherwise.ldd – [in] the leading dimension of the matrix
D. Constraint:ldd\(\ge\)m, ifYis nullptr ororder=column_major, andldd\(\ge\)n, otherwise.gamma – [in] the RBF kernel scale factor. Constraint:
gamma\(\ge\) 0.
- Returns:
da_status_success - operation completed successfully.
da_status_invalid_leading_dimension - one of the constraints on
ldx,ldy, orlddwas violated.da_status_invalid_pointer - one of the input pointers is null.
da_status_invalid_input - one of the arguments had an invalid value.
da_status_invalid_array_dimension - one of the dimensions
m,n, orkis invalid.da_status_memory_error - unable to allocate memory.
-
da_status da_linear_kernel_s(da_order order, da_int m, da_int n, da_int k, const float *X, da_int ldx, const float *Y, da_int ldy, float *D, da_int ldd)#
-
da_status da_linear_kernel_d(da_order order, da_int m, da_int n, da_int k, const double *X, da_int ldx, const double *Y, da_int ldy, double *D, da_int ldd)#
Compute the linear kernel matrix for the matrices
Xand, optionally,Y.This function computes the linear kernel between the rows of
X(sizem\(\times\)k) andY(sizen\(\times\)k) if provided. IfYis null, the kernel is computed between the rows ofX, ( \(XX^T\)). The results are stored inD.The linear kernel is given by:
\[ K(x, y) = x \cdot y. \]- Parameters:
order – [in] da_order enum specifying column-major or row-major layout.
m – [in] the number of rows of matrix X. Constraint:
m\(\ge\) 1.n – [in] the number of rows of matrix Y. Constraint:
n\(\ge\) 1.k – [in] the number of columns of matrices X and Y. Constraint:
k\(\ge\) 1.X – [in] the matrix of size
m\(\times\)k, stored in column-major order by default.ldx – [in] the leading dimension of
X. Constraint:ldx\(\ge\)miforder=column_major, orldx\(\ge\)kiforder=row_major.Y – [in] the matrix of size
n\(\times\)k, or null if computing the kernel ofXwith itself.ldy – [in] the leading dimension of
Y. Constraint:ldy\(\ge\)niforder=column_major, orldy\(\ge\)kiforder=row_major.D – [out] the resulting kernel matrix of size
m\(\times\)nifYis not null, orm\(\times\)motherwise.ldd – [in] the leading dimension of the matrix
D. Constraint:ldd\(\ge\)m, ifYis nullptr ororder=column_major, andldd\(\ge\)n, otherwise.
- Returns:
da_status_success - operation completed successfully.
da_status_invalid_leading_dimension - one of the constraints on
ldx,ldy, orlddwas violated.da_status_invalid_pointer - one of the input pointers is null.
da_status_invalid_array_dimension - one of the dimensions
m,n, orkis invalid.da_status_memory_error - unable to allocate memory.
-
da_status da_polynomial_kernel_s(da_order order, da_int m, da_int n, da_int k, const float *X, da_int ldx, const float *Y, da_int ldy, float *D, da_int ldd, float gamma, da_int degree, float coef0)#
-
da_status da_polynomial_kernel_d(da_order order, da_int m, da_int n, da_int k, const double *X, da_int ldx, const double *Y, da_int ldy, double *D, da_int ldd, double gamma, da_int degree, double coef0)#
Compute the polynomial kernel matrix for the matrices
Xand, optionally,Y.This function computes the polynomial kernel between the rows of
X(sizem\(\times\)k) andY(sizen\(\times\)k) if provided. IfYis null, the kernel is computed between the rows ofX, ( \(XX^T\)). The results are stored inD.The polynomial kernel is given by:
\[ K(x, y) = (\gamma x \cdot y + c)^d. \]- Parameters:
order – [in] da_order enum specifying column-major or row-major layout.
m – [in] the number of rows of matrix X. Constraint:
m\(\ge\) 1.n – [in] the number of rows of matrix Y. Constraint:
n\(\ge\) 1.k – [in] the number of columns of matrices X and Y. Constraint:
k\(\ge\) 1.X – [in] the matrix of size
m\(\times\)k, stored in column-major order by default.ldx – [in] the leading dimension of
X. Constraint:ldx\(\ge\)miforder=column_major, orldx\(\ge\)kiforder=row_major.Y – [in] the matrix of size
n\(\times\)k, or null if computing the kernel ofXwith itself.ldy – [in] the leading dimension of
Y. Constraint:ldy\(\ge\)niforder=column_major, orldy\(\ge\)kiforder=row_major.D – [out] the resulting kernel matrix of size
m\(\times\)nifYis not null, orm\(\times\)motherwise.ldd – [in] the leading dimension of the matrix
D. Constraint:ldd\(\ge\)m, ifYis nullptr ororder=column_major, andldd\(\ge\)n, otherwise.gamma – [in] the scale factor used in polynomial kernel. Constraint:
gamma\(\ge\) 0.degree – [in] the degree of the polynomial kernel. Constraint:
degree\(\ge\) 0.coef0 – [in] the independent term in the polynomial kernel.
- Returns:
da_status_success - operation completed successfully.
da_status_invalid_leading_dimension - one of the constraints on
ldx,ldy, orlddwas violated.da_status_invalid_pointer - one of the input pointers is null.
da_status_invalid_input - one of the arguments had an invalid value.
da_status_invalid_array_dimension - one of the dimensions
m,n, orkis invalid.da_status_memory_error - unable to allocate memory.
-
da_status da_sigmoid_kernel_s(da_order order, da_int m, da_int n, da_int k, const float *X, da_int ldx, const float *Y, da_int ldy, float *D, da_int ldd, float gamma, float coef0)#
-
da_status da_sigmoid_kernel_d(da_order order, da_int m, da_int n, da_int k, const double *X, da_int ldx, const double *Y, da_int ldy, double *D, da_int ldd, double gamma, double coef0)#
Compute the sigmoid kernel matrix for the matrices
Xand, optionally,Y.This function computes the sigmoid kernel between the rows of
X(sizem\(\times\)k) andY(sizen\(\times\)k) if provided. IfYis null, the kernel is computed between the rows ofX, ( \(XX^T\)). The results are stored inD.The sigmoid kernel is given by:
\[ K(x, y) = \tanh(\gamma x \cdot y + c). \]- Parameters:
order – [in] da_order enum specifying column-major or row-major layout.
m – [in] the number of rows of matrix X. Constraint:
m\(\ge\) 1.n – [in] the number of rows of matrix Y. Constraint:
n\(\ge\) 1.k – [in] the number of columns of matrices X and Y. Constraint:
k\(\ge\) 1.X – [in] the matrix of size
m\(\times\)k, stored in column-major order by default.ldx – [in] the leading dimension of
X. Constraint:ldx\(\ge\)miforder=column_major, orldx\(\ge\)kiforder=row_major.Y – [in] the matrix of size
n\(\times\)k, or null if computing the kernel ofXwith itself.ldy – [in] the leading dimension of
Y. Constraint:ldy\(\ge\)niforder=column_major, orldy\(\ge\)kiforder=row_major.D – [out] the resulting kernel matrix of size
m\(\times\)nifYis not null, orm\(\times\)motherwise.ldd – [in] the leading dimension of the matrix
D. Constraint:ldd\(\ge\)m, ifYis nullptr ororder=column_major, andldd\(\ge\)n, otherwise.gamma – [in] the scale factor used in sigmoid kernel. Constraint:
gamma\(\ge\) 0.coef0 – [in] constant term in the sigmoid kernel.
- Returns:
da_status_success - operation completed successfully.
da_status_invalid_leading_dimension - one of the constraints on
ldx,ldy, orlddwas violated.da_status_invalid_pointer - one of the input pointers is null.
da_status_invalid_input - one of the arguments had an invalid value.
da_status_invalid_array_dimension - one of the dimensions
m,n, orkis invalid.da_status_memory_error - unable to allocate memory.