Add category matrix support to AttributeSet
@sushobhan2024 is already working on this.
Since Oct 16, 2025.
- Dominant language
- Python
- Stars
- 314
- Forks
- 77
- Avg merge
- 4d 6m
- Merged PRs (30d)
- 10
Description
As discussed today with @sushobhan2024, we need to add a new cat_matrix method to AttributeSet and its subclasses, to compute a matrix over categorical values for various attribute representations.
-
Define the
cat_matrixsignature. Proposed:def cat_matrix(self, *, normalize: Literal["unit" | "distribution"] = None) -> NDArray[np.floating[Any]] | csr_array: ... -
Implement
cat_matrixfor scalar attribute sets, where the columns of the matrix refer to distinct values of the attribute. It should throw aTypeErrorif the attribute is floating-point. We may want to cache aVocabularyof distinct values to speed up repeated calls. If the attribute is null for a given item, the resulting matrix should be all 0. Should usually return a sparse matrix (csr_array). -
Implement
cat_matrixfor list attribute sets. Behaves like scalar attribute, except that more than one value can be nonzero. -
Implement
cat_matrixfor dense vector attribute sets. Returns a dense matrix (np.ndarray), columns correspond to the attribute vector columns. Basically just returns the vector as-is, possibly with normalized rows. -
Implement
cat_matrixfor sparse vector attribute sets. Same as dense, except it returns a sparse matrix instead of a dense one.
Open question: do we provide access to the vocabulary for list and scalar attribute sets, and how? Maybe we also add a cat_vocabulary() method that returns the column vocabulary for a vector attribute set, and the unique value vocabulary for a scalar or list set, and None if the scalar or list is floating-point or if the vector attribute has no dimension vocabulary / names.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.