Cpp ML Library  1.0.0
A library of Machine Learning Algorithmns seen from the Udemy course Machine Learning A to Z.
Public Member Functions | List of all members
LogisticRegression Class Reference

Logistic Regression model for binary classification tasks. More...

#include <LogisticRegression.hpp>

Public Member Functions

 LogisticRegression (double learningRate=0.01, int iterations=1000, bool useBias=true)
 Constructor initializing the learning rate and iteration count. More...
 
void train (const std::vector< std::vector< double >> &features, const std::vector< int > &labels)
 Train the model using features and labels. More...
 
int predict (const std::vector< double > &features) const
 Predicts the class label for a given input. More...
 
double predictProbability (const std::vector< double > &features) const
 Predicts the probability of class 1 for a given input. More...
 

Detailed Description

Logistic Regression model for binary classification tasks.

Constructor & Destructor Documentation

◆ LogisticRegression()

LogisticRegression::LogisticRegression ( double  learningRate = 0.01,
int  iterations = 1000,
bool  useBias = true 
)
inline

Constructor initializing the learning rate and iteration count.

Parameters
learningRateThe rate at which the model learns.
iterationsNumber of training iterations.
useBiasWhether to include a bias term.

Member Function Documentation

◆ predict()

int LogisticRegression::predict ( const std::vector< double > &  features) const
inline

Predicts the class label for a given input.

Parameters
featuresInput feature vector.
Returns
Predicted class label (0 or 1).

◆ predictProbability()

double LogisticRegression::predictProbability ( const std::vector< double > &  features) const
inline

Predicts the probability of class 1 for a given input.

Parameters
featuresInput feature vector.
Returns
Probability of the input belonging to class 1.

◆ train()

void LogisticRegression::train ( const std::vector< std::vector< double >> &  features,
const std::vector< int > &  labels 
)
inline

Train the model using features and labels.

Parameters
featuresInput feature matrix.
labelsBinary labels (0 or 1).

The documentation for this class was generated from the following file: