optiml.ml.svm.losses module
- class optiml.ml.svm.losses.SVMLoss(svm, X, y)[source]
Bases:
OptimizationFunction,ABCBase abstract class for all SVM loss functions. It defines the primal objective, i.e., the regularization term plus the loss term averaged over the training samples, together with its jacobian.
Subclasses must implement
loss,loss_jacobianandstep_size.- Parameters:
svm (SVM instance) – The SVM estimator this loss is attached to. It provides the hyper-parameters used by the objective, e.g.,
Candfit_intercept.X (ndarray of shape (n_samples, n_features)) – Training data over which the loss is evaluated.
y (ndarray of shape (n_samples,)) – Target values associated with
X.
- jacobian(packed_coef_inter, X_batch=None, y_batch=None)[source]
The Jacobian (i.e., the gradient) of the function.
- Parameters:
x – 1D array of points at which the Jacobian is to be computed.
- Returns:
the Jacobian of the function at x.
- function_jacobian(*args, **kwargs)
- hessian(x)
The Hessian matrix of the function.
- Parameters:
x – 1D array of points at which the Hessian is to be computed.
- Returns:
the Hessian matrix of the function at x.
- class optiml.ml.svm.losses.Hinge(svm, X, y)[source]
Bases:
SVMLossCompute the hinge loss for classification as:
\[L(y_{pred}, y_{true}) = \max(0, 1 - y_{true} \, y_{pred})\]- Parameters:
svm (SVM instance) – The SVM estimator this loss is attached to. It provides the hyper-parameters used by the objective, e.g.,
Candfit_intercept.X (ndarray of shape (n_samples, n_features)) – Training data over which the loss is evaluated.
y (ndarray of shape (n_samples,)) – Target values associated with
X.
- args()
- f_star()
- function(packed_coef_inter, X_batch=None, y_batch=None)
- function_jacobian(*args, **kwargs)
- hessian(x)
The Hessian matrix of the function.
- Parameters:
x – 1D array of points at which the Hessian is to be computed.
- Returns:
the Hessian matrix of the function at x.
- jacobian(packed_coef_inter, X_batch=None, y_batch=None)
The Jacobian (i.e., the gradient) of the function.
- Parameters:
x – 1D array of points at which the Jacobian is to be computed.
- Returns:
the Jacobian of the function at x.
- x_star()
- class optiml.ml.svm.losses.SquaredHinge(svm, X, y)[source]
Bases:
HingeCompute the squared hinge loss for classification as:
\[L(y_{pred}, y_{true}) = \max(0, 1 - y_{true} \, y_{pred})^2\]- Parameters:
svm (SVM instance) – The SVM estimator this loss is attached to. It provides the hyper-parameters used by the objective, e.g.,
Candfit_intercept.X (ndarray of shape (n_samples, n_features)) – Training data over which the loss is evaluated.
y (ndarray of shape (n_samples,)) – Target values associated with
X.
- args()
- f_star()
- function(packed_coef_inter, X_batch=None, y_batch=None)
- function_jacobian(*args, **kwargs)
- hessian(x)
The Hessian matrix of the function.
- Parameters:
x – 1D array of points at which the Hessian is to be computed.
- Returns:
the Hessian matrix of the function at x.
- jacobian(packed_coef_inter, X_batch=None, y_batch=None)
The Jacobian (i.e., the gradient) of the function.
- Parameters:
x – 1D array of points at which the Jacobian is to be computed.
- Returns:
the Jacobian of the function at x.
- x_star()
- class optiml.ml.svm.losses.EpsilonInsensitive(svm, X, y, epsilon)[source]
Bases:
SVMLossCompute the epsilon-insensitive loss for regression as:
\[L(y_{pred}, y_{true}) = \max(0, \lvert y_{true} - y_{pred} \rvert - \epsilon)\]- Parameters:
svm (SVM instance) – The SVM estimator this loss is attached to.
X (ndarray of shape (n_samples, n_features)) – Training data over which the loss is evaluated.
y (ndarray of shape (n_samples,)) – Target values associated with
X.epsilon (float) – Width of the epsilon-tube within which no penalty is associated with points predicted within a distance epsilon from the actual value.
- args()
- f_star()
- function(packed_coef_inter, X_batch=None, y_batch=None)
- function_jacobian(*args, **kwargs)
- hessian(x)
The Hessian matrix of the function.
- Parameters:
x – 1D array of points at which the Hessian is to be computed.
- Returns:
the Hessian matrix of the function at x.
- jacobian(packed_coef_inter, X_batch=None, y_batch=None)
The Jacobian (i.e., the gradient) of the function.
- Parameters:
x – 1D array of points at which the Jacobian is to be computed.
- Returns:
the Jacobian of the function at x.
- x_star()
- class optiml.ml.svm.losses.SquaredEpsilonInsensitive(svm, X, y, epsilon)[source]
Bases:
EpsilonInsensitiveCompute the squared epsilon-insensitive loss for regression as:
\[L(y_{pred}, y_{true}) = \max(0, \lvert y_{true} - y_{pred} \rvert - \epsilon)^2\]- Parameters:
svm (SVM instance) – The SVM estimator this loss is attached to.
X (ndarray of shape (n_samples, n_features)) – Training data over which the loss is evaluated.
y (ndarray of shape (n_samples,)) – Target values associated with
X.epsilon (float) – Width of the epsilon-tube within which no penalty is associated with points predicted within a distance epsilon from the actual value.
- args()
- f_star()
- function(packed_coef_inter, X_batch=None, y_batch=None)
- function_jacobian(*args, **kwargs)
- hessian(x)
The Hessian matrix of the function.
- Parameters:
x – 1D array of points at which the Hessian is to be computed.
- Returns:
the Hessian matrix of the function at x.
- jacobian(packed_coef_inter, X_batch=None, y_batch=None)
The Jacobian (i.e., the gradient) of the function.
- Parameters:
x – 1D array of points at which the Jacobian is to be computed.
- Returns:
the Jacobian of the function at x.
- x_star()
- optiml.ml.svm.losses.squared_hinge
alias of
SquaredHinge
- optiml.ml.svm.losses.epsilon_insensitive
alias of
EpsilonInsensitive
- optiml.ml.svm.losses.squared_epsilon_insensitive
alias of
SquaredEpsilonInsensitive