Skip to content

Getting Started

Installation

DataMat is distributed on PyPI. Use Poetry or pip:

pip install datamat
# or
poetry add datamat

Basic Usage

Create labelled matrices and vectors using familiar pandas-like constructors. All operations preserve index/column metadata automatically.

import datamat as dm
import numpy as np

rows = ["obs1", "obs2"]
cols = ["x1", "x2"]

X = dm.DataMat(np.array([[1.0, 2.0], [3.0, 4.0]]), idxnames=["obs"], colnames=["feature"], index=rows, columns=cols)
y = dm.DataVec([1.0, 0.5], idxnames=["feature"], name="coef")

prediction = X @ y
print(prediction)

Random Draws

Use the random helpers to simulate labelled data:

X = dm.DataMat.random((100, 3), distribution="normal", idxnames=["obs"], colnames=["feature"], rng=123)
y = dm.DataVec.random(100, distribution=("normal", 0, 2), idxnames=["obs"], rng=456)

Documentation Build

The documentation you are reading is generated by MkDocs (Material theme). To build locally:

pip install -r docs/requirements.txt
mkdocs serve

Navigate to http://127.0.0.1:8000/ in your browser.