5#include "../utils/matrix.hpp"
6#include "../utils/autograd.hpp"
16 using namespace utils;
106 std::vector<size_t>
support()
const;
139 std::vector<size_t> support_indices_;
140 std::vector<T> dual_coef_;
141 std::vector<int> classes_;
143 std::vector<T> loss_history_;
175 T gradient_step(
const Matrix<T> &
X,
const std::vector<int> &
y);
std::vector< size_t > support() const
Get support vector indices.
std::vector< T > decision_function(const Matrix< T > &X) const
Compute the decision function for samples.
Matrix< T > support_vectors() const
Get support vectors.
Matrix< T > predict_proba(const Matrix< T > &X) const
Predict class probabilities for samples.
std::vector< int > predict(const Matrix< T > &X) const
Predict class labels for samples.
void fit(const Matrix< T > &X, const std::vector< int > &y)
Fit the SVM model to training data using automatic differentiation.
T intercept() const
Get intercept term.
std::vector< T > dual_coef() const
Get dual coefficients.
std::vector< T > loss_history() const
Get training loss history.
Namespace containing traditional machine learning algorithms.
KernelType
Kernel function types for SVM.
@ RBF
Radial Basis Function kernel: K(x, y) = exp(-gamma * ||x - y||^2)
@ LINEAR
Linear kernel: K(x, y) = x^T * y.
@ SIGMOID
Sigmoid kernel: K(x, y) = tanh(gamma * x^T * y + coef0)
@ POLYNOMIAL
Polynomial kernel: K(x, y) = (gamma * x^T * y + coef0)^degree.