slope 0.29.0
Loading...
Searching...
No Matches
ols.h File Reference

Ordinary Least Squares (OLS) regression functionality. More...

#include <Eigen/Dense>
#include <Eigen/SparseCore>
#include <utility>
Include dependency graph for ols.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::pair< double, Eigen::VectorXd > fitOls (const Eigen::MatrixXd &X, const Eigen::VectorXd &y, bool fit_intercept=true)
 Fits an OLS regression model using dense matrices.
 
std::pair< double, Eigen::VectorXd > fitOls (const Eigen::SparseMatrix< double > &X, const Eigen::VectorXd &y, bool fit_intercept=true)
 Fits an OLS regression model using sparse matrices.
 

Detailed Description

Ordinary Least Squares (OLS) regression functionality.

This header provides functions for fitting Ordinary Least Squares regression models using both dense and sparse matrix representations.

Definition in file ols.h.

Function Documentation

◆ fitOls() [1/2]

std::pair< double, Eigen::VectorXd > fitOls ( const Eigen::MatrixXd &  X,
const Eigen::VectorXd &  y,
bool  fit_intercept = true 
)

Fits an OLS regression model using dense matrices.

Parameters
XThe design matrix with predictors (features) - dense representation
yThe target/response vector
fit_interceptWhether to include an intercept term (default: true)
Returns
std::pair containing:
  • double: Intercept term (or 0 if fit_intercept is false)
  • Eigen::VectorXd: Coefficient vector

Definition at line 7 of file ols.cpp.

◆ fitOls() [2/2]

std::pair< double, Eigen::VectorXd > fitOls ( const Eigen::SparseMatrix< double > &  X,
const Eigen::VectorXd &  y,
bool  fit_intercept = true 
)

Fits an OLS regression model using sparse matrices.

Parameters
XThe design matrix with predictors (features) - sparse representation
yThe target/response vector
fit_interceptWhether to include an intercept term (default: true)
Returns
std::pair containing:
  • double: Intercept term (or 0 if fit_intercept is false)
  • Eigen::VectorXd: Coefficient vector

Definition at line 36 of file ols.cpp.