|  | openGPMP
    Open Source Mathematics Package | 
Represents a Logistic Regression classifier. More...
#include <logreg.hpp>
| Public Member Functions | |
| LogReg (double l_rate=001, int num_iters=1000, double lda=001) | |
| Constructor for the LogReg class.  More... | |
| ~LogReg () | |
| Destructor for the LogReg class.  More... | |
| void | train (const std::vector< std::vector< double >> &X_train, const std::vector< int > &y_train) | 
| Trains the logistic regression model on the given training data.  More... | |
| std::vector< int > | classify (const std::vector< std::vector< double >> &X) | 
| Predicts the class labels for the given test data.  More... | |
| std::vector< double > | predict (const std::vector< std::vector< double >> &X_test) | 
| Computes the predicted probabilities for the given test data.  More... | |
| double | accuracy (const std::vector< std::vector< double >> &X_test, const std::vector< int > &y_test) | 
| Computes the accuracy of the model on the given test data.  More... | |
| void | feature_scaling (std::vector< std::vector< double >> &X) | 
| Performs feature scaling on the input feature matrix.  More... | |
| double | sigmoid (double z) | 
| Computes the sigmoid function value for the given input.  More... | |
| double | cost_function (const std::vector< std::vector< double >> &X, const std::vector< int > &y) | 
| Computes the cost function value for the given input data and labels.  More... | |
| Public Attributes | |
| double | learning_rate | 
| int | num_iterations | 
| double | lambda | 
| std::vector< double > | weights | 
Represents a Logistic Regression classifier.
Definition at line 53 of file logreg.hpp.
| gpmp::ml::LogReg::LogReg | ( | double | l_rate = 001, | 
| int | num_iters = 1000, | ||
| double | lda = 001 | ||
| ) | 
Constructor for the LogReg class.
| l_rate | The learning rate for gradient descent optimization (default: 001) | 
| num_iters | The number of iterations for gradient descent (default: 1000) | 
| lda | The regularization parameter lambda (default: 001) | 
Definition at line 40 of file logreg.cpp.
| gpmp::ml::LogReg::~LogReg | ( | ) | 
| double gpmp::ml::LogReg::accuracy | ( | const std::vector< std::vector< double >> & | X_test, | 
| const std::vector< int > & | y_test | ||
| ) | 
Computes the accuracy of the model on the given test data.
| X_test | The feature matrix of the test data | 
| y_test | The true labels of the test data | 
Definition at line 99 of file logreg.cpp.
| std::vector< int > gpmp::ml::LogReg::classify | ( | const std::vector< std::vector< double >> & | X | ) | 
Predicts the class labels for the given test data.
| X_test | The feature matrix of the test data | 
Definition at line 164 of file logreg.cpp.
| double gpmp::ml::LogReg::cost_function | ( | const std::vector< std::vector< double >> & | X, | 
| const std::vector< int > & | y | ||
| ) | 
Computes the cost function value for the given input data and labels.
| X | The feature matrix of the data | 
| y | The labels of the data | 
Definition at line 145 of file logreg.cpp.
| void gpmp::ml::LogReg::feature_scaling | ( | std::vector< std::vector< double >> & | X | ) | 
Performs feature scaling on the input feature matrix.
| X | The feature matrix to be scaled | 
Definition at line 116 of file logreg.cpp.
| std::vector< double > gpmp::ml::LogReg::predict | ( | const std::vector< std::vector< double >> & | X_test | ) | 
Computes the predicted probabilities for the given test data.
| X_test | The feature matrix of the test data | 
Definition at line 81 of file logreg.cpp.
| double gpmp::ml::LogReg::sigmoid | ( | double | z | ) | 
Computes the sigmoid function value for the given input.
| z | The input value | 
Definition at line 112 of file logreg.cpp.
| void gpmp::ml::LogReg::train | ( | const std::vector< std::vector< double >> & | X_train, | 
| const std::vector< int > & | y_train | ||
| ) | 
Trains the logistic regression model on the given training data.
| X_train | The feature matrix of the training data | 
| y_train | The labels of the training data | 
Definition at line 47 of file logreg.cpp.
| double gpmp::ml::LogReg::lambda | 
The regularization parameter lambda
Definition at line 110 of file logreg.hpp.
| double gpmp::ml::LogReg::learning_rate | 
The learning rate for gradient descent optimization
Definition at line 107 of file logreg.hpp.
| int gpmp::ml::LogReg::num_iterations | 
The number of iterations for gradient descent
Definition at line 109 of file logreg.hpp.
| std::vector<double> gpmp::ml::LogReg::weights | 
The weights learned by the logistic regression model
Definition at line 112 of file logreg.hpp.