sega_learn.svm.linerarSVM

 
Modules
       
numpy

 
Classes
       
sega_learn.svm.baseSVM.BaseSVM(builtins.object)
LinearSVC
LinearSVR

 
class LinearSVC(sega_learn.svm.baseSVM.BaseSVM)
    LinearSVC(C=1.0, tol=0.0001, max_iter=1000, learning_rate=0.01, numba=False)
 
LinearSVC is a linear Support Vector Classifier (SVC) implementation that uses gradient descent for optimization.
 
It supports binary and multi-class classification using a one-vs-rest strategy.
 
Attributes:
    C (float): Regularization parameter. Default is 1.0.
    tol (float): Tolerance for stopping criteria. Default is 1e-4.
    max_iter (int): Maximum number of iterations for gradient descent. Default is 1000.
    learning_rate (float): Learning rate for gradient descent. Default is 0.01.
    numba (bool): Whether to use Numba-accelerated computations. Default is False.
    w (ndarray): Weight vector for the linear model.
    b (float): Bias term for the linear model.
    numba_available (bool): Indicates if Numba is available for use.
 
Methods:
    __init__(self, C=1.0, tol=1e-4, max_iter=1000, learning_rate=0.01, numba=False):
        Initializes the LinearSVC instance with hyperparameters and checks for Numba availability.
    _fit(self, X, y):
        Fits the LinearSVC model to the training data using gradient descent.
    _predict_binary(self, X):
        Predicts class labels {-1, 1} for binary classification.
    _predict_multiclass(self, X):
        Predicts class labels for multi-class classification using one-vs-rest strategy.
    decision_function(self, X):
        Computes raw decision function values before thresholding.
    _score_binary(self, X, y):
        Computes the mean accuracy of predictions for binary classification.
    _score_multiclass(self, X, y):
        Computes the mean accuracy of predictions for multi-class classification.
 
 
Method resolution order:
LinearSVC
sega_learn.svm.baseSVM.BaseSVM
builtins.object

Methods defined here:
__init__(self, C=1.0, tol=0.0001, max_iter=1000, learning_rate=0.01, numba=False)
Initializes the LinearSVC instance with hyperparameters and checks for Numba availability.
 
Args:
    C: (float) - Regularization parameter. Default is 1.0.
    tol: (float) - Tolerance for stopping criteria. Default is 1e-4.
    max_iter: (int) - Maximum number of iterations for gradient descent. Default is 1000.
    learning_rate: (float) - Learning rate for gradient descent. Default is 0.01.
    numba: (bool) - Whether to use Numba-accelerated computations. Default is False.
decision_function(self, X)
Compute raw decision function values before thresholding.
 
Args:
    X (array-like of shape (n_samples, n_features)): Input samples.
 
Returns:
    scores (array of shape (n_samples,)): Decision function values.

Methods inherited from sega_learn.svm.baseSVM.BaseSVM:
__sklearn_is_fitted__(self)
Checks if the model has been fitted (for sklearn compatibility).
 
Returns:
    fitted: (bool) - True if the model has been fitted, otherwise False.
fit(self, X, y=None)
Fits the SVM model to the training data.
 
Args:
    X: (array-like of shape (n_samples, n_features)) - Training vectors.
    y: (array-like of shape (n_samples,)) - Target values. Default is None.
 
Returns:
    self: (BaseSVM) - The fitted instance.
get_params(self, deep=True)
Retrieves the hyperparameters of the model.
 
Args:
    deep: (bool) - If True, returns parameters of subobjects as well. Default is True.
 
Returns:
    params: (dict) - Dictionary of hyperparameter names and values.
predict(self, X)
Predicts class labels for input samples.
 
Args:
    X: (array-like of shape (n_samples, n_features)) - Input samples.
 
Returns:
    predicted_labels: (ndarray of shape (n_samples,)) - Predicted class labels.
score(self, X, y)
Computes the mean accuracy of the model on the given test data.
 
Args:
    X: (array-like of shape (n_samples, n_features)) - Test samples.
    y: (array-like of shape (n_samples,)) - True class labels.
 
Returns:
    score: (float) - Mean accuracy of predictions.
set_params(self, **parameters)
Sets the hyperparameters of the model.
 
Args:
    **parameters: (dict) - Hyperparameter names and values.
 
Returns:
    self: (BaseSVM) - The updated estimator instance.

Data descriptors inherited from sega_learn.svm.baseSVM.BaseSVM:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class LinearSVR(sega_learn.svm.baseSVM.BaseSVM)
    LinearSVR(C=1.0, tol=0.0001, max_iter=1000, learning_rate=0.01, epsilon=0.1, numba=False)
 
LinearSVR: A linear Support Vector Regression (SVR) model using epsilon-insensitive loss.
 
This class implements a linear SVR model with support for mini-batch gradient descent
and optional acceleration using Numba. It is designed for regression tasks and uses
epsilon-insensitive loss to handle errors within a specified margin.
 
Attributes:
    C (float): Regularization parameter. Default is 1.0.
    tol (float): Tolerance for stopping criteria. Default is 1e-4.
    max_iter (int): Maximum number of iterations for gradient descent. Default is 1000.
    learning_rate (float): Learning rate for gradient descent. Default is 0.01.
    epsilon (float): Epsilon parameter for epsilon-insensitive loss. Default is 0.1.
    numba (bool): Whether to use Numba for acceleration. Default is False.
    w (ndarray): Weight vector of the model.
    b (float): Bias term of the model.
    numba_available (bool): Indicates if Numba is available for acceleration.
    X_train (ndarray): Training data used for fitting.
    y_train (ndarray): Target values used for fitting.
 
Methods:
    __init__(self, C=1.0, tol=1e-4, max_iter=1000, learning_rate=0.01, epsilon=0.1, numba=False):
        Initialize the LinearSVR model with specified hyperparameters.
    _fit(self, X, y):
        Fit the LinearSVR model to the training data using mini-batch gradient descent.
    predict(self, X):
        Predict continuous target values for input samples.
    decision_function(self, X):
        Compute raw decision function values for input samples.
    score(self, X, y):
        Compute the coefficient of determination (R² score) for the model's predictions.
 
Raises:
    ValueError: If a non-linear kernel is specified, as LinearSVR only supports linear kernels.
 
 
Method resolution order:
LinearSVR
sega_learn.svm.baseSVM.BaseSVM
builtins.object

Methods defined here:
__init__(self, C=1.0, tol=0.0001, max_iter=1000, learning_rate=0.01, epsilon=0.1, numba=False)
Initializes the LinearSVR instance with hyperparameters and checks for Numba availability.
 
Args:
    C: (float) - Regularization parameter. Default is 1.0.
    tol: (float) - Tolerance for stopping criteria. Default is 1e-4.
    max_iter: (int) - Maximum number of iterations for gradient descent. Default is 1000.
    learning_rate: (float) - Learning rate for gradient descent. Default is 0.01.
    epsilon: (float) - Epsilon parameter for epsilon-insensitive loss. Default is 0.1.
    numba: (bool) - Whether to use Numba-accelerated computations. Default is False.
 
Returns:
    None
decision_function(self, X)
Compute raw decision function values.
 
Args:
    X: (array-like of shape (n_samples, n_features)) - Input samples.
 
Returns:
    scores: (array of shape (n_samples,)) - Predicted values.
predict(self, X)
Predict continuous target values for input samples.
 
Args:
    X: (array-like of shape (n_samples, n_features)) - Input samples.
 
Returns:
    y_pred: (array of shape (n_samples,)) - Predicted values.
score(self, X, y)
Compute the coefficient of determination (R² score).
 
Args:
    X: (array-like of shape (n_samples, n_features)) - Test samples.
    y: (array-like of shape (n_samples,)) - True target values.
 
Returns:
    score: (float) - R² score of predictions.

Methods inherited from sega_learn.svm.baseSVM.BaseSVM:
__sklearn_is_fitted__(self)
Checks if the model has been fitted (for sklearn compatibility).
 
Returns:
    fitted: (bool) - True if the model has been fitted, otherwise False.
fit(self, X, y=None)
Fits the SVM model to the training data.
 
Args:
    X: (array-like of shape (n_samples, n_features)) - Training vectors.
    y: (array-like of shape (n_samples,)) - Target values. Default is None.
 
Returns:
    self: (BaseSVM) - The fitted instance.
get_params(self, deep=True)
Retrieves the hyperparameters of the model.
 
Args:
    deep: (bool) - If True, returns parameters of subobjects as well. Default is True.
 
Returns:
    params: (dict) - Dictionary of hyperparameter names and values.
set_params(self, **parameters)
Sets the hyperparameters of the model.
 
Args:
    **parameters: (dict) - Hyperparameter names and values.
 
Returns:
    self: (BaseSVM) - The updated estimator instance.

Data descriptors inherited from sega_learn.svm.baseSVM.BaseSVM:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object