Skip to content

Commit 86ad712

Browse files
authored
Improve docstring of LinearRegression. (rust-ml#330)
1 parent 9220765 commit 86ad712

File tree

1 file changed

+10
-11
lines changed
  • algorithms/linfa-linear/src

1 file changed

+10
-11
lines changed

algorithms/linfa-linear/src/ols.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,21 @@ use linfa::traits::{Fit, PredictInplace};
2121
derive(Serialize, Deserialize),
2222
serde(crate = "serde_crate")
2323
)]
24-
/// An ordinary least squares linear regression model.
24+
/// An ordinary least squares univariate linear regression model.
2525
///
26-
/// LinearRegression fits a linear model to minimize the residual sum of
27-
/// squares between the observed targets in the dataset, and the targets
28-
/// predicted by the linear approximation.
26+
/// Given predictors `x` and responses `y` ordinary least squares linear
27+
/// regression estimates a model of the form
2928
///
30-
/// Ordinary least squares regression solves the overconstrainted model
29+
/// `y = xW + b`
3130
///
32-
/// y = Ax + b
31+
/// by finding a matrix `W` and a vector `b` which minimize the sum of the
32+
/// squared L_2 norms `||y_j - x_jW - b||_2^2` for a dataset
33+
/// `{(x_j, y_j) for j in 1..=n_samples}`.
3334
///
34-
/// by finding x and b which minimize the L_2 norm ||y - Ax - b||_2.
35+
/// The algorithm is only implemented for _univariate_ regression. This means
36+
/// that `b` and `y` are scalars and `W` is just one column.
3537
///
36-
/// It currently uses the [Moore-Penrose pseudo-inverse]()
37-
/// to solve y - b = Ax.
38-
///
39-
/// /// ## Examples
38+
/// ## Examples
4039
///
4140
/// Here's an example on how to train a linear regression model on the `diabetes` dataset
4241
/// ```rust

0 commit comments

Comments
 (0)