adelie.adelie_core.matrix.MatrixNaiveOneHotDense64F#

class adelie.adelie_core.matrix.MatrixNaiveOneHotDense64F#

Core matrix class for naive (dense) one-hot encoded matrix.

Methods

__init__(self, mat, levels, n_threads)

bmul(self, arg0, arg1, arg2, arg3, arg4)

Computes a column block matrix-vector multiplication.

btmul(self, arg0, arg1, arg2, arg3)

Computes a column block matrix transpose-vector multiplication increment.

cmul(self, arg0, arg1, arg2)

Computes a column vector-vector multiplication.

cols(self)

Returns the number of columns.

cov(self, arg0, arg1, arg2, arg3, arg4)

Computes a weighted covariance matrix.

ctmul(self, arg0, arg1, arg2)

Computes a column vector-scalar multiplication increment.

mean(self, arg0, arg1)

Computes the implied column means.

mul(self, arg0, arg1, arg2)

Computes a matrix-vector multiplication.

rows(self)

Returns the number of rows.

sp_tmul(self, arg0, arg1)

Computes a matrix transpose-sparse matrix multiplication.

sq_mul(self, arg0, arg1)

Computes a squared matrix-vector multiplication.

var(self, arg0, arg1, arg2)

Computes the implied column variances.

Attributes

group_sizes

List of group sizes corresponding to each element in groups.

groups

List of starting indices to each group where G is the number of groups.

ndim

Number of dimensions.

shape

Shape of the matrix.

__init__(self: adelie.adelie_core.matrix.MatrixNaiveOneHotDense64F, mat: numpy.ndarray[numpy.float64[m, n], flags.f_contiguous], levels: numpy.ndarray[numpy.int64[1, n]], n_threads: int) None#
bmul(self: adelie.adelie_core.matrix.MatrixNaiveBase64, arg0: int, arg1: int, arg2: numpy.ndarray[numpy.float64[1, n]], arg3: numpy.ndarray[numpy.float64[1, n]], arg4: numpy.ndarray[numpy.float64[1, n], flags.writeable]) None#

Computes a column block matrix-vector multiplication.

Computes the matrix-vector multiplication (v * w).T @ X[:, j:j+q].

Parameters:
jint

Column index.

qint

Number of columns.

v(n,) ndarray

Vector to multiply with the block matrix.

w(n,) ndarray

Vector of weights.

out(q,) ndarray

Vector to store in-place the result.

btmul(self: adelie.adelie_core.matrix.MatrixNaiveBase64, arg0: int, arg1: int, arg2: numpy.ndarray[numpy.float64[1, n]], arg3: numpy.ndarray[numpy.float64[1, n], flags.writeable]) None#

Computes a column block matrix transpose-vector multiplication increment.

Computes the matrix-vector multiplication v.T @ X[:, j:j+q].T. The result is incremented into the output vector.

Parameters:
jint

Column index.

qint

Number of columns.

v(q,) ndarray

Vector to multiply with the block matrix.

out(n,) ndarray

Vector to increment in-place the result.

cmul(self: adelie.adelie_core.matrix.MatrixNaiveBase64, arg0: int, arg1: numpy.ndarray[numpy.float64[1, n]], arg2: numpy.ndarray[numpy.float64[1, n]]) float#

Computes a column vector-vector multiplication.

Computes the dot-product (v * w).T @ X[:,j].

Parameters:
jint

Column index.

v(n,) ndarray

Vector to dot product with the j th column.

w(n,) ndarray

Vector of weights.

Returns:
dotfloat

Column vector-vector multiplication.

cols(self: adelie.adelie_core.matrix.MatrixNaiveBase64) int#

Returns the number of columns.

Returns:
colsint

Number of columns.

cov(self: adelie.adelie_core.matrix.MatrixNaiveBase64, arg0: int, arg1: int, arg2: numpy.ndarray[numpy.float64[1, n]], arg3: numpy.ndarray[numpy.float64[m, n], flags.writeable, flags.f_contiguous], arg4: numpy.ndarray[numpy.float64[m, n], flags.writeable, flags.f_contiguous]) None#

Computes a weighted covariance matrix.

Computes the weighted covariance matrix X[:, j:j+q].T @ W @ X[:, j:j+q].

Note

Although the name is “covariance”, we do not center the columns of X!

Parameters:
jint

Column index.

qint

Number of columns.

sqrt_weights(n,) ndarray

Square-root of the weights.

out(q, q) ndarray

Matrix to store in-place the result.

buffer(n, q) ndarray

Extra buffer space if needed.

ctmul(self: adelie.adelie_core.matrix.MatrixNaiveBase64, arg0: int, arg1: float, arg2: numpy.ndarray[numpy.float64[1, n], flags.writeable]) None#

Computes a column vector-scalar multiplication increment.

Computes the vector-scalar multiplication v * X[:,j]. The result is incremented into the output vector.

Parameters:
jint

Column index.

vfloat

Scalar to multiply with the j th column.

out(n,) ndarray

Vector to increment in-place the result.

mean(self: adelie.adelie_core.matrix.MatrixNaiveOneHotDense64F, arg0: numpy.ndarray[numpy.float64[1, n]], arg1: numpy.ndarray[numpy.float64[1, n], flags.writeable]) None#

Computes the implied column means.

The default method is used for continuous features and the implied mean is zero for categorical features.

Parameters:
weights(n,) ndarray

Vector of weights.

out(p,) ndarray

Vector to store in-place the result.

mul(self: adelie.adelie_core.matrix.MatrixNaiveBase64, arg0: numpy.ndarray[numpy.float64[1, n]], arg1: numpy.ndarray[numpy.float64[1, n]], arg2: numpy.ndarray[numpy.float64[1, n], flags.writeable]) None#

Computes a matrix-vector multiplication.

Computes the matrix-vector multiplication (v * w).T @ X.

Parameters:
v(n,) ndarray

Vector to multiply with the matrix.

w(n,) ndarray

Vector of weights.

out(p,) ndarray

Vector to store in-place the result.

rows(self: adelie.adelie_core.matrix.MatrixNaiveBase64) int#

Returns the number of rows.

Returns:
rowsint

Number of rows.

sp_tmul(self: adelie.adelie_core.matrix.MatrixNaiveBase64, arg0: scipy.sparse.csr_matrix[numpy.float64], arg1: numpy.ndarray[numpy.float64[m, n], flags.writeable, flags.c_contiguous]) None#

Computes a matrix transpose-sparse matrix multiplication.

Computes the matrix transpose-sparse matrix multiplication v.T @ X.T.

Parameters:
v(L, p) csr_matrix

Sparse matrix to multiply with the matrix.

out(L, n) ndarray

Matrix to store in-place the result.

sq_mul(self: adelie.adelie_core.matrix.MatrixNaiveBase64, arg0: numpy.ndarray[numpy.float64[1, n]], arg1: numpy.ndarray[numpy.float64[1, n], flags.writeable]) None#

Computes a squared matrix-vector multiplication.

Computes the squared matrix-vector multiplication w.T @ X ** 2.

Parameters:
weights(n,) ndarray

Vector of weights.

out(p,) ndarray

Vector to store in-place the result.

var(self: adelie.adelie_core.matrix.MatrixNaiveOneHotDense64F, arg0: numpy.ndarray[numpy.float64[1, n]], arg1: numpy.ndarray[numpy.float64[1, n]], arg2: numpy.ndarray[numpy.float64[1, n], flags.writeable]) None#

Computes the implied column variances.

The default method is used for continuous features and the implied variance is one for categorical features.

Parameters:
centers(p,) ndarray

Vector of centers.

weights(n,) ndarray

Vector of weights.

out(p,) ndarray

Vector to store in-place the result.

group_sizes#

List of group sizes corresponding to each element in groups. group_sizes[i] is the group size of the i th group.

groups#

List of starting indices to each group where G is the number of groups. groups[i] is the starting index of the i th group. The groups are naturally defined by the columns of mat. In the order of the columns of mat, we group all columns of the current matrix corresponding to each column of mat. This way, the continuous features each form a group of size one and the discrete features form a group across their one-hot encodings.

ndim#

Number of dimensions. It is always 2.

shape#

Shape of the matrix.