#ifndef MLPP_DUAL_SVC_OLD_H #define MLPP_DUAL_SVC_OLD_H // // DualSVC.hpp // // Created by Marc Melikyan on 10/2/20. // // http://disp.ee.ntu.edu.tw/~pujols/Support%20Vector%20Machine.pdf // http://ciml.info/dl/v0_99/ciml-v0_99-ch11.pdf // Were excellent for the practical intution behind the dual formulation. #include "core/math/math_defs.h" #include #include class MLPPDualSVCOld { public: MLPPDualSVCOld(std::vector> inputSet, std::vector outputSet, real_t C, std::string kernel = "Linear"); MLPPDualSVCOld(std::vector> inputSet, std::vector outputSet, real_t C, std::string kernel, real_t p, real_t c); std::vector modelSetTest(std::vector> X); real_t modelTest(std::vector x); void gradientDescent(real_t learning_rate, int max_epoch, bool UI = false); void SGD(real_t learning_rate, int max_epoch, bool UI = false); void MBGD(real_t learning_rate, int max_epoch, int mini_batch_size, bool UI = false); real_t score(); void save(std::string fileName); private: void init(); real_t Cost(std::vector alpha, std::vector> X, std::vector y); std::vector Evaluate(std::vector> X); std::vector propagate(std::vector> X); real_t Evaluate(std::vector x); real_t propagate(std::vector x); void forwardPass(); void alphaProjection(); real_t kernelFunction(std::vector v, std::vector u, std::string kernel); std::vector> kernelFunction(std::vector> U, std::vector> V, std::string kernel); std::vector> inputSet; std::vector outputSet; std::vector z; std::vector y_hat; real_t bias; std::vector alpha; std::vector> K; real_t C; int n; int k; std::string kernel; real_t p; // Poly real_t c; // Poly // UI Portion void UI(int epoch, real_t cost_prev); }; #endif /* DualSVC_hpp */