pass::regression Class Reference
#include <regression.hpp>
Public Member Functions | |
arma::rowvec | linear_model (const arma::rowvec &x_values, const arma::rowvec &y_values) |
arma::rowvec | poly_model (const arma::rowvec &x_values, const arma::rowvec &y_values, int degree) |
double | predict_linear (const double &x, const arma::rowvec &model) |
double | predict_poly (const double &x, const arma::rowvec &model) |
Detailed Description
Regression Implementation
Linear and polynomial regression
Member Function Documentation
◆ linear_model()
arma::rowvec pass::regression::linear_model | ( | const arma::rowvec & | x_values, |
const arma::rowvec & | y_values | ||
) |
Creates the linear model for the given data set using the linear least squares method https://en.wikipedia.org/wiki/Linear_least_squares
@ x_values -> Training points for the x axis @ y_values -> Training points for the y axis
- Returns
- a rowvec like y = mx + b and the correlation coeff r^2 first element -> m second element -> b thirt element -> r^2
r^2 in range [0, 1] -> 0 worst fit -> 1 best fit
Here is the caller graph for this function:
◆ poly_model()
arma::rowvec pass::regression::poly_model | ( | const arma::rowvec & | x_values, |
const arma::rowvec & | y_values, | ||
int | degree | ||
) |
Creates the polynomial model for the given data set using the least squares method https://en.wikipedia.org/wiki/Linear_least_squares
Code based on Manas Sharma example
@ x_values -> Training points for the x axis @ y_values -> Training points for the y axis -> the degree of the polynomial regression
- Returns
- a rowvec like f(x) = p1*x^3 + p2*x^2 + p3*x + p4 first element -> p4 second element -> p4 thirt element -> p2 fourth element -> p1
Here is the caller graph for this function:
◆ predict_linear()
double pass::regression::predict_linear | ( | const double & | x, |
const arma::rowvec & | model | ||
) |
Predict a value x using the linear model
Here is the caller graph for this function:
◆ predict_poly()
double pass::regression::predict_poly | ( | const double & | x, |
const arma::rowvec & | model | ||
) |
Predict a value x using the polynomial model
Here is the caller graph for this function:
The documentation for this class was generated from the following files:
- /Users/romeo/Desktop/PASS/include/pass_bits/helper/regression.hpp
- /Users/romeo/Desktop/PASS/src/helper/regression.cpp