Constructor
new LinearPrior(weights, intercept)
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
weights |
Array.<number> | length = input dimension |
intercept |
number |
Classes
Members
intercept :number
- Source:
Type:
- number
weights :Array.<number>
- Source:
Type:
- Array.<number>
Methods
fit(inputs, outputs)
- Description:
Fits the linear prior via least-squares.
Matches Rust: insert a column of ones at index 0 → [1 | inputs], then solve [1|inputs]·w = outputs (SVD, threshold 0). The resulting w[0] is the intercept and w[1..] are the weights.
JS: builds augmented matrix (m × d+1) with a leading ones column, delegates to
lstsqSolve(augmented, outputs).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
inputs |
Array.<Array.<number>> | training inputs (m × d) |
outputs |
Array.<number> | training outputs (m) |
prior(inputs) → {Array.<number>}
- Description:
Evaluates the linear prior for each row of
inputs. Matches Rustprior(input) → input * self.weights + self.interceptwhere input is (n×d) and weights is (d×1), yielding (n×1).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
inputs |
Array.<Array.<number>> | one sample per row |
Returns:
length = inputs.length
- Type
- Array.<number>
(static) default(inputDimension) → {LinearPrior}
- Description:
Creates the default LinearPrior with all-zero weights and zero intercept. Matches Rust
LinearPrior::default(input_dimension) → Self { weights: DVector::zeros(input_dimension), intercept: 0f64 }.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
inputDimension |
number |
Returns:
- Type
- LinearPrior