sega_learn.svm.generalizedSVM

 
Modules
       
numpy

 
Classes
       
sega_learn.svm.baseSVM.BaseSVM(builtins.object)
GeneralizedSVC
GeneralizedSVR

 
class GeneralizedSVC(sega_learn.svm.baseSVM.BaseSVM)
    GeneralizedSVC(C=1.0, tol=0.0001, max_iter=1000, learning_rate=0.01, kernel='linear', degree=3, gamma='scale', coef0=0.0)
 
GeneralizedSVC: A Support Vector Classifier (SVC) model with support for multiple kernels.
 
This class implements an SVC model using gradient descent for optimization. It supports
linear and non-linear kernels, including polynomial and RBF kernels.
 
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.
    kernel (str): Kernel type ('linear', 'poly', 'rbf'). Default is 'linear'.
    degree (int): Degree of the polynomial kernel function ('poly'). Ignored by other kernels. Default is 3.
    gamma (str or float): Kernel coefficient for 'rbf' and 'poly'. Default is 'scale'.
    coef0 (float): Independent term in kernel function ('poly'). Default is 0.0.
 
Methods:
    __init__(self, C=1.0, tol=1e-4, max_iter=1000, learning_rate=0.01, kernel="linear", degree=3, gamma="scale", coef0=0.0):
        Initialize the GeneralizedSVC model with specified hyperparameters.
    _fit(self, X, y):
        Fit the GeneralizedSVC model to the training data using gradient descent.
    _predict_binary(self, X):
        Predict binary class labels for input samples.
    _predict_multiclass(self, X):
        Predict multi-class labels using one-vs-rest strategy.
    decision_function(self, X):
        Compute raw decision function values for input samples.
    _score_binary(self, X, y):
        Compute the accuracy score for binary classification.
    _score_multiclass(self, X, y):
        Compute the accuracy score for multi-class classification.
 
Raises:
    ValueError: If numerical instability is detected during training.
 
 
Method resolution order:
GeneralizedSVC
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, kernel='linear', degree=3, gamma='scale', coef0=0.0)
Initializes the GeneralizedSVC model with specified hyperparameters.
 
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.
    kernel: (str) - Kernel type ('linear', 'poly', 'rbf'). Default is 'linear'.
    degree: (int) - Degree of the polynomial kernel function ('poly'). Ignored by other kernels. Default is 3.
    gamma: (str or float) - Kernel coefficient for 'rbf' and 'poly'. Default is 'scale'.
    coef0: (float) - Independent term in kernel function ('poly'). Default is 0.0.
decision_function(self, X)
Compute raw decision function values for input samples.

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 GeneralizedSVR(sega_learn.svm.baseSVM.BaseSVM)
    GeneralizedSVR(C=1.0, tol=0.0001, max_iter=1000, learning_rate=0.01, epsilon=0.1, kernel='linear', degree=3, gamma='scale', coef0=0.0)
 
GeneralizedSVR: A Support Vector Regression (SVR) model with support for multiple kernels.
 
This class implements an SVR model using gradient descent for optimization. It supports
linear and non-linear kernels, including polynomial and RBF kernels.
 
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.
    kernel (str): Kernel type ('linear', 'poly', 'rbf'). Default is 'linear'.
    degree (int): Degree of the polynomial kernel function ('poly'). Ignored by other kernels. Default is 3.
    gamma (str or float): Kernel coefficient for 'rbf' and 'poly'. Default is 'scale'.
    coef0 (float): Independent term in kernel function ('poly'). Default is 0.0.
 
Methods:
    __init__(self, C=1.0, tol=1e-4, max_iter=1000, learning_rate=0.01, epsilon=0.1, kernel="linear", degree=3, gamma="scale", coef0=0.0):
        Initialize the GeneralizedSVR model with specified hyperparameters.
    _fit(self, X, y):
        Fit the GeneralizedSVR model to the training data using 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 numerical instability is detected during training.
 
 
Method resolution order:
GeneralizedSVR
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, kernel='linear', degree=3, gamma='scale', coef0=0.0)
Initializes the GeneralizedSVR model with specified hyperparameters.
 
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.
    kernel: (str) - Kernel type ('linear', 'poly', 'rbf'). Default is 'linear'.
    degree: (int) - Degree of the polynomial kernel function ('poly'). Ignored by other kernels. Default is 3.
    gamma: (str or float) - Kernel coefficient for 'rbf' and 'poly'. Default is 'scale'.
    coef0: (float) - Independent term in kernel function ('poly'). Default is 0.0.
decision_function(self, X)
Compute raw decision function values for input samples.
predict(self, X)
Predict continuous target values for input samples.
score(self, X, y)
Compute the coefficient of determination (R² score) for the model's 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