Tabmat provides efficient matrix representations for working with tabular data, designed to integrate seamlessly with various dataframe libraries. It offers specialized matrix types like DenseMatrix, CategoricalMatrix, and SplitMatrix for performance-critical statistical and machine learning tasks, especially useful for generalized linear models. The current version is 4.2.1, with an active development pace and frequent releases addressing bug fixes and new features.
pip install tabmatVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a `SplitMatrix` from a pandas DataFrame using `tabmat.from_df`. It automatically handles different column types, applying standardization and one-hot encoding as specified. The example then shows how to perform a matrix-vector multiplication, a common operation for `tabmat` objects.
Use the `.unpack()` method (or `.toarray()` for `DenseMatrix`) to explicitly convert to the underlying array type before performing operations that require a standard NumPy array or SciPy sparse matrix. For example, `dense_matrix.unpack()`.
Upgrade your Python environment to version 3.10 or higher. If unable to upgrade, install an older version of tabmat, e.g., `pip install "tabmat<4.2.0"`.
Upgrade to tabmat >=4.2.1, which includes fixes for read-only buffer handling across various matrix operations. If upgrading is not an option, ensure that any input arrays passed to tabmat methods are writable (e.g., by making a copy: `my_array.copy()`).
Test your existing code with the new versions. Consult the `narwhals` documentation if you encounter unexpected behavior, especially when working with non-pandas dataframes or specific dataframe operations.
Use `dense_matrix.unpack()` or `dense_matrix.toarray()` to get the underlying NumPy array for direct array manipulation.
Explicitly convert the `DenseMatrix` to a NumPy array using `dense_matrix.unpack()` or `dense_matrix.toarray()` before passing it to functions expecting a `np.ndarray`.
Upgrade your Python environment to 3.10 or newer. If an upgrade is not possible, install an older version of tabmat: `pip install "tabmat<4.2.0"`.
Upgrade to tabmat version 4.2.1 or newer, which includes fixes for operating on read-only buffers. If an upgrade is not possible, ensure any input arrays are writable, e.g., by creating a copy: `my_array.copy(order='C')`.