18 explicit AdalineGD(
double _eta = 0.01,
int iter = 10)
29 for(
int iter = 0; iter <
n_iter; iter++) {
31 auto errors = y - output;
37 costs(iter, 0) = cost;
62 std::function<bool(
double)> condition = [](
double x) {
return bool(x >= 0.0); };
Definition: Classifier.h:70
double eta
Learning rate.
Definition: Classifier.h:73
int n_iter
number epochs
Definition: Classifier.h:75
Definition: AdalineGD.h:11
void fit(const Matrix< double > &X, const Matrix< double > &y) override
Definition: AdalineGD.h:26
Matrix< double > predict(const Matrix< double > &X) override
Definition: AdalineGD.h:61
AdalineGD(double _eta=0.01, int iter=10)
Definition: AdalineGD.h:18
Matrix< double > netInput(const Matrix< double > &X) override
Definition: AdalineGD.h:47
double costFunction(const Matrix< double > &X) override
Definition: AdalineGD.h:73
Matrix< double > activation(const Matrix< double > &X) override
Definition: AdalineGD.h:54
Matrix< double > weights
Vector holding weights.
Definition: Classifier.h:29
void initialize_weights(size_t numRows, size_t numColumns=1)
Definition: Classifier.h:45
Matrix< double > costs
Vector holding classification error per epoch.
Definition: Classifier.h:31
void update_weights(const Matrix< double > &update, const Matrix< double > &delta)
Definition: Classifier.h:50
constexpr Matrix< T > Transpose() const
Definition: Matrix.h:256
size_t rows() const
Definition: Matrix.h:193
size_t columns() const
Definition: Matrix.h:198
static Matrix< double > netInput(const Matrix< double > &X, const Matrix< double > &weights)
Definition: SGD.h:132
Matrix< T > where(const std::function< bool(T)> &condition, const Matrix< T > &in, const Matrix< T > &valIfTrue, const Matrix< T > &valIfFalse)
Definition: matrix_utils.h:194