Abstract implementation, sharing the common parameters and stopping criterion.
More...
#include <LogisticRegression.hpp>
|
bool | weights_converged (Eigen::Ref< const Eigen::VectorXd > old_weights, Eigen::Ref< const Eigen::VectorXd > new_weights) const |
| Check if weight fitting converged. More...
|
|
|
static double | probability (Eigen::Ref< const Eigen::VectorXd > x, double y, Eigen::Ref< const Eigen::VectorXd > w) |
| Calculates the probability of label given model weights and feature vector. More...
|
|
static double | log_likelihood (Eigen::Ref< const Eigen::MatrixXd > X, Eigen::Ref< const Eigen::VectorXd > y, Eigen::Ref< const Eigen::VectorXd > w, double lam) |
| Calculates the posterior log-likelihood of data given model weights. More...
|
|
static void | grad_log_likelihood (Eigen::Ref< const Eigen::MatrixXd > X, Eigen::Ref< const Eigen::VectorXd > y, Eigen::Ref< const Eigen::VectorXd > w, double lam, Eigen::Ref< Eigen::VectorXd > g) |
| Calculates the gradient of the posterior log-likelihood of data given model weights, over those weights. More...
|
|
static void | hessian_log_likelihood (Eigen::Ref< const Eigen::MatrixXd > X, Eigen::Ref< const Eigen::VectorXd > y, Eigen::Ref< const Eigen::VectorXd > w, double lam, Eigen::Ref< Eigen::MatrixXd > H) |
| Calculates the Hessian of the posterior log-likelihood of data given model weights, over those weights. More...
|
|
Abstract implementation, sharing the common parameters and stopping criterion.
The stopping criterion is ||old_weights - new_weights||_2 <= absolute_tolerance + relative_tolerance * max(||old_weights||_2, ||new_weights||_2).
◆ lam()
double ml::AbstractLogisticRegression::lam |
( |
| ) |
const |
|
inline |
Returns the regularisation parameter.
- Returns
- Inverse variance of the Gaussian prior for
w
. Cannot be negative. Set it to 0 if you want to perform maximum likelihood estimation of w
.
◆ set_lam()
void ml::AbstractLogisticRegression::set_lam |
( |
double |
lam | ) |
|
Sets the regularisation parameter.
- Parameters
-
lam | Inverse variance of the Gaussian prior for w . Cannot be negative. Set it to 0 if you want to perform maximum likelihood estimation of w . |
- Exceptions
-
std::domain_error | If lam is negative. |
◆ set_absolute_tolerance()
void ml::AbstractLogisticRegression::set_absolute_tolerance |
( |
double |
absolute_tolerance | ) |
|
Sets absolute tolerance for weight convergence.
- Parameters
-
absolute_tolerance | Cannot be negative. |
- Exceptions
-
std::domain_error | If negative. |
◆ set_relative_tolerance()
void ml::AbstractLogisticRegression::set_relative_tolerance |
( |
double |
relative_tolerance | ) |
|
Sets relative tolerance for weight convergence.
- Parameters
-
relative_tolerance | Cannot be negative. |
- Exceptions
-
std::domain_error | If negative. |
◆ weights_converged()
bool ml::AbstractLogisticRegression::weights_converged |
( |
Eigen::Ref< const Eigen::VectorXd > |
old_weights, |
|
|
Eigen::Ref< const Eigen::VectorXd > |
new_weights |
|
) |
| const |
|
protected |
Check if weight fitting converged.
- Parameters
-
old_weights | Previous weight vector. |
new_weights | New weight vector. |
- Returns
- True if converged, false otherwise.
The documentation for this class was generated from the following file: