#include <LogRegSGD.h>
Logistical regression model using statistic gradient decent method for model fitting.
- Examples
- ds/TestLogRegSGD.cpp.
◆ LogRegSGD()
LogRegSGD::LogRegSGD |
( |
double |
_eta = 0.01 , |
|
|
int |
iter = 10 , |
|
|
bool |
_shuffle = false , |
|
|
int |
_randomState = 0 |
|
) |
| |
|
inlineexplicit |
default constructor
- Parameters
-
_eta | learning rate |
iter | number learning iterations |
_shuffle | shuffle data in each iteration? |
_randomState | seed for random state |
◆ activation()
Matrix< double > LogRegSGD::activation |
( |
const Matrix< double > & |
X | ) |
|
|
inlineoverridevirtual |
activate given input $$x\mapsto \phi(x)$$
- Parameters
-
- Returns
- activated values
Implements ANNClassifier.
◆ costFunction()
double LogRegSGD::costFunction |
( |
const Matrix< double > & |
mat | ) |
|
|
inlineoverridevirtual |
◆ fit()
void LogRegSGD::fit |
( |
const Matrix< double > & |
X, |
|
|
const Matrix< double > & |
y |
|
) |
| |
|
inlineoverridevirtual |
fits the weights of the model for given input values
- Parameters
-
X | array-like with the shape: [n_samples, n_features] |
y | array-like with shape: [n_samples, 1] |
- Returns
- this
Implements Predictor.
◆ initialize_weights()
void LogRegSGD::initialize_weights |
( |
size_t |
m | ) |
|
|
inlineprivate |
helper to initialize weights matrix
- Parameters
-
◆ Log()
static Matrix< double > LogRegSGD::Log |
( |
const Matrix< double > & |
in | ) |
|
|
inlinestaticprivate |
Calculates log of each element. Implementation doesn't use Matrix::Apply
- Parameters
-
- Returns
◆ netInput()
Matrix< double > LogRegSGD::netInput |
( |
const Matrix< double > & |
X | ) |
|
|
inlineoverridevirtual |
◆ partial_fit()
void LogRegSGD::partial_fit |
( |
const Matrix< double > & |
X, |
|
|
const Matrix< double > & |
y |
|
) |
| |
|
inline |
partially fit weights
- Parameters
-
X | input values |
y | target output values |
◆ predict()
Matrix< double > LogRegSGD::predict |
( |
const Matrix< double > & |
X | ) |
|
|
inlineoverridevirtual |
predict output for given input
- Parameters
-
- Returns
- predicted output for given input
Implements Predictor.
◆ update_weights()
double LogRegSGD::update_weights |
( |
const Matrix< double > & |
xi, |
|
|
const Matrix< double > & |
target |
|
) |
| |
|
inlineprivate |
logistical regression
- Parameters
-
xi | input values |
target | target output values |
- Returns
- cost
◆ randomState
int LogRegSGD::randomState |
initialize weights with random state
◆ sgd
SGD* LogRegSGD::sgd = nullptr |
algorithmic object to represent fitting algorithm
◆ shuffle
signalizes whether given dataset should be shuffled while fitting
The documentation for this class was generated from the following file: