Skip to main content

models.Design

A design matrix with an offset and prior weights.

Usage

Source

models.Design()

Parameters

columns: list of list of float or numpy.ndarray

One list or 1-D array per column, or a 2-D float64 array whose rows are the columns (the transpose of to_numpy()), read in one copy.

names: list of str
offset: list of float or numpy.ndarray
weights: list of float or numpy.ndarray

Examples

>>> from prospicio.models import Design
>>> d = Design([[1.0, 1.0], [0.0, 2.0]], ["(Intercept)", "x"])
>>> d.n_rows, d.names

(2, [‘(Intercept)’, ‘x’])

Attributes

Name Description
n_rows Number of rows.
names Column names.
offset Offset per row.
weights Prior weight per row.

n_rows

Number of rows.

n_rows: int


names

Column names.

names: list[str]


offset

Offset per row.

offset: list[float]


weights

Prior weight per row.

weights: list[float]

Methods

Name Description
__reduce__() Pickles as the constructor’s arguments: the columns, names, offset
column() Column j.
select() The rows rows, in that order.
to_numpy() The design matrix as a NumPy array, one row per observation and one

__reduce__()

Pickles as the constructor’s arguments: the columns, names, offset

Usage

Source

__reduce__()

and weights, every value as stored (#978).


column()

Column j.

Usage

Source

column(j)
Parameters
j: int
Returns
list of float

select()

The rows rows, in that order.

Usage

Source

select(rows)
Parameters
rows: list of int
Returns
Design

to_numpy()

The design matrix as a NumPy array, one row per observation and one

Usage

Source

to_numpy()

column per name, in Fortran order: a new array, each column copied once (#978).

Returns
numpy.ndarray
Float64, of shape (n_rows, len(names)).
Examples
>>> import numpy as np
>>> from prospicio.models import Design
>>> d = Design(np.array([[1.0, 1.0, 1.0], [0.5, 1.5, 2.5]]), ["(Intercept)", "x"])
>>> d.to_numpy()

array([[1. , 0.5], [1. , 1.5], [1. , 2.5]])