Skip to main content

NuSVR

NuSVR is a nu-parametrised support vector regressor. Rather than fixing the tube width epsilon, the nu parameter controls the fraction of support vectors and the algorithm learns epsilon from the data.

Algorithm

The estimator runs a two-phase fit. The first pass solves the dual with epsilon = 0 to estimate the residual scale; the fitted tube width is then set to the 1 - nu quantile of the absolute residuals. The second pass re-fits with that effective epsilon. The dual is optimised by a projected sub-gradient method over the dual coefficients with a box bound derived from C. The prediction is the kernel-weighted sum of dual_coef_ plus the intercept.

Constructor

Skigen::NuSVR<Scalar> model(
Scalar nu = 0.5,
Scalar C = 1.0,
Kernel kernel = Kernel::RBF,
int degree = 3,
Scalar gamma = 0,
Scalar coef0 = 0,
Scalar tol = 1e-3,
int max_iter = 1000,
std::optional<uint64_t> random_state = std::nullopt);

Parameters

ParameterDefaultDescription
nu0.5Upper bound on the fraction of margin errors and lower bound on the fraction of support vectors, in (0, 1].
C1.0Regularisation strength; the box bound on the dual coefficients.
kernelRBFKernel function.
gamma0Kernel coefficient; 0 means 1 / (n_features * var).

Methods

MethodDescription
fit(X, y)Fit the nu-SVM regressor; learns epsilon from nu.
predict(X)Predicted target values.
score(X, y)Coefficient of determination R².

Fitted Attributes

AccessorDescription
support()Indices of the support vectors.
n_support()Number of support vectors.
epsilon_fitted()The tube width learned from nu.

Example

#include <Skigen/SVM>

using K = Skigen::NuSVR<double>::Kernel;
Skigen::NuSVR<double> reg(/*nu=*/0.5, /*C=*/5.0, K::Linear);
reg.fit(X, y);
Eigen::VectorXd pred = reg.predict(X);

Parity Scope

Mirrors the dense sklearn.svm.NuSVR API surface and the nu-to-epsilon mapping. The sub-gradient solver targets the same optimum as libsvm but is coarser, so support-vector counts and the fitted epsilon may differ. Sparse input is deferred.

API Reference

For full signatures see the NuSVR API Reference.