Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Companion crate examples

Each companion crate ships its own runnable examples, living in that crate’s examples/ directory (never in core matten). They are small, deterministic, and self-checking, and they all respect the one-way dependency rule: companions depend on matten, but core matten depends on no companion.

These examples were audited and improved in place under RFC-048; the program does not add duplicate or renamed companion examples.

matten-ndarray — interop with ndarray

ExampleWhat it shows
from_arraydndarray::ArrayD<f64>matten::Tensor, including a transposed (non-contiguous) input
to_arraydmatten::Tensorndarray::ArrayD<f64>

Both conversions copy data (no zero-copy claim) and preserve shape. Only numeric tensors convert to ndarray. The full conversion rules are documented as a bridge conversion contract; the bridge-crate policy covers how bridge crates are structured (own their target dependency, never re-export Tensor).

cargo run -p matten-ndarray --example from_arrayd
cargo run -p matten-ndarray --example to_arrayd

matten-mlprep — small preprocessing

ExampleWhat it shows
mlprep_standardize_columnsPer-column z-score (zero mean, unit std)
mlprep_minmax_scalePer-column scaling into [0, 1]
mlprep_add_bias_columnPrepend a constant intercept column
mlprep_train_test_splitDeterministic, ordered train/test split

Convention throughout: rows are samples, columns are features; every transform is deterministic with no hidden randomness and no model training.

cargo run -p matten-mlprep --example mlprep_standardize_columns
cargo run -p matten-mlprep --example mlprep_train_test_split

matten-data — table-to-Tensor (production-ready candidate)

ExampleWhat it shows
data_00_quickstartThe full happy path in one place
data_01_schema_summaryInspect rows, columns, names, missing counts, kinds
data_02_select_columnsSelect by name; output order matches the request
data_03_missing_valuesMissing values never become zero silently
data_04_to_tensorOutput shape, row-major order, core interop
data_05_errorsThe common boundary errors
csv_to_tensorComprehensive overview of the whole workflow

matten-data is a production-ready candidate and intentionally small. It is not a dataframe: no group-by, join, merge, pivot, or query. Missing values and numeric conversion are explicit, never silent. See matten-data: table to Tensor for the full guide.

cargo run -p matten-data --example csv_to_tensor

What this is not

Companion examples demonstrate accepted bridge/preprocessing APIs. They do not imply that matten is a dataframe engine, an ML framework, a linear-algebra backend, or a replacement for ndarray, nalgebra, NumPy, or Pandas.