41 DLL_DECLSPEC
void predict(Eigen::Ref<const Eigen::MatrixXd> X, Eigen::Ref<Eigen::VectorXd> y)
const;
49 Eigen::VectorXd
predict(Eigen::Ref<const Eigen::MatrixXd> X)
const
51 Eigen::VectorXd y(X.cols());
62 DLL_DECLSPEC
double predict_single(Eigen::Ref<const Eigen::VectorXd> x)
const;
65 DLL_DECLSPEC std::string
to_string()
const;
83 DLL_DECLSPEC
virtual Result
fit(Eigen::Ref<const Eigen::MatrixXd> X, Eigen::Ref<const Eigen::VectorXd> y)
const = 0;
92 DLL_DECLSPEC
static double probability(Eigen::Ref<const Eigen::VectorXd> x,
double y, Eigen::Ref<const Eigen::VectorXd> w);
104 DLL_DECLSPEC
static double log_likelihood(Eigen::Ref<const Eigen::MatrixXd> X, Eigen::Ref<const Eigen::VectorXd> y, Eigen::Ref<const Eigen::VectorXd> w,
double lam);
116 DLL_DECLSPEC
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);
128 DLL_DECLSPEC
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);
158 return absolute_tolerance_;
166 return relative_tolerance_;
174 return maximum_steps_;
209 bool weights_converged(Eigen::Ref<const Eigen::VectorXd> old_weights, Eigen::Ref<const Eigen::VectorXd> new_weights)
const;
212 double relative_tolerance_;
213 double absolute_tolerance_;
214 unsigned int maximum_steps_;
223 DLL_DECLSPEC
Result fit(Eigen::Ref<const Eigen::MatrixXd> X, Eigen::Ref<const Eigen::VectorXd> y)
const override;
void set_absolute_tolerance(double absolute_tolerance)
Sets absolute tolerance for weight convergence.
Eigen::VectorXd predict(Eigen::Ref< const Eigen::MatrixXd > X) const
Predicts labels for features X given w. Version which returns a new vector.
Definition: LogisticRegression.hpp:49
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,...
Result fit(Eigen::Ref< const Eigen::MatrixXd > X, Eigen::Ref< const Eigen::VectorXd > y) const override
Fits the model and returns the result.
Definition: BallTree.hpp:10
void set_relative_tolerance(double relative_tolerance)
Sets relative tolerance for weight convergence.
void set_maximum_steps(unsigned int maximum_steps)
Sets maximum number of steps.
AbstractLogisticRegression()
Constructor setting default parameter values.
double predict_single(Eigen::Ref< const Eigen::VectorXd > x) const
Predicts label for feature x given w.
Abstract implementation, sharing the common parameters and stopping criterion.
Definition: LogisticRegression.hpp:136
void set_lam(double lam)
Sets the regularisation parameter.
Eigen::VectorXd w
Definition: LogisticRegression.hpp:30
unsigned int steps_taken
Definition: LogisticRegression.hpp:31
bool weights_converged(Eigen::Ref< const Eigen::VectorXd > old_weights, Eigen::Ref< const Eigen::VectorXd > new_weights) const
Check if weight fitting converged.
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,...
double absolute_tolerance() const
Returns absolute tolerance for fitted weights.
Definition: LogisticRegression.hpp:156
void predict(Eigen::Ref< const Eigen::MatrixXd > X, Eigen::Ref< Eigen::VectorXd > y) const
Predicts labels for features X given w.
Conjugate gradient logistic regression, as described in Sec. 4 of Thomas P. Minka,...
Definition: LogisticRegression.hpp:220
Binomial logistic regression algorithm.
Definition: LogisticRegression.hpp:22
unsigned int maximum_steps() const
Returns maximum number of steps allowed.
Definition: LogisticRegression.hpp:172
double lam() const
Returns the regularisation parameter.
Definition: LogisticRegression.hpp:148
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.
std::string to_string() const
Formats the result as string.
virtual Result fit(Eigen::Ref< const Eigen::MatrixXd > X, Eigen::Ref< const Eigen::VectorXd > y) const =0
Fits the model and returns the result.
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.
double relative_tolerance() const
Returns relative tolerance for fitted weights.
Definition: LogisticRegression.hpp:164
virtual ~LogisticRegression()
Virtual destructor.
bool converged
Definition: LogisticRegression.hpp:32
Result of binomial logistic regression.
Definition: LogisticRegression.hpp:28