sega_learn

 
Package Contents
       
auto (package)
clustering (package)
linear_models (package)
nearest_neighbors (package)
neural_networks (package)
neural_networks_cupy_dev (package)
neural_networks_numba_dev (package)
setup
svm (package)
time_series (package)
trees (package)
utils (package)

 
Classes
       
abc.ABC(builtins.object)
sega_learn.utils.animator.AnimationBase
sega_learn.utils.animator.ClassificationAnimation
sega_learn.utils.animator.ForcastingAnimation
sega_learn.utils.animator.RegressionAnimation
builtins.object
sega_learn.auto.classifier.AutoClassifier
sega_learn.auto.regressor.AutoRegressor
sega_learn.clustering.clustering.DBSCAN
sega_learn.clustering.clustering.KMeans
sega_learn.linear_models.classifiers.LinearDiscriminantAnalysis
sega_learn.linear_models.classifiers.LogisticRegression
sega_learn.linear_models.classifiers.Perceptron
sega_learn.linear_models.classifiers.QuadraticDiscriminantAnalysis
sega_learn.linear_models.regressors.Bayesian
sega_learn.linear_models.regressors.Lasso
sega_learn.linear_models.regressors.OrdinaryLeastSquares
sega_learn.linear_models.regressors.PassiveAggressiveRegressor
sega_learn.linear_models.regressors.RANSAC
sega_learn.linear_models.regressors.Ridge
sega_learn.neural_networks.activations.Activation
sega_learn.neural_networks.layers.ConvLayer
sega_learn.neural_networks.layers.DenseLayer
sega_learn.neural_networks.layers.FlattenLayer
sega_learn.neural_networks.layers.RNNLayer
sega_learn.neural_networks.layers_jit.JITRNNLayer
sega_learn.neural_networks.loss.BCEWithLogitsLoss
sega_learn.neural_networks.loss.CrossEntropyLoss
sega_learn.neural_networks.loss.HuberLoss
sega_learn.neural_networks.loss.MeanAbsoluteErrorLoss
sega_learn.neural_networks.loss.MeanSquaredErrorLoss
sega_learn.neural_networks.loss_jit.JITBCEWithLogitsLoss
sega_learn.neural_networks.loss_jit.JITCrossEntropyLoss
sega_learn.neural_networks.loss_jit.JITHuberLoss
sega_learn.neural_networks.loss_jit.JITMeanAbsoluteErrorLoss
sega_learn.neural_networks.loss_jit.JITMeanSquaredErrorLoss
sega_learn.neural_networks.neuralNetworkBase.NeuralNetworkBase
sega_learn.neural_networks.neuralNetworkBaseBackend.BaseBackendNeuralNetwork
sega_learn.neural_networks.neuralNetworkNumbaBackend.NumbaBackendNeuralNetwork
sega_learn.neural_networks.optimizers.AdadeltaOptimizer
sega_learn.neural_networks.optimizers.AdamOptimizer
sega_learn.neural_networks.optimizers.SGDOptimizer
sega_learn.neural_networks.schedulers.lr_scheduler_exp
sega_learn.neural_networks.schedulers.lr_scheduler_plateau
sega_learn.neural_networks.schedulers.lr_scheduler_step
sega_learn.svm.baseSVM.BaseSVM
sega_learn.svm.generalizedSVM.GeneralizedSVC
sega_learn.svm.generalizedSVM.GeneralizedSVR
sega_learn.svm.linerarSVM.LinearSVC
sega_learn.svm.linerarSVM.LinearSVR
sega_learn.svm.oneClassSVM.OneClassSVM
sega_learn.time_series.arima.ARIMA
sega_learn.time_series.arima.SARIMA
sega_learn.time_series.arima.SARIMAX
sega_learn.time_series.decomposition.AdditiveDecomposition
sega_learn.time_series.decomposition.MultiplicativeDecomposition
sega_learn.time_series.exponential_smoothing.DoubleExponentialSmoothing
sega_learn.time_series.exponential_smoothing.SimpleExponentialSmoothing
sega_learn.time_series.exponential_smoothing.TripleExponentialSmoothing
sega_learn.time_series.forecasting.ForecastingPipeline
sega_learn.time_series.moving_average.ExponentialMovingAverage
sega_learn.time_series.moving_average.SimpleMovingAverage
sega_learn.time_series.moving_average.WeightedMovingAverage
sega_learn.trees.adaBoostClassifier.AdaBoostClassifier
sega_learn.trees.adaBoostRegressor.AdaBoostRegressor
sega_learn.trees.gradientBoostedClassifier.GradientBoostedClassifier
sega_learn.trees.gradientBoostedRegressor.GradientBoostedRegressor
sega_learn.trees.isolationForest.IsolationForest
sega_learn.trees.isolationForest.IsolationTree
sega_learn.trees.isolationForest.IsolationUtils
sega_learn.trees.randomForestClassifier.RandomForestClassifier
sega_learn.trees.randomForestRegressor.RandomForestRegressor
sega_learn.trees.treeClassifier.ClassifierTree
sega_learn.trees.treeClassifier.ClassifierTreeUtility
sega_learn.trees.treeRegressor.RegressorTree
sega_learn.trees.treeRegressor.RegressorTreeUtility
sega_learn.utils.dataAugmentation.Augmenter
sega_learn.utils.dataAugmentation.RandomOverSampler
sega_learn.utils.dataAugmentation.RandomUnderSampler
sega_learn.utils.dataAugmentation.SMOTE
sega_learn.utils.dataPrep.DataPrep
sega_learn.utils.dataPreprocessing.Scaler
sega_learn.utils.decomposition.PCA
sega_learn.utils.decomposition.SVD
sega_learn.utils.metrics.Metrics
sega_learn.utils.modelSelection.GridSearchCV
sega_learn.utils.modelSelection.ModelSelectionUtility
sega_learn.utils.modelSelection.RandomSearchCV
sega_learn.utils.polynomialTransform.PolynomialTransform
sega_learn.utils.voting.ForecastRegressor
sega_learn.utils.voting.VotingClassifier
sega_learn.utils.voting.VotingRegressor
sega_learn.nearest_neighbors.base.KNeighborsBase(abc.ABC)
sega_learn.nearest_neighbors.knn_classifier.KNeighborsClassifier
sega_learn.nearest_neighbors.knn_regressor.KNeighborsRegressor
sega_learn.neural_networks.layers_jit.JITConvLayer(builtins.object)
sega_learn.neural_networks.layers_jit.JITConvLayer
sega_learn.neural_networks.layers_jit.JITDenseLayer(builtins.object)
sega_learn.neural_networks.layers_jit.JITDenseLayer
sega_learn.neural_networks.layers_jit.JITFlattenLayer(builtins.object)
sega_learn.neural_networks.layers_jit.JITFlattenLayer
sega_learn.neural_networks.optimizers_jit.JITAdadeltaOptimizer(builtins.object)
sega_learn.neural_networks.optimizers_jit.JITAdadeltaOptimizer
sega_learn.neural_networks.optimizers_jit.JITAdamOptimizer(builtins.object)
sega_learn.neural_networks.optimizers_jit.JITAdamOptimizer
sega_learn.neural_networks.optimizers_jit.JITSGDOptimizer(builtins.object)
sega_learn.neural_networks.optimizers_jit.JITSGDOptimizer

 
class ARIMA(builtins.object)
    ARIMA(order)
 
ARIMA model for time series forecasting.
 
ARIMA is a class of models that explains a given time series based on its own past values,
its own past forecast errors, and a number of lagged forecast errors.
It is a combination of Auto-Regressive (AR), Moving Average (MA) models, and differencing (I) to make the series stationary.
 
The model is defined by three parameters: p, d, and q, which represent the order of the AR,
the degree of differencing, and the order of the MA components, respectively.
 
Attributes:
    order (tuple): The order of the ARIMA model (p, d, q).
    p (int): The order of the Auto-Regressive (AR) component.
    d (int): The degree of differencing.
    q (int): The order of the Moving Average (MA) component.
    model (array-like): The original time series data.
    fitted_model (dict): The fitted ARIMA model containing AR and MA components.
    _differenced_series (array-like): The differenced series used for fitting ARMA.
    _residuals (array-like): The residuals after fitting the AR component.
 
  Methods defined here:
__init__(self, order)
Initialize the ARIMA model.
 
ARIMA(p, d, q) model where:
    - p: Order of the Auto-Regressive (AR) component.
    - d: Degree of differencing (number of times the series is differenced).
    - q: Order of the Moving Average (MA) component.
 
Args:
    order (tuple): The order of the ARIMA model (p, d, q).
 
Selecting the right values:
    - p: Use the Partial Autocorrelation Function (PACF) plot to determine the lag where the PACF cuts off.
    - d: Use the Augmented Dickey-Fuller (ADF) test to check stationarity. Increase `d` until the series becomes stationary.
    - q: Use the Autocorrelation Function (ACF) plot to determine the lag where the ACF cuts off.
__str__(self)
Return str(self).
fit(self, time_series)
Fit the ARIMA model to the given time series data.
 
Args:
    time_series (array-like): The time series data to fit the model to.
forecast(self, steps)
Forecast future values using the fitted ARIMA model.
 
Args:
    steps (int): The number of steps to forecast.
 
Returns:
    array-like: The forecasted values.

Static methods defined here:
find_best_order(train_series, test_series, max_p=5, max_d=2, max_q=5, subset_size=1.0)
Find the best ARIMA order using grid search.
 
Args:
    train_series (array-like): The training time series data.
    test_series (array-like): The testing time series data.
    max_p (int): Maximum order for AR component.
    max_d (int): Maximum degree of differencing.
    max_q (int): Maximum order for MA component.
    subset_size (float): Proportion of the training set to use for fitting.
 
Returns:
    tuple: The best order (p, d, q).
suggest_order(time_series, max_p=5, max_d=2, max_q=5)
Suggest the optimal ARIMA order (p, d, q) for the given time series.
 
Args:
    time_series (array-like): The time series data.
    max_p (int): Maximum order for AR component.
    max_d (int): Maximum degree of differencing.
    max_q (int): Maximum order for MA component.
 
Returns:
    tuple: The optimal order (p, d, q).

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class Activation(builtins.object)
    This class contains various activation functions and their corresponding derivatives for use in neural networks.
 
Methods:
    relu: Rectified Linear Unit activation function. Returns the input directly if it's positive, otherwise returns 0.
    leaky_relu: Leaky ReLU activation function. A variant of ReLU that allows a small gradient when the input is negative.
    tanh: Hyperbolic tangent activation function. Maps input to range [-1, 1]. Commonly used for normalized input.
    sigmoid: Sigmoid activation function. Maps input to range [0, 1]. Commonly used for binary classification.
    softmax: Softmax activation function. Maps input into a probability distribution over multiple classes.
 
  Static methods defined here:
leaky_relu(z, alpha=0.01)
Leaky ReLU activation function: f(z) = z if z > 0, else alpha * z.
 
Allows a small, non-zero gradient when the input is negative to address the dying ReLU problem.
leaky_relu_derivative(z, alpha=0.01)
Derivative of the Leaky ReLU function: f'(z) = 1 if z > 0, else alpha.
 
Returns 1 for positive input, and alpha for negative input.
relu(z)
ReLU (Rectified Linear Unit) activation function: f(z) = max(0, z).
 
Returns the input directly if it's positive, otherwise returns 0.
relu_derivative(z)
Derivative of the ReLU function: f'(z) = 1 if z > 0, else 0.
 
Returns 1 for positive input, and 0 for negative input.
sigmoid(z)
Sigmoid activation function: f(z) = 1 / (1 + exp(-z)).
 
Maps input to the range [0, 1], commonly used for binary classification.
sigmoid_derivative(z)
Derivative of the sigmoid function: f'(z) = sigmoid(z) * (1 - sigmoid(z)).
 
Used for backpropagation through the sigmoid activation.
softmax(z)
Softmax activation function: f(z)_i = exp(z_i) / sum(exp(z_j)) for all j.
 
Maps input into a probability distribution over multiple classes. Used for multiclass classification.
tanh(z)
Hyperbolic tangent (tanh) activation function: f(z) = (exp(z) - exp(-z)) / (exp(z) + exp(-z)).
 
Maps input to the range [-1, 1], typically used for normalized input.
tanh_derivative(z)
Derivative of the tanh function: f'(z) = 1 - tanh(z)^2.
 
Used for backpropagation through the tanh activation.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class AdaBoostClassifier(builtins.object)
    AdaBoostClassifier(base_estimator=None, n_estimators=50, learning_rate=1.0, random_state=None, max_depth=3, min_samples_split=2)
 
AdaBoost classifier.
 
Builds an additive model by sequentially fitting weak classifiers (default: decision stumps)
on modified versions of the data. Each subsequent classifier focuses more on samples
that were misclassified by the previous ensemble.
 
Uses the SAMME algorithm which supports multi-class classification.
 
Attributes:
    base_estimator_ (object): The base estimator template used for fitting.
    n_estimators (int): The maximum number of estimators at which boosting is terminated.
    learning_rate (float): Weight applied to each classifier's contribution.
    estimators_ (list): The collection of fitted base estimators.
    estimator_weights_ (np.ndarray): Weights for each estimator.
    estimator_errors_ (np.ndarray): Classification error for each estimator.
    classes_ (np.ndarray): The class labels.
    n_classes_ (int): The number of classes.
 
  Methods defined here:
__init__(self, base_estimator=None, n_estimators=50, learning_rate=1.0, random_state=None, max_depth=3, min_samples_split=2)
Initialize the AdaBoostClassifier.
 
Args:
    base_estimator (object, optional): The base estimator from which the boosted ensemble is built.
                                      Support for sample weighting is required. If None, then
                                      the base estimator is DecisionTreeClassifier(max_depth=1).
    n_estimators (int, optional): The maximum number of estimators at which boosting is terminated.
                                  In case of perfect fit, the learning procedure is stopped early. Defaults to 50.
    learning_rate (float, optional): Weight applied to each classifier's contribution. Defaults to 1.0.
    random_state (int, optional): Controls the random seed given to the base estimator at each boosting iteration.
                                  Defaults to None.
    max_depth (int, optional): The maximum depth of the base estimator. Defaults to 3.
    min_samples_split (int, optional): The minimum number of samples required to split an internal node
                                       when using the default `ClassifierTree` base estimator. Defaults to 2.
decision_function(self, X)
Compute the decision function of X.
fit(self, X, y)
Build a boosted classifier from the training set (X, y).
get_stats(self, y_true, X=None, y_pred=None, verbose=False)
Calculate and optionally print evaluation metrics. Requires either X or y_pred.
predict(self, X)
Predict classes for X.
predict_proba(self, X)
Predict class probabilities for X.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class AdaBoostRegressor(builtins.object)
    AdaBoostRegressor(base_estimator=None, n_estimators=50, learning_rate=1.0, loss='linear', random_state=None, max_depth=3, min_samples_split=2)
 
AdaBoost regressor.
 
Builds an additive model by sequentially fitting weak regressors (default: decision trees)
on modified versions of the data. The weights of instances are adjusted at each iteration
so that subsequent regressors focus more on instances with larger errors.
 
Uses the AdaBoost.R2 algorithm.
 
Attributes:
    base_estimator_ (object): The base estimator template used for fitting.
    n_estimators (int): The maximum number of estimators at which boosting is terminated.
    learning_rate (float): Contribution of each regressor to the final prediction.
    loss (str): The loss function to use when updating the weights ('linear', 'square', 'exponential').
    estimators_ (list): The collection of fitted base estimators.
    estimator_weights_ (np.ndarray): Weights for each estimator (alpha values, specifically log(1/beta)).
    estimator_errors_ (np.ndarray): Loss value for each estimator on the weighted training data.
 
  Methods defined here:
__init__(self, base_estimator=None, n_estimators=50, learning_rate=1.0, loss='linear', random_state=None, max_depth=3, min_samples_split=2)
Initialize the AdaBoostRegressor.
 
Args:
    base_estimator (object, optional): The base estimator from which the boosted ensemble is built.
                                      Support for sample weighting is required. If None, then
                                      the base estimator is DecisionTreeRegressor(max_depth=3).
    n_estimators (int, optional): The maximum number of estimators. Defaults to 50.
    learning_rate (float, optional): Shrinks the contribution of each regressor by learning_rate. Defaults to 1.0.
    loss (str, optional): The loss function to use when updating sample weights ('linear', 'square', 'exponential').
                          Defaults to 'linear'.
    random_state (int, optional): Controls the random seed. Defaults to None.
    max_depth (int, optional): Maximum depth of the base estimator. Defaults to 3.
    min_samples_split (int, optional): Minimum number of samples required to split an internal node. Defaults to 2.
fit(self, X, y)
Build a boosted regressor from the training set (X, y).
get_stats(self, y_true, X=None, y_pred=None, verbose=False)
Calculate and optionally print evaluation metrics. Requires either X or y_pred.
predict(self, X)
Predict regression target for X.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class AdadeltaOptimizer(builtins.object)
    AdadeltaOptimizer(learning_rate=1.0, rho=0.95, epsilon=1e-06, reg_lambda=0.0)
 
Adadelta optimizer class for training neural networks.
 
Formula:
    E[g^2]_t = rho * E[g^2]_{t-1} + (1 - rho) * g^2
    Delta_x = - (sqrt(E[delta_x^2]_{t-1} + epsilon) / sqrt(E[g^2]_t + epsilon)) * g
    E[delta_x^2]_t = rho * E[delta_x^2]_{t-1} + (1 - rho) * Delta_x^2
Derived from: https://arxiv.org/abs/1212.5701
 
Args:
    learning_rate (float, optional): The learning rate for the optimizer. Defaults to 1.0.
    rho (float, optional): The decay rate. Defaults to 0.95.
    epsilon (float, optional): A small value to prevent division by zero. Defaults to 1e-6.
    reg_lambda (float, optional): The regularization parameter. Defaults to 0.0.
 
  Methods defined here:
__init__(self, learning_rate=1.0, rho=0.95, epsilon=1e-06, reg_lambda=0.0)
Initializes the optimizer with the specified hyperparameters.
 
Args:
    learning_rate (float, optional): The learning rate for the optimizer. Defaults to 1.0.
    rho (float, optional): The decay rate for the running averages. Defaults to 0.95.
    epsilon (float, optional): A small value to prevent division by zero. Defaults to 1e-6.
    reg_lambda (float, optional): The regularization parameter for weight decay. Defaults to 0.0.
initialize(self, layers)
Initializes the running averages for each layer's weights.
 
Args:
    layers (list): List of layers in the neural network.
 
Returns:
    None
update(self, layer, dW, db, index)
Updates the weights and biases of a layer using the Adadelta optimization algorithm.
 
Args:
    layer (Layer): The layer to update.
    dW (ndarray): The gradient of the weights.
    db (ndarray): The gradient of the biases.
    index (int): The index of the layer.
 
Returns:
    None

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class AdamOptimizer(builtins.object)
    AdamOptimizer(learning_rate=0.001, beta1=0.9, beta2=0.999, epsilon=1e-08, reg_lambda=0.01)
 
Adam optimizer class for training neural networks.
 
Formula: w = w - alpha * m_hat / (sqrt(v_hat) + epsilon) - lambda * w
Derived from: https://arxiv.org/abs/1412.6980
 
Args:
    learning_rate (float, optional): The learning rate for the optimizer. Defaults to 0.001.
    beta1 (float, optional): The exponential decay rate for the first moment estimates. Defaults to 0.9.
    beta2 (float, optional): The exponential decay rate for the second moment estimates. Defaults to 0.999.
    epsilon (float, optional): A small value to prevent division by zero. Defaults to 1e-8.
    reg_lambda (float, optional): The regularization parameter. Defaults to 0.01.
 
  Methods defined here:
__init__(self, learning_rate=0.001, beta1=0.9, beta2=0.999, epsilon=1e-08, reg_lambda=0.01)
Initializes the optimizer with the given hyperparameters.
 
Args:
    learning_rate (float, optional): The learning rate (alpha) for the optimizer. Defaults to 0.001.
    beta1 (float, optional): Exponential decay rate for the first moment estimates. Defaults to 0.9.
    beta2 (float, optional): Exponential decay rate for the second moment estimates. Defaults to 0.999.
    epsilon (float, optional): A small value to prevent division by zero. Defaults to 1e-8.
    reg_lambda (float, optional): Regularization parameter; higher values indicate stronger regularization. Defaults to 0.01.
 
Attributes:
    learning_rate (float): The learning rate for the optimizer.
    beta1 (float): Exponential decay rate for the first moment estimates.
    beta2 (float): Exponential decay rate for the second moment estimates.
    epsilon (float): A small value to prevent division by zero.
    reg_lambda (float): Regularization parameter for controlling overfitting.
    m (list): List to store first moment estimates for each parameter.
    v (list): List to store second moment estimates for each parameter.
    t (int): Time step counter for the optimizer.
initialize(self, layers)
Initializes the first and second moment estimates for each layer's weights.
 
Args:
    layers (list): List of layers in the neural network.
 
Returns:
    None
update(self, layer, dW, db, index)
Updates the weights and biases of a layer using the Adam optimization algorithm.
 
Args:
    layer (Layer): The layer to update.
    dW (ndarray): The gradient of the weights.
    db (ndarray): The gradient of the biases.
    index (int): The index of the layer.
Returns: None

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class AdditiveDecomposition(builtins.object)
    AdditiveDecomposition(period)
 
Performs classical additive decomposition of a time series.
 
Decomposes the series Y into Trend (T), Seasonal (S), and Residual (R) components
such that Y = T + S + R. Assumes seasonality is constant over time.
 
Attributes:
    period (int): The seasonal period.
    time_series (np.ndarray): The original time series data.
    trend (np.ndarray): The estimated trend component.
    seasonal (np.ndarray): The estimated seasonal component.
    residual (np.ndarray): The estimated residual component.
 
  Methods defined here:
__init__(self, period)
Initialize the AdditiveDecomposition model.
 
Args:
    period (int): The seasonal period (e.g., 12 for monthly, 7 for daily). Must be > 1.
__str__(self)
Return str(self).
fit(self, time_series)
Perform additive decomposition on the time series.
 
Args:
    time_series (array-like): The time series data. Must be 1-dimensional and have length >= 2 * period.
 
Returns:
    tuple: The calculated trend, seasonal, and residual components.
get_components(self)
Return the calculated components.
reconstruct(self)
Reconstruct the series from components (Y = T + S + R).

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class AnimationBase(abc.ABC)
    AnimationBase(model, train_series, test_series, dynamic_parameter=None, static_parameters=None, keep_previous=None, **kwargs)
 
Base class for creating animations of machine learning models.
 
 
Method resolution order:
AnimationBase
abc.ABC
builtins.object

Methods defined here:
__init__(self, model, train_series, test_series, dynamic_parameter=None, static_parameters=None, keep_previous=None, **kwargs)
Initialize the animation base class.
 
Args:
    model: The forecasting model or any machine learning model.
    train_series: Training time series data.
    test_series: Testing time series data.
    dynamic_parameter: The parameter to update dynamically (e.g., 'window', 'alpha', 'beta').
    static_parameters: Static parameters for the model.
        Should be a dictionary with parameter names as keys and their values.
    keep_previous: Whether to keep all previous lines with reduced opacity.
    **kwargs: Additional customization options (e.g., colors, line styles).
animate(self, frames, interval=150, blit=True, repeat=False)
Create the animation.
 
Args:
    frames: Range of frames (e.g., window sizes).
    interval: Delay between frames in milliseconds.
    blit: Whether to use blitting for faster rendering.
    repeat: Whether to repeat the animation.
save(self, filename, writer='pillow', fps=5, dpi=100)
Save the animation to a file.
 
Args:
    filename: Path to save the animation.
    writer: Writer to use (e.g., 'pillow' for GIF).
    fps: Frames per second.
    dpi: Dots per inch for the saved figure.
setup_plot(self, title, xlabel, ylabel, legend_loc='upper left', grid=True, figsize=(12, 6))
Set up the plot for the animation.
 
Args:
    title: Title of the plot.
    xlabel: Label for the x-axis.
    ylabel: Label for the y-axis.
    legend_loc: Location of the legend.
    grid: Whether to show grid lines.
    figsize: Size of the figure.
show(self)
Display the animation.
update_model(self, frame)
Abstract method to update the model for a given frame. Must be implemented by subclasses.
update_plot(self, frame)
Abstract method to update the plot for a given frame.Must be implemented by subclasses.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Data and other attributes defined here:
__abstractmethods__ = frozenset({'update_model', 'update_plot'})

 
class Augmenter(builtins.object)
    Augmenter(techniques, verbose=False)
 
General class for data augmentation techniques.
 
This class allows for the application of multiple augmentation techniques in sequence.
 
  Methods defined here:
__init__(self, techniques, verbose=False)
Initializes the Augmenter with a list of techniques and verbosity option.
augment(self, X, y)
Applies multiple augmentation techniques in sequence.
 
Args:
    X: (np.ndarray) - Feature matrix.
    y: (np.ndarray) - Target vector.
 
Returns:
    tuple: (np.ndarray, np.ndarray) - Augmented feature matrix and target vector.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class AutoClassifier(builtins.object)
    AutoClassifier(all_kernels=False, tune_hyperparameters=False, tuning_method='random', tuning_iterations=10, cv=3, tuning_metric='f1')
 
A class to automatically select and evaluate the best classification model.
 
Includes optional automated hyperparameter tuning using GridSearchCV or RandomSearchCV.
 
  Methods defined here:
__init__(self, all_kernels=False, tune_hyperparameters=False, tuning_method='random', tuning_iterations=10, cv=3, tuning_metric='f1')
Initializes the AutoClassifier.
 
Args:
    all_kernels (bool): If True, include all SVM kernels. Default False.
    tune_hyperparameters (bool): If True, perform hyperparameter tuning. Default False.
    tuning_method (str): Method for tuning ('random' or 'grid'). Default 'random'.
    tuning_iterations (int): Number of iterations for Random Search. Default 10.
    cv (int): Number of cross-validation folds for tuning. Default 3.
    tuning_metric (str): Metric to optimize ('accuracy', 'precision', 'recall', 'f1'). Default 'f1'.
evaluate(self, y_true, custom_metrics=None, model=None)
Evaluates the performance using stored predictions.
 
Args:
    y_true: (np.ndarray) - True target values.
    custom_metrics: (dict), optional - Custom metrics. Default None.
    model: (str), optional - Specific model name. Default None (evaluate all).
 
Returns:
    dict: Evaluation metrics for the specified model(s).
fit(self, X_train, y_train, X_test=None, y_test=None, custom_metrics=None, verbose=False)
Fits the classification models, optionally performing hyperparameter tuning.
 
Args:
    X_train: (np.ndarray) - Training feature data.
    y_train: (np.ndarray) - Training target data.
    X_test: (np.ndarray), optional - Testing feature data. Default None.
    y_test: (np.ndarray), optional - Testing target data. Default None.
    custom_metrics: (dict: str -> callable), optional - Custom metrics for evaluation.
    verbose: (bool), optional - If True, prints progress. Default False.
 
Returns:
    results: (list) - A list of dictionaries containing model performance metrics.
    predictions: (dict) - A dictionary of predictions for each model on the test/train set.
get_model(self, model_name)
Returns the final fitted model instance (potentially tuned).
 
Args:
    model_name (str): The name of the model.
 
Returns:
    model_instance: The fitted model instance.
predict(self, X, model=None)
Generates predictions using fitted models.
 
Args:
    X: (np.ndarray) - Input feature data.
    model: (str), optional - Specific model name. Default None (predict with all).
 
Returns:
    dict or np.ndarray: Predictions for specified model(s).
summary(self)
Prints a summary of model performance, including tuning results if available.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class AutoRegressor(builtins.object)
    AutoRegressor(all_kernels=False, tune_hyperparameters=False, tuning_method='random', tuning_iterations=10, cv=3, tuning_metric='r2')
 
A class to automatically select and evaluate the best regression model.
 
Includes optional automated hyperparameter tuning using GridSearchCV or RandomSearchCV.
 
  Methods defined here:
__init__(self, all_kernels=False, tune_hyperparameters=False, tuning_method='random', tuning_iterations=10, cv=3, tuning_metric='r2')
Initializes the AutoRegressor.
 
Args:
    all_kernels (bool): If True, include all SVM kernels. Default False.
    tune_hyperparameters (bool): If True, perform hyperparameter tuning. Default False.
    tuning_method (str): Method for tuning ('random' or 'grid'). Default 'random'.
    tuning_iterations (int): Number of iterations for Random Search. Default 10.
    cv (int): Number of cross-validation folds for tuning. Default 3.
    tuning_metric (str): Metric to optimize ('r2', 'neg_mean_squared_error', 'rmse', 'mae', 'mape'). Default 'r2'.
                       Note: for minimization use 'neg_mean_squared_error', 'rmse', 'mae', 'mape'.
evaluate(self, y_true, custom_metrics=None, model=None)
Evaluates performance using stored predictions.
 
Args:
    y_true: (np.ndarray) - True target values.
    custom_metrics: (dict), optional - Custom metrics. Default None.
    model: (str), optional - Specific model name. Default None (evaluate all).
 
Returns:
    dict: Evaluation metrics.
fit(self, X_train, y_train, X_test=None, y_test=None, custom_metrics=None, verbose=False)
Fits the regression models, optionally performing hyperparameter tuning.
 
Args:
    X_train: (np.ndarray) - Training feature data.
    y_train: (np.ndarray) - Training target data.
    X_test: (np.ndarray), optional - Testing feature data. Default None.
    y_test: (np.ndarray), optional - Testing target data. Default None.
    custom_metrics: (dict: str -> callable), optional - Custom metrics.
    verbose: (bool), optional - If True, prints progress. Default False.
 
Returns:
    results: (list) - Performance metrics for each model.
    predictions: (dict) - Predictions for each model on the test/train set.
get_model(self, model_name)
Returns the final fitted model instance (potentially tuned).
predict(self, X, model=None)
Generates predictions using fitted models.
 
Args:
    X: (np.ndarray) - Input feature data.
    model: (str), optional - Specific model name. Default None (predict with all).
 
Returns:
    dict or np.ndarray: Predictions for specified model(s).
summary(self)
Prints a summary of model performance, including tuning results.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class BCEWithLogitsLoss(builtins.object)
    Custom binary cross entropy loss with logits implementation using numpy.
 
Formula: -mean(y * log(p) + (1 - y) * log(1 - p))
 
Methods:
    __call__(self, logits, targets): Calculate the binary cross entropy loss.
 
  Methods defined here:
__call__(self, logits, targets)
Calculate the binary cross entropy loss.
 
Args:
    logits (np.ndarray): The logits (predicted values) of shape (num_samples,).
    targets (np.ndarray): The target labels of shape (num_samples,).
 
Returns:
    float: The binary cross entropy loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class BaseBackendNeuralNetwork(sega_learn.neural_networks.neuralNetworkBase.NeuralNetworkBase)
    BaseBackendNeuralNetwork(layers, dropout_rate=0.2, reg_lambda=0.01, activations=None, loss_function=None, regressor=False)
 
A class representing a backend implementation of a neural network with support for forward propagation, backward propagation, training, evaluation, and hyperparameter tuning.
 
This class extends the `NeuralNetworkBase` class and provides additional functionality
for managing layers, applying dropout, calculating loss, and optimizing weights and biases.
 
Attributes:
    layers (list): List of layer objects in the neural network.
    layer_outputs (list): Outputs of each layer during forward propagation.
    weights (list): Weights of each layer.
    biases (list): Biases of each layer.
    train_loss (list): Training loss values over epochs.
    train_accuracy (list): Training accuracy values over epochs.
    val_loss (list): Validation loss values over epochs.
    val_accuracy (list): Validation accuracy values over epochs.
    train_precision (list): Training precision values over epochs.
    train_recall (list): Training recall values over epochs.
    train_f1 (list): Training F1-score values over epochs.
    val_precision (list): Validation precision values over epochs.
    val_recall (list): Validation recall values over epochs.
    val_f1 (list): Validation F1-score values over epochs.
    learning_rates (list): Learning rates over epochs.
 
Methods:
    __init__(layers, dropout_rate=0.2, reg_lambda=0.01, activations=None, loss_function=None, regressor=False):
        Initializes the neural network with the specified layers, dropout rate,
        regularization parameter, activation functions, and optional loss function.
    initialize_new_layers():
        Initializes the layers of the neural network with random weights and biases.
    forward(X, training=True):
        Performs forward propagation through the neural network.
    backward(y):
        Performs backward propagation to calculate gradients for weight and bias updates.
    fit(X_train, y_train, X_val=None, y_val=None, optimizer=None, epochs=100, batch_size=32, ...):
        Fits the neural network to the training data.
    train(X_train, y_train, X_val=None, y_val=None, optimizer=None, epochs=100, batch_size=32, ...):
        Trains the neural network model with optional validation and early stopping.
    evaluate(X, y):
        Evaluates the model on the given data and returns accuracy and predictions.
    predict(X):
        Predicts the output for the given input data.
    calculate_loss(X, y):
        Calculates the loss with L2 regularization for the given input and target labels.
    _create_optimizer(optimizer_type, learning_rate, JIT=False):
        Helper method to create optimizer instances based on the specified type.
    tune_hyperparameters(X_train, y_train, X_val, y_val, param_grid, ...):
        Performs hyperparameter tuning using grid search.
    train_with_animation_capture(X_train, y_train, X_val=None, y_val=None, ...):
        Trains the neural network while capturing training metrics in real-time animation.
 
 
Method resolution order:
BaseBackendNeuralNetwork
sega_learn.neural_networks.neuralNetworkBase.NeuralNetworkBase
builtins.object

Methods defined here:
__init__(self, layers, dropout_rate=0.2, reg_lambda=0.01, activations=None, loss_function=None, regressor=False)
Initializes the Numba backend neural network.
 
Args:
    layers: (list) - List of layer sizes or Layer objects.
    dropout_rate: (float) - Dropout rate for regularization.
    reg_lambda: (float) - L2 regularization parameter.
    activations: (list) - List of activation functions for each layer.
    loss_function: (callable) optional - Custom loss function to use (default is None, which uses the default calculate_loss implementation).
    regressor: (bool) - Whether the model is a regressor (default is False).
backward(self, y)
Performs backward propagation to calculate the gradients.
 
Args:
    y: (ndarray) - Target labels of shape (m, output_size).
calculate_loss(self, X, y)
Calculates the loss with L2 regularization.
 
Args:
    X: (np.ndarray) - Input feature data.
    y: (np.ndarray) - Target labels.
 
Returns:
    loss: (float) - The calculated loss value with L2 regularization.
evaluate(self, X, y)
Evaluates the model's performance on the given data.
 
Args:
    X: (np.ndarray) - Input feature data for evaluation.
    y: (np.ndarray) - True target labels corresponding to the input data.
 
Returns:
    metric: (float) - The evaluation metric (accuracy for classification, MSE for regression).
    predicted: (np.ndarray) - The predicted labels or values for the input data.
fit(self, X_train, y_train, X_val=None, y_val=None, optimizer=None, epochs=100, batch_size=32, early_stopping_threshold=10, lr_scheduler=None, p=False, use_tqdm=False, n_jobs=1, track_metrics=False, track_adv_metrics=False, save_animation=False, save_path='training_animation.mp4', fps=1, dpi=100, frame_every=1)
Fits the neural network to the training data.
forward(self, X, training=True)
Performs forward propagation through the neural network.
 
Args:
    X: (ndarray): - Input data of shape (batch_size, input_size).
    training: (bool) - Whether the network is in training mode (applies dropout).
 
Returns:
    ndarray: Output predictions of shape (batch_size, output_size).
initialize_new_layers(self)
Initializes the layers of the neural network.
 
Each layer is created with the specified number of neurons and activation function.
predict(self, X)
Generates predictions for the given input data.
 
Args:
    X: (np.ndarray) - Input feature data for which predictions are to be made.
 
Returns:
    outputs: (np.ndarray) - Predicted outputs. If the model is binary, returns the raw outputs.
                Otherwise, returns the class indices with the highest probability.
train(self, X_train, y_train, X_val=None, y_val=None, optimizer=None, epochs=100, batch_size=32, early_stopping_threshold=10, lr_scheduler=None, p=True, use_tqdm=True, n_jobs=1, track_metrics=False, track_adv_metrics=False, save_animation=False, save_path='training_animation.mp4', fps=1, dpi=100, frame_every=1)
Trains the neural network model.
 
Args:
    X_train: (ndarray) - Training data features.
    y_train: (ndarray) - Training data labels.
    X_val: (ndarray) - Validation data features, optional.
    y_val: (ndarray) - Validation data labels, optional.
    optimizer: (Optimizer) - Optimizer for updating parameters (default: Adam, lr=0.0001).
    epochs: (int) - Number of training epochs (default: 100).
    batch_size: (int) - Batch size for mini-batch gradient descent (default: 32).
    early_stopping_threshold: (int) - Patience for early stopping (default: 10).
    lr_scheduler: (Scheduler) - Learning rate scheduler (default: None).
    p: (bool) - Whether to print training progress (default: True).
    use_tqdm: (bool) - Whether to use tqdm for progress bar (default: True).
    n_jobs: (int) - Number of jobs for parallel processing (default: 1).
    track_metrics: (bool) - Whether to track training metrics (default: False).
    track_adv_metrics: (bool) - Whether to track advanced metrics (default: False).
    save_animation: (bool) - Whether to save the animation of metrics (default: False).
    save_path: (str) - Path to save the animation file. File extension must be .mp4 or .gif (default: 'training_animation.mp4').
    fps: (int) - Frames per second for the saved animation (default: 1).
    dpi: (int) - DPI for the saved animation (default: 100).
    frame_every: (int) - Capture frame every N epochs (to reduce file size) (default: 1).
train_with_animation_capture(self, X_train, y_train, X_val=None, y_val=None, optimizer=None, epochs=100, batch_size=32, early_stopping_threshold=10, lr_scheduler=None, save_path='training_animation.mp4', fps=1, dpi=100, frame_every=1)
Trains the neural network model while capturing training metrics in real-time animation.
 
Args:
    X_train: (np.ndarray) - Training feature data.
    y_train: (np.ndarray) - Training target data.
    X_val: (np.ndarray), optional - Validation feature data (default is None).
    y_val: (np.ndarray), optional - Validation target data (default is None).
    optimizer: (Optimizer), optional - Optimizer for updating parameters (default is None).
    epochs: (int), optional - Number of training epochs (default is 100).
    batch_size: (int), optional - Batch size for mini-batch gradient descent (default is 32).
    early_stopping_threshold: (int), optional - Patience for early stopping (default is 10).
    lr_scheduler: (Scheduler), optional - Learning rate scheduler (default is None).
    save_path: (str), optional - Path to save the animation file (default is 'training_animation.mp4').
    fps: (int), optional - Frames per second for the saved animation (default is 1).
    dpi: (int), optional - DPI for the saved animation (default is 100).
    frame_every: (int), optional - Capture frame every N epochs (default is 1).
 
Returns:
    None
tune_hyperparameters(self, X_train, y_train, X_val, y_val, param_grid, layer_configs=None, optimizer_types=None, lr_range=(0.0001, 0.01, 5), epochs=30, batch_size=32)
Performs hyperparameter tuning using grid search.
 
Args:
    X_train: (np.ndarray) - Training feature data.
    y_train: (np.ndarray) - Training target data.
    X_val: (np.ndarray) - Validation feature data.
    y_val: (np.ndarray) - Validation target data.
    param_grid: (dict) - Dictionary of parameters to try.
    layer_configs: (list), optional - List of layer configurations (default is None).
    optimizer_types: (list), optional - List of optimizer types (default is None).
    lr_range: (tuple) - Tuple of (min_lr, max_lr, num_steps) for learning rates.
    epochs: (int) - Maximum epochs for each trial.
    batch_size: (int) - Batch size for training.
 
Returns:
    best_params: (dict) - Best hyperparameters found.
    best_accuracy: (float) - Best validation accuracy.

Methods inherited from sega_learn.neural_networks.neuralNetworkBase.NeuralNetworkBase:
apply_dropout(self, X)
Applies dropout to the activation X.
 
Args:
    X: (ndarray) - Activation values.
 
Returns:
    ndarray: Activation values after applying dropout.
calculate_precision_recall_f1(self, X, y)
Calculates precision, recall, and F1 score.
 
Args:
    X: (ndarray) - Input data
    y: (ndarray) - Target labels
Returns:
    precision: (float) - Precision score
    recall: (float) - Recall score
    f1: (float) - F1 score
compute_l2_reg(self, weights)
Computes the L2 regularization term.
 
Args:
    weights: (list) - List of weight matrices.
 
Returns:
    float: L2 regularization term.
create_scheduler(self, scheduler_type, optimizer, **kwargs)
Creates a learning rate scheduler.
initialize_layers(self)
Initializes the weights and biases of the layers.
plot_metrics(self, save_dir=None)
Plots the training and validation metrics.

Data descriptors inherited from sega_learn.neural_networks.neuralNetworkBase.NeuralNetworkBase:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class BaseSVM(builtins.object)
    BaseSVM(C=1.0, tol=0.0001, max_iter=1000, learning_rate=0.01, kernel='linear', degree=3, gamma='scale', coef0=0.0, regression=False)
 
BaseSVM: A base class for Support Vector Machines (SVM) with kernel support.
 
This class provides the foundation for implementing SVM models with various kernels
and supports both classification and regression tasks.
 
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 optimization. Default is 1000.
    learning_rate (float): Step size for optimization. Default is 0.01.
    kernel (str): Kernel type ('linear', 'poly', 'rbf', or 'sigmoid'). Default is 'linear'.
    degree (int): Degree for polynomial kernel. Default is 3.
    gamma (str or float): Kernel coefficient ('scale', 'auto', or float). Default is 'scale'.
    coef0 (float): Independent term in poly and sigmoid kernels. Default is 0.0.
    regression (bool): Whether to use regression (SVR) or classification (SVC). Default is False.
    w (ndarray): Weight vector for linear kernel.
    b (float): Bias term.
    support_vectors_ (ndarray): Support vectors identified during training.
    support_vector_labels_ (ndarray): Labels of the support vectors.
    support_vector_alphas_ (ndarray): Lagrange multipliers for the support vectors.
 
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, regression=False):
        Initializes the BaseSVM instance with specified hyperparameters.
    fit(self, X, y=None):
        Fits the SVM model to the training data.
    _fit(self, X, y):
        Abstract method to be implemented by subclasses for training.
    _compute_kernel(self, X1, X2):
        Computes the kernel function between two input matrices.
    decision_function(self, X):
        Computes the decision function for input samples.
    predict(self, X):
        Predicts class labels for input samples.
    score(self, X, y):
        Computes the mean accuracy of the model on the given test data.
    get_params(self, deep=True):
        Retrieves the hyperparameters of the model.
    set_params(self, **parameters):
        Sets the hyperparameters of the model.
    __sklearn_is_fitted__(self):
        Checks if the model has been fitted (for sklearn compatibility).
 
  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, regression=False)
Initializes the BaseSVM instance 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 optimization. Default is 1000.
    learning_rate: (float) - Step size for optimization. Default is 0.01.
    kernel: (str) - Kernel type ('linear', 'poly', 'rbf', or 'sigmoid'). Default is 'linear'.
    degree: (int) - Degree for polynomial kernel. Default is 3.
    gamma: (str or float) - Kernel coefficient ('scale', 'auto', or float). Default is 'scale'.
    coef0: (float) - Independent term in poly and sigmoid kernels. Default is 0.0.
    regression: (bool) - Whether to use regression (SVR) or classification (SVC). Default is False.
__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.
decision_function(self, X)
Computes the decision function for input samples.
 
Args:
    X: (array-like of shape (n_samples, n_features)) - Input samples.
 
Returns:
    decision_values: (ndarray of shape (n_samples,)) - Decision function values.
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 defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class Bayesian(builtins.object)
    Bayesian(max_iter=300, tol=0.001, alpha_1=1e-06, alpha_2=1e-06, lambda_1=1e-06, lambda_2=1e-06, fit_intercept=None)
 
Fits the Bayesian Regression model to the training data using Coordinate Descent.
 
Args:
    X_train: (np.ndarray) - Training feature data.
    y_train: (np.ndarray) - Training target data.
    X_test: (np.ndarray), optional - Testing feature data (default is None).
    y_test: (np.ndarray), optional - Testing target data (default is None).
    max_iter: (int), optional - The maximum number of iterations to perform (default is 300).
    tol: (float), optional - The convergence threshold. The algorithm stops when the coefficients change less than this threshold (default is 0.001).
    alpha_1: (float), optional - The shape parameter for the prior on the weights (default is 1e-06).
    alpha_2: (float), optional - The scale parameter for the prior on the weights (default is 1e-06).
    lambda_1: (float), optional - The shape parameter for the prior on the noise (default is 1e-06).
    lambda_2: (float), optional - The scale parameter for the prior on the noise (default is 1e-06).
    fit_intercept: (bool), optional - Whether to calculate the intercept for this model (default is True).
 
Returns:
    intercept_: (float) - The intercept of the model.
    coef_: (np.ndarray) - Estimated coefficients for the linear regression problem. If `fit_intercept` is True, the first element is the intercept.
    n_iter_: (int) - The number of iterations performed.
    alpha_: (float) - The precision of the weights.
    lambda_: (float) - The precision of the noise.
    sigma_: (np.ndarray) - The posterior covariance of the weights.
 
  Methods defined here:
__init__(self, max_iter=300, tol=0.001, alpha_1=1e-06, alpha_2=1e-06, lambda_1=1e-06, lambda_2=1e-06, fit_intercept=None)
Implements Bayesian Regression using Coordinate Descent.
 
Bayesian regression applies both L1 and L2 regularization to prevent overfitting by adding penalty terms to the loss function.
 
Args:
    max_iter: (int) - The maximum number of iterations to perform (default is 300).
    tol: (float) - The convergence threshold. The algorithm stops when the coefficients change less than this threshold (default is 0.001).
    alpha_1: (float) - The shape parameter for the prior on the weights (default is 1e-06).
    alpha_2: (float) - The scale parameter for the prior on the weights (default is 1e-06).
    lambda_1: (float) - The shape parameter for the prior on the noise (default is 1e-06).
    lambda_2: (float) - The scale parameter for the prior on the noise (default is 1e-06).
    fit_intercept: (bool), optional - Whether to calculate the intercept for this model (default is True).
 
Returns:
    intercept_: (float) - The intercept of the model.
    coef_: (np.ndarray) - Estimated coefficients for the linear regression problem. If `fit_intercept` is True, the first element is the intercept.
    n_iter_: (int) - The number of iterations performed.
    alpha_: (float) - The precision of the weights.
    lambda_: (float) - The precision of the noise.
    sigma_: (np.ndarray) - The posterior covariance of the weights.
__str__(self)
Returns the string representation of the model.
fit(self, X, y)
Fits the Bayesian Regression model to the training data.
 
Args:
    X: (np.ndarray) - Training feature data of shape (n_samples, n_features).
    y: (np.ndarray) - Training target data of shape (n_samples,).
 
Returns:
    self: (Bayesian) - The fitted Bayesian Regression model.
get_formula(self)
Computes the formula of the model.
 
Returns:
    formula: (str) - The formula of the model as a string.
predict(self, X)
Predicts the target values using the Bayesian Regression model.
 
Args:
    X: (np.ndarray) - Feature data of shape (n_samples, n_features).
 
Returns:
    y_pred: (np.ndarray) - Predicted target values of shape (n_samples,).
tune(self, X, y, beta1=0.9, beta2=0.999, iter=1000)
Tunes the hyperparameters alpha_1, alpha_2, lambda_1, and lambda_2 using ADAM optimizer.
 
Args:
    X: (np.ndarray) - Training feature data of shape (n_samples, n_features).
    y: (np.ndarray) - Training target data of shape (n_samples,).
    beta1: (float), optional - The exponential decay rate for the first moment estimates (default is 0.9).
    beta2: (float), optional - The exponential decay rate for the second moment estimates (default is 0.999).
    iter: (int), optional - The maximum number of iterations to perform (default is 1000).
 
Returns:
    best_alpha_1: (float) - The best value of alpha_1.
    best_alpha_2: (float) - The best value of alpha_2.
    best_lambda_1: (float) - The best value of lambda_1.
    best_lambda_2: (float) - The best value of lambda_2.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ClassificationAnimation(AnimationBase)
    ClassificationAnimation(model, X, y, test_size=0.3, dynamic_parameter=None, static_parameters=None, keep_previous=False, scaler=None, pca_components=2, plot_step=0.02, **kwargs)
 
Class for creating animations of classification models.
 
 
Method resolution order:
ClassificationAnimation
AnimationBase
abc.ABC
builtins.object

Methods defined here:
__init__(self, model, X, y, test_size=0.3, dynamic_parameter=None, static_parameters=None, keep_previous=False, scaler=None, pca_components=2, plot_step=0.02, **kwargs)
Initialize the classification animation class.
 
Args:
    model: The classification model.
    X: Feature matrix (input data).
    y: Target vector (output data).
    test_size: Proportion of the dataset to include in the test split.
    dynamic_parameter: The parameter to update dynamically (e.g., 'alpha', 'beta').
    static_parameters: Additional static parameters for the model.
        Should be a dictionary with parameter names as keys and their values.
    keep_previous: Whether to keep all previous lines with reduced opacity.
    scaler: Optional scaler for preprocessing the data.
    pca_components: Number of components to use for PCA.
    plot_step: Resolution of the decision boundary mesh.
    **kwargs: Additional customization options (e.g., colors, line styles).
setup_plot(self, title, xlabel, ylabel, legend_loc='upper left', grid=True, figsize=(12, 6))
Set up the plot for classification animation.
update_model(self, frame)
Update the classification model for the current frame.
 
Args:
    frame: The current frame (e.g., parameter value).
update_plot(self, frame)
Update the plot for the current frame.
 
Args:
    frame: The current frame (e.g., parameter value).

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Methods inherited from AnimationBase:
animate(self, frames, interval=150, blit=True, repeat=False)
Create the animation.
 
Args:
    frames: Range of frames (e.g., window sizes).
    interval: Delay between frames in milliseconds.
    blit: Whether to use blitting for faster rendering.
    repeat: Whether to repeat the animation.
save(self, filename, writer='pillow', fps=5, dpi=100)
Save the animation to a file.
 
Args:
    filename: Path to save the animation.
    writer: Writer to use (e.g., 'pillow' for GIF).
    fps: Frames per second.
    dpi: Dots per inch for the saved figure.
show(self)
Display the animation.

Data descriptors inherited from AnimationBase:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ClassifierTree(builtins.object)
    ClassifierTree(max_depth=5, min_samples_split=2)
 
A class representing a decision tree.
 
Args:
    max_depth: (int) - The maximum depth of the decision tree.
 
Methods:
    learn(X, y, par_node={}, depth=0): Builds the decision tree based on the given training data.
    classify(record): Classifies a record using the decision tree.
 
  Methods defined here:
__init__(self, max_depth=5, min_samples_split=2)
Initializes the ClassifierTree with a maximum depth.
fit(self, X, y, sample_weight=None)
Fits the decision tree to the training data.
 
Args:
    X: (array-like) - The input features.
    y: (array-like) - The target labels.
    sample_weight: (array-like) - The sample weights (default: None).
learn(self, X, y, par_node=None, depth=0, sample_weight=None)
Builds the decision tree based on the given training data.
 
Args:
    X: (array-like) - The input features.
    y: (array-like) - The target labels.
    par_node: (dict) - The parent node of the current subtree (default: {}).
    depth: (int) - The current depth of the subtree (default: 0).
    sample_weight: (array-like) - The sample weights (default: None).
 
Returns:
    dict: The learned decision tree.
predict(self, X)
Predicts the labels for a given set of records using the decision tree.
 
Args:
    X: (array-like) - The input features.
 
Returns:
    list: A list of predicted labels for each record.
predict_proba(self, X)
Predicts the probabilities for a given set of records using the decision tree.
 
Args:
    X: (array-like) - The input features.
 
Returns:
    list: A list of dictionaries where each dictionary represents the probability distribution
          over the classes for a record.

Static methods defined here:
classify(tree, record)
Classifies a given record using the decision tree.
 
Args:
    tree: (dict) - The decision tree.
    record: (dict) - A dictionary representing the record to be classified.
 
Returns:
    The label assigned to the record based on the decision tree.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ClassifierTreeUtility(builtins.object)
    ClassifierTreeUtility(min_samples_split=2)
 
Utility class for computing entropy, partitioning classes, and calculating information gain.
 
  Methods defined here:
__init__(self, min_samples_split=2)
Initialize the utility class.
best_split(self, X, y, sample_weight=None)
Finds the best attribute and value to split the data based on information gain.
 
Args:
    X: (array-like) - The input features.
    y: (array-like) - The target variable.
    sample_weight: (array-like) - The sample weights (default: None).
 
Returns:
    dict: A dictionary containing the best split attribute, split value, left and right subsets of X and y,
          and the information gain achieved by the split.
entropy(self, class_y, sample_weight=None)
Computes the entropy for a given class.
 
Args:
    class_y: (array-like) - The class labels.
    sample_weight: (array-like) - The sample weights (default: None).
 
Returns:
    float: The entropy value.
information_gain(self, previous_y, current_y, sample_weight_prev=None, sample_weight_current=None)
Calculates the information gain between the previous and current values of y.
 
Args:
    previous_y: (array-like) - The previous values of y.
    current_y: (array-like) - The current values of y.
    sample_weight_prev: (array-like) - The sample weights for the previous y values (default: None).
    sample_weight_current: (array-like) - The sample weights for the current y values (default: None).
 
Returns:
    float: The information gain between the previous and current values of y.
partition_classes(self, X, y, split_attribute, split_val, sample_weight=None)
Partitions the dataset into two subsets based on a given split attribute and value.
 
Args:
    X: (array-like) - The input features.
    y: (array-like) - The target labels.
    split_attribute: (int) - The index of the attribute to split on.
    split_val: (float) - The value to split the attribute on.
    sample_weight: (array-like) - The sample weights (default: None).
 
Returns:
    X_left:  (array-like) - The subset of input features where the split attribute is less than or equal to the split value.
    X_right: (array-like) - The subset of input features where the split attribute is greater than the split value.
    y_left:  (array-like) - The subset of target labels corresponding to X_left.
    y_right: (array-like) - The subset of target labels corresponding to X_right.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ConvLayer(builtins.object)
    ConvLayer(in_channels, out_channels, kernel_size, stride=1, padding=0, activation='relu')
 
A convolutional layer implementation for neural networks.
 
This layer performs 2D convolution operations, commonly used in convolutional neural networks (CNNs).
The implementation uses the im2col technique for efficient computation, transforming the convolution operation into matrix multiplication.
An optional activation function is applied element-wise to the output.
 
Args:
    in_channels (int): Number of input channels (depth of input volume).
    out_channels (int): Number of output channels (number of filters).
    kernel_size (int): Size of the convolutional kernel (square kernel assumed).
    stride (int, optional): Stride of the convolution. Default: 1.
    padding (int, optional): Zero-padding added to both sides of the input. Default: 0.
    activation (str, optional): Activation function to use. Options are "relu", "sigmoid", "tanh", or None. Default: "relu".
 
Attributes:
    in_channels (int): Number of input channels.
    out_channels (int): Number of output channels.
    kernel_size (int): Size of the square convolutional kernel.
    stride (int): Stride of the convolution.
    padding (int): Zero-padding added to both sides of the input.
    weights (numpy.ndarray): Learnable weights of shape (out_channels, in_channels, kernel_size, kernel_size).
    biases (numpy.ndarray): Learnable biases of shape (out_channels, 1).
    activation (str): Type of activation function.
    weight_gradients (numpy.ndarray): Gradients with respect to weights.
    bias_gradients (numpy.ndarray): Gradients with respect to biases.
    input_cache (numpy.ndarray): Cached input for use in backward pass.
    X_cols (numpy.ndarray): Cached column-transformed input.
    X_padded (numpy.ndarray): Cached padded input.
    h_out (int): Height of output feature maps.
    w_out (int): Width of output feature maps.
    input_size (int): Size of input (same as in_channels).
    output_size (int): Size of output (same as out_channels).
 
Methods:
    zero_grad(): Reset gradients to zero.
    _im2col(x, h_out, w_out): Convert image regions to columns for efficient convolution.
    forward(X): Perform forward pass of the convolutional layer.
    _col2im(dcol, x_shape): Convert column back to image format for the backward pass.
    backward(d_out, reg_lambda=0): Perform backward pass of the convolutional layer.
 
  Methods defined here:
__init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, activation='relu')
Initializes a convolutional layer object for neural networks.
 
This layer performs 2D convolution operations, commonly used in convolutional neural networks (CNNs).
 
Args:
    in_channels: (int) - Number of input channels (depth of input volume).
    out_channels: (int) - Number of output channels (number of filters).
    kernel_size: (int) - Size of the convolutional kernel (square kernel assumed).
    stride: (int), optional - Stride of the convolution (default is 1).
    padding: (int), optional - Zero-padding added to both sides of the input (default is 0).
    activation: (str), optional - Activation function to use (default is "relu").
 
Attributes:
    in_channels: (int) - Number of input channels.
    out_channels: (int) - Number of output channels.
    kernel_size: (int) - Size of the square convolutional kernel.
    stride: (int) - Stride of the convolution.
    padding: (int) - Zero-padding added to both sides of the input.
    weights: (np.ndarray) - Learnable weights of shape (out_channels, in_channels, kernel_size, kernel_size).
    biases: (np.ndarray) - Learnable biases of shape (out_channels, 1).
    activation: (str) - Type of activation function.
    weight_gradients: (np.ndarray or None) - Gradients with respect to weights, initialized to None.
    bias_gradients: (np.ndarray or None) - Gradients with respect to biases, initialized to None.
    input_cache: (np.ndarray or None) - Cached input for use in backward pass.
    input_size: (int) - Size of input (same as in_channels).
    output_size: (int) - Size of output (same as out_channels).
activate(self, Z)
Apply activation function.
backward(self, d_out, reg_lambda=0)
Optimized backward pass using im2col technique.
 
Args:
    d_out: (np.ndarray) - Gradient of the loss with respect to the layer output,
                      shape (batch_size, out_channels, h_out, w_out)
    reg_lambda: (float, optional) - Regularization parameter.
 
Returns:
    dX: Gradient with respect to the input X.
forward(self, X)
Perform forward pass of the convolutional layer.
 
Args:
    X: numpy array with shape (batch_size, in_channels, height, width)
 
Returns:
    Output feature maps after convolution and activation.
zero_grad(self)
Reset the gradients of the weights and biases to zero.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class CrossEntropyLoss(builtins.object)
    Custom cross entropy loss implementation using numpy for multi-class classification.
 
Formula: -sum(y * log(p) + (1 - y) * log(1 - p)) / m
Methods:
    __call__(self, logits, targets): Calculate the cross entropy loss.
 
  Methods defined here:
__call__(self, logits, targets)
Calculate the cross entropy loss.
 
Args:
    logits (np.ndarray): The logits (predicted values) of shape (num_samples, num_classes).
    targets (np.ndarray): The target labels of shape (num_samples,).
 
Returns:
    float: The cross entropy loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class DBSCAN(builtins.object)
    DBSCAN(X, eps=0.5, min_samples=5, compile_numba=False)
 
This class implements the Density-Based Spatial Clustering of Applications with Noise (DBSCAN) algorithm.
 
Args:
    X: The data matrix (numpy array).
    eps: The maximum distance between two samples for one to be considered as in the neighborhood of the other.
    min_samples: The number of samples in a neighborhood for a point to be considered as a core point.
 
Methods:
    - __init__: Initializes the DBSCAN object with the input parameters.
    - fit: Fits the DBSCAN model to the data and assigns cluster labels.
    - predict: Predicts the cluster labels for new data points.
    - fit_predict: Fits the DBSCAN model and returns cluster labels.
    - silhouette_score: Calculates the Silhouette Score for evaluating clustering performance.
    - _handle_categorical: Handles categorical columns by one-hot encoding.
    - _convert_to_ndarray: Converts input data to a NumPy ndarray and handles categorical columns.
    - _custom_distance_matrix: Calculates the pairwise distance matrix using a custom distance calculation method.
 
  Methods defined here:
__init__(self, X, eps=0.5, min_samples=5, compile_numba=False)
Initialize the DBSCAN object.
 
Args:
    X: The data matrix (numpy array).
    eps: The maximum distance between two samples for one to be considered as in the neighborhood of the other.
    min_samples: The number of samples in a neighborhood for a point to be considered as a core point.
    compile_numba: Whether to compile the distance calculations using Numba for performance.
    If not compiled, the first call to the numba fitting function will take longer, but subsequent calls will be faster.
auto_eps(self, min=0.1, max=1.1, precision=0.01, return_scores=False, verbose=False)
Find the optimal eps value for DBSCAN based on silhouette score.
 
Args:
    min: The minimum eps value to start the search.
    max: The maximum eps value to end the search.
    precision: The precision of the search.
    return_scores: Whether to return a dictionary of (eps, score) pairs.
    verbose: Whether to print the silhouette score for each eps value.
 
Returns:
    eps: The optimal eps value.
    scores_dict (optional): A dictionary of (eps, score) pairs if return_scores is True.
fit(self, metric='euclidean', numba=False)
Fit the DBSCAN model to the data.
 
Algorithm Steps:
1. Calculate the distance matrix between all points in the dataset.
2. Identify core points based on the minimum number of neighbors within eps distance.
3. Assign cluster labels using depth-first search (DFS) starting from core points.
 
Args:
    metric: The distance metric to use ('euclidean', 'manhattan', or 'cosine').
    numba: Whether to use numba for faster computation.
 
Returns:
    labels: The cluster labels for each data point.
fit_predict(self, numba=False)
Fit the DBSCAN model to the data and return the cluster labels.
 
Returns:
    labels: The cluster labels for the data.
predict(self, new_X)
Predict the cluster labels for new data points.
 
Note: DBSCAN does not naturally support predicting new data points.
 
Args:
    new_X: The data matrix to predict (numpy array).
 
Returns:
    labels: The predicted cluster labels (-1 for noise).
silhouette_score(self)
Calculate the silhouette score for evaluating clustering performance.
 
Returns:
    silhouette_score: The computed silhouette score.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class DataPrep(builtins.object)
    A class for preparing data for machine learning models.
 
  Methods defined here:
df_to_ndarray(df, y_col=0)
Converts a DataFrame to a NumPy array.
 
Args:
    df: (pandas.DataFrame) - The DataFrame to be converted.
    y_col: (int), optional - The index of the label column (default is 0).
 
Returns:
    X: (numpy.ndarray) - The feature columns as a NumPy array.
    y: (numpy.ndarray) - The label column as a NumPy array.
find_categorical_columns(data)
Finds the indices of non-numerical columns in a DataFrame or numpy array.
 
Args:
    data: (pandas.DataFrame or numpy.ndarray) - The data to be checked.
 
Returns:
    categorical_cols: (list) - The list of indices of non-numerical columns.
k_split(X, y, k=5)
Splits the data into k folds for cross-validation.
 
Args:
    X: (numpy.ndarray) - The feature columns.
    y: (numpy.ndarray) - The label column.
    k: (int), optional - The number of folds (default is 5).
 
Returns:
    X_folds: (list) - A list of k folds of feature columns.
    y_folds: (list) - A list of k folds of label columns.
one_hot_encode(data, cols)
One-hot encodes non-numerical columns in a DataFrame or numpy array.
 
Drops the original columns after encoding.
 
Args:
    data: (pandas.DataFrame or numpy.ndarray) - The data to be encoded.
    cols: (list) - The list of column indices to be encoded.
 
Returns:
    data: (pandas.DataFrame or numpy.ndarray) - The data with one-hot encoded columns.
prepare_data(csv_file, label_col_index, cols_to_encode=None, write_to_csv=True)
Prepares the data by loading a CSV file, one-hot encoding non-numerical columns, and optionally writing the prepared data to a new CSV file.
 
Args:
    csv_file: (str) - The path of the CSV file to load.
    label_col_index: (int) - The index of the label column.
    cols_to_encode: (list), optional - The list of column indices to one-hot encode (default is None).
    write_to_csv: (bool), optional - Whether to write the prepared data to a new CSV file (default is True).
 
Returns:
    df: (pandas.DataFrame) - The prepared DataFrame.
    prepared_csv_file: (str) - The path of the prepared CSV file. If write_to_csv is False, returns "N/A".
write_data(df, csv_file, print_path=False)
Writes the DataFrame to a CSV file.
 
Args:
    df: (pandas.DataFrame) - The DataFrame to be written.
    csv_file: (str) - The path of the CSV file to write to.
    print_path: (bool), optional - If True, prints the file path (default is False).

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class DenseLayer(builtins.object)
    DenseLayer(input_size, output_size, activation='relu')
 
Initializes a fully connected layer object, where each neuron is connected to all neurons in the previous layer.
 
Each layer consists of weights, biases, and an activation function.
 
Args:
    input_size (int): The size of the input to the layer.
    output_size (int): The size of the output from the layer.
    activation (str): The activation function to be used in the layer.
 
Attributes:
    weights (np.ndarray): Weights of the layer.
    biases (np.ndarray): Biases of the layer.
    activation (str): Activation function name.
    weight_gradients (np.ndarray): Gradients of the weights.
    bias_gradients (np.ndarray): Gradients of the biases.
    input_cache (np.ndarray): Cached input for backpropagation.
    output_cache (np.ndarray): Cached output for backpropagation.
 
Methods:
    zero_grad(): Resets the gradients of the weights and biases to zero.
    forward(X): Performs the forward pass of the layer.
    backward(dA, reg_lambda): Performs the backward pass of the layer.
    activate(Z): Applies the activation function.
    activation_derivative(Z): Applies the derivative of the activation function.
 
  Methods defined here:
__init__(self, input_size, output_size, activation='relu')
Initializes the layer with weights, biases, and activation function.
 
Args:
    input_size: (int) - The number of input features to the layer.
    output_size: (int) - The number of output features from the layer.
    activation: (str), optional - The activation function to use (default is "relu").
 
Attributes:
    weights: (np.ndarray) - The weight matrix initialized using He initialization for ReLU or Leaky ReLU, or standard initialization otherwise.
    biases: (np.ndarray) - The bias vector initialized to zeros.
    input_size: (int) - The number of input features to the layer.
    output_size: (int) - The number of output features from the layer.
    activation: (str) - The activation function to use.
    weight_gradients: (np.ndarray or None) - Gradients of the weights, initialized to None.
    bias_gradients: (np.ndarray or None) - Gradients of the biases, initialized to None.
activate(self, Z)
Apply activation function.
activation_derivative(self, Z)
Apply activation derivative.
backward(self, dA, reg_lambda)
Backward pass of the layer.
forward(self, X)
Forward pass of the layer.
zero_grad(self)
Reset the gradients of the weights and biases to zero.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class DoubleExponentialSmoothing(builtins.object)
    DoubleExponentialSmoothing(alpha, beta)
 
Double Exponential Smoothing (DES) / Holt's Linear Trend Method.
 
Extends SES to handle time series with a trend component (additive trend).
 
Attributes:
    alpha (float): Smoothing parameter for the level (0 <= alpha <= 1).
    beta (float): Smoothing parameter for the trend (0 <= beta <= 1).
    level (float): The final estimated level component after fitting.
    trend (float): The final estimated trend component after fitting.
    fitted_values (np.ndarray): The one-step-ahead forecasts made during fitting.
    model (np.ndarray): The original time series data.
 
  Methods defined here:
__init__(self, alpha, beta)
Initialize DES model.
 
Args:
    alpha (float): Smoothing parameter for the level (0 <= alpha <= 1).
    beta (float): Smoothing parameter for the trend (0 <= beta <= 1).
__str__(self)
Return str(self).
find_best_alpha_beta(self, train_series, test_series, alpha_values=None, beta_values=None, set_best=False)
Find the best alpha and beta values for the DES model.
 
Args:
    train_series (array-like): The training time series data (1-dimensional).
    test_series (array-like): The testing time series data (1-dimensional).
    alpha_values (list, optional): List of alpha values to evaluate. Defaults to [0.1, 0.2, ..., 0.9].
    beta_values (list, optional): List of beta values to evaluate. Defaults to [0.1, 0.2, ..., 0.9].
    set_best (bool, optional): If True, set the best alpha and beta values to the model. Defaults to False.
 
Returns:
    tuple: Best alpha and beta values based on mean squared error.
fit(self, time_series)
Fit the DES model to the data.
 
Args:
    time_series (array-like): The time series data (1-dimensional). Requires at least 2 points.
 
Returns:
    np.ndarray: The fitted values (one-step-ahead forecasts).
forecast(self, steps)
Generate forecasts for future steps.
 
Args:
    steps (int): The number of steps to forecast ahead.
 
Returns:
    np.ndarray: An array of forecasted values.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ExponentialMovingAverage(builtins.object)
    ExponentialMovingAverage(alpha)
 
Calculates the Exponential Moving Average (EMA) of a time series.
 
EMA gives more weight to recent observations, making it more responsive to new information.
 
Attributes:
    alpha (float): The smoothing factor (0 < alpha < 1).
    smoothed_values (np.ndarray): The calculated EMA values. NaNs prepended.
    model (np.ndarray): The original time series data.
 
  Methods defined here:
__init__(self, alpha)
Initialize EMA calculator.
 
Args:
    alpha (float): The smoothing factor (0 < alpha < 1).
__str__(self)
Return str(self).
fit(self, time_series)
Calculate the Exponential Moving Average for the series.
 
Args:
    time_series (array-like): The time series data (1-dimensional).
forecast(self, steps)
Generate forecasts using the last calculated EMA value.
 
Note: This is a naive forecast where the future is predicted to be the
last known smoothed value.
 
Args:
    steps (int): The number of steps to forecast ahead.
 
Returns:
    np.ndarray: An array of forecasted values (all the same).
get_smoothed(self)
Return the calculated EMA series.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class FlattenLayer(builtins.object)
    A layer that flattens multi-dimensional input into a 2D array (batch_size, flattened_size).
 
Useful for transitioning from convolutional layers to dense layers.
 
Attributes:
    input_shape: (tuple) - Shape of the input data (excluding batch size).
    output_size: (int) - Size of the flattened output vector.
    input_cache: (np.ndarray) - Cached input for backpropagation.
    input_size: (int) - Size of the input (same as input_shape).
    output_size: (int) - Size of the output (same as output_size).
 
  Methods defined here:
__init__(self)
Initializes the layer with default attributes.
 
Attributes:
    input_shape: (tuple or None) - Shape of the input data, to be set dynamically during the forward pass.
    output_size: (int or None) - Size of the output data, to be set dynamically during the forward pass.
    input_cache: (any or None) - Cache to store input data for use during backpropagation.
    input_size: (int or None) - Flattened size of the input, calculated as channels * height * width.
    output_size: (int or None) - Flattened size of the output, same as input_size.
backward(self, dA, reg_lambda=0)
Reshapes the gradient back to the original input shape.
 
Args:
    dA (np.ndarray): Gradient of the loss with respect to the layer's output,
                    shape (batch_size, flattened_size)
    reg_lambda (float): Regularization parameter (unused in FlattenLayer).
 
Returns:
    np.ndarray: Gradient with respect to the input, reshaped to original input shape.
forward(self, X)
Flattens the input tensor.
 
Args:
    X: (np.ndarray) - Input data of shape (batch_size, channels, height, width)
                   or any multi-dimensional shape after batch dimension.
 
Returns:
    np.ndarray: Flattened output of shape (batch_size, flattened_size)

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ForcastingAnimation(AnimationBase)
    ForcastingAnimation(model, train_series, test_series, forecast_steps, dynamic_parameter=None, static_parameters=None, keep_previous=False, max_previous=None, **kwargs)
 
Class for creating animations of forecasting models.
 
 
Method resolution order:
ForcastingAnimation
AnimationBase
abc.ABC
builtins.object

Methods defined here:
__init__(self, model, train_series, test_series, forecast_steps, dynamic_parameter=None, static_parameters=None, keep_previous=False, max_previous=None, **kwargs)
Initialize the forecasting animation class.
 
Args:
    model: The forecasting model.
    train_series: Training time series data.
    test_series: Testing time series data.
    forecast_steps: Number of steps to forecast.
    dynamic_parameter: The parameter to update dynamically (e.g., 'window', 'alpha', 'beta').
    static_parameters: Static parameters for the model.
        Should be a dictionary with parameter names as keys and their values.
    keep_previous: Whether to keep all previous lines with reduced opacity.
    max_previous: Maximum number of previous lines to keep.
    **kwargs: Additional customization options (e.g., colors, line styles).
setup_plot(self, title, xlabel, ylabel, legend_loc='upper left', grid=True, figsize=(12, 6))
Set up the plot for forecasting animation.
update_model(self, frame)
Update the model for the current frame.
 
Args:
    frame: The current frame (e.g., parameter value).
update_plot(self, frame)
Update the plot for the current frame.
 
Args:
    frame: The current frame (e.g., parameter value).

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Methods inherited from AnimationBase:
animate(self, frames, interval=150, blit=True, repeat=False)
Create the animation.
 
Args:
    frames: Range of frames (e.g., window sizes).
    interval: Delay between frames in milliseconds.
    blit: Whether to use blitting for faster rendering.
    repeat: Whether to repeat the animation.
save(self, filename, writer='pillow', fps=5, dpi=100)
Save the animation to a file.
 
Args:
    filename: Path to save the animation.
    writer: Writer to use (e.g., 'pillow' for GIF).
    fps: Frames per second.
    dpi: Dots per inch for the saved figure.
show(self)
Display the animation.

Data descriptors inherited from AnimationBase:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ForecastRegressor(builtins.object)
    ForecastRegressor(models, model_weights=None)
 
Implements a forcast voting regressor.
 
Takes a list of fitted models and their weights and returns a weighted average of the predictions.
 
  Methods defined here:
__init__(self, models, model_weights=None)
Initialize the ForecastRegressor object.
 
Args:
    models: list of models to be stacked
    model_weights: list of weights for each model. Default is None.
forecast(self, steps)
Forecast the target variable using the fitted models.
 
Args:
    steps: number of steps to forecast
 
Returns:
    y_pred: predicted target variable
get_params(self)
Get the parameters of the ForecastRegressor object.
 
Returns:
    params: dictionary of parameters
show_models(self, formula=False)
Print the models and their weights.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ForecastingPipeline(builtins.object)
    ForecastingPipeline(preprocessors=None, model=None, evaluators=None)
 
A customizable pipeline for time series forecasting.
 
This pipeline allows for the integration of preprocessing steps, a forecasting model,
and evaluation metrics to streamline the forecasting workflow.
 
Attributes:
    preprocessors (list): A list of preprocessing functions or objects to transform the input data.
    model (object): A forecasting model (e.g., ARIMASARIMA, etc.) that implements fit and predict methods.
    evaluators (list): A list of evaluation metrics or functions to assess the model's performance.
 
Methods:
    add_preprocessor(preprocessor): Add a preprocessing step to the pipeline.
    fit(X, y): Fit the model to the data after applying preprocessing steps.
    predict(X): Make predictions using the fitted model and preprocessing steps.
    evaluate(X, y): Evaluate the model using the provided evaluators.
    summary(): Print a summary of the pipeline configuration.
 
  Methods defined here:
__init__(self, preprocessors=None, model=None, evaluators=None)
Initialize the pipeline with optional preprocessors, model, and evaluators.
 
Args:
    preprocessors (list, optional): List of preprocessing functions or objects.
    model (object, optional): A forecasting model (e.g., ARIMASARIMA, etc.).
    evaluators (list, optional): List of evaluation metrics or functions.
add_evaluator(self, evaluator)
Add an evaluation metric to the pipeline.
 
Args:
    evaluator (callable): An evaluation metric function.
add_model(self, model)
Add a forecasting model to the pipeline.
 
Args:
    model (object): A forecasting model (e.g., ARIMASARIMA, etc.).
add_preprocessor(self, preprocessor)
Add a preprocessing step to the pipeline.
 
Args:
    preprocessor (callable): A preprocessing function or object.
evaluate(self, predictions, y)
Evaluate the model using the provided evaluators.
 
Args:
    predictions (array-like): Predicted values.
    y (array-like): True target values.
 
Returns:
    dict: Dictionary of evaluation results.
fit(self, X, y=None)
Fit the model to the data.
 
Args:
    X (array-like): Input features (e.g., time series data).
    y (array-like): Target values (optional). If not provided, X is used as both features and target.
predict(self, X, steps=1)
Make predictions using the fitted model.
 
Args:
    X (array-like): Input features for prediction.
    steps (int): Number of steps to forecast ahead.
 
Returns:
    array-like: Predicted values.
remove_evaluator(self, evaluator)
Remove an evaluation metric from the pipeline.
 
Args:
    evaluator (callable): An evaluation metric function to remove.
remove_model(self, model)
Remove a forecasting model from the pipeline.
 
Args:
    model (object): A forecasting model (e.g., ARIMASARIMA, etc.) to remove.
remove_preprocessor(self, preprocessor)
Remove a preprocessing step from the pipeline.
 
Args:
    preprocessor (callable): A preprocessing function or object to remove.
summary(self)
Print a summary of the pipeline configuration.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
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

 
class GradientBoostedClassifier(builtins.object)
    GradientBoostedClassifier(X=None, y=None, n_estimators: int = 100, learning_rate: float = 0.1, max_depth: int = 3, min_samples_split: int = 2, random_seed: int = None)
 
A Gradient Boosted Decision Tree Classifier.
 
This model builds an ensemble of regression trees sequentially. Each tree
is trained to predict the pseudo-residuals (gradients of the loss function)
of the previous model's predictions.
 
Attributes:
    X (np.ndarray): Training input features of shape (n_samples, n_features).
    y (np.ndarray): Training target class labels of shape (n_samples,).
    n_estimators (int): The number of boosting stages (trees) to perform.
    learning_rate (float): Step size shrinkage to prevent overfitting.
    max_depth (int): Maximum depth of the individual regression tree estimators.
    min_samples_split (int): Minimum number of samples required to split an internal node in a tree.
    random_seed (int or None): Controls the randomness for reproducibility (currently affects feature selection within trees if applicable).
    trees_ (list): List storing the fitted regression tree instances for each boosting stage (and for each class in multiclass).
    classes_ (np.ndarray): The unique class labels found in the target variable `y`.
    n_classes_ (int): The number of unique classes.
    init_estimator_ (float or np.ndarray): The initial prediction model (predicts log-odds).
    loss_ (str): The loss function used ('log_loss' for binary, 'multinomial' for multi-class).
 
  Methods defined here:
__init__(self, X=None, y=None, n_estimators: int = 100, learning_rate: float = 0.1, max_depth: int = 3, min_samples_split: int = 2, random_seed: int = None)
Initializes the Gradient Boosted Classifier.
 
Args:
    X (array-like): Training input features of shape (n_samples, n_features).
    y (array-like): Training target class labels of shape (n_samples,).
    n_estimators (int): Number of boosting stages (trees).
    learning_rate (float): Step size shrinkage to prevent overfitting.
    max_depth (int): Maximum depth of each individual regression tree estimator.
    min_samples_split (int): Minimum samples required to split a node in a tree.
    random_seed (int, optional): Seed for reproducibility. Defaults to None.
calculate_metrics(self, y_true, y_pred, y_prob=None)
Calculate common classification metrics.
 
Args:
    y_true (array-like): True class labels.
    y_pred (array-like): Predicted class labels.
    y_prob (array-like, optional): Predicted probabilities for Log Loss calculation.
 
Returns:
    dict: A dictionary containing calculated metrics (Accuracy, Precision, Recall, F1 Score, Log Loss if applicable).
decision_function(self, X)
Compute the raw decision scores (log-odds) for samples in X.
 
Args:
    X (array-like): Input features of shape (n_samples, n_features).
 
Returns:
    np.ndarray: The raw decision scores. Shape (n_samples,) for binary
                or (n_samples, n_classes) for multi-class.
fit(self, X=None, y=None, sample_weight=None, verbose=0)
Fits the gradient boosted classifier to the training data.
 
Args:
    X (array-like): Training input features of shape (n_samples, n_features).
    y (array-like): Training target class labels of shape (n_samples,).
    sample_weight (array-like, optional): Sample weights for the training data.
    verbose (int): Controls the verbosity of the fitting process.
                   0 for no output, 1 for basic output.
 
Returns:
    self: The fitted GradientBoostedClassifier instance.
get_params(self)
Get the parameters of the GradientBoostedClassifier.
get_stats(self, y_true, X=None, y_pred=None, verbose=False)
Calculate and optionally print evaluation metrics. Requires either X or y_pred.
 
Args:
    y_true (array-like): True target values.
    X (array-like, optional): Input features to generate predictions if y_pred is not provided.
    y_pred (array-like, optional): Pre-computed predicted class labels.
    verbose (bool): Whether to print the metrics.
 
Returns:
    dict: A dictionary containing calculated metrics.
predict(self, X)
Predicts class labels for input features X.
 
Args:
    X (array-like): Input features of shape (n_samples, n_features).
 
Returns:
    np.ndarray: Predicted class labels of shape (n_samples,).
predict_proba(self, X)
Predict class probabilities for samples in X.
 
Args:
    X (array-like): Input features of shape (n_samples, n_features).
 
Returns:
    np.ndarray: Predicted class probabilities. Shape (n_samples, n_classes).
                For binary, columns are [P(class 0), P(class 1)].

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class GradientBoostedRegressor(builtins.object)
    GradientBoostedRegressor(X=None, y=None, num_trees: int = 100, max_depth: int = 3, learning_rate: float = 0.1, min_samples_split: int = 2, random_seed: int = None)
 
A class to represent a Gradient Boosted Decision Tree Regressor.
 
Attributes:
    random_seed (int): The random seed for the random number generator.
    num_trees (int): The number of decision trees in the ensemble.
    max_depth (int): The maximum depth of each decision tree.
    learning_rate (float): The learning rate for the gradient boosted model.
    min_samples_split (int): The minimum number of samples required to split a node.
    random_seed (int): The random seed for the random number generator.
 
Methods:
    fit(X=None, y=None, verbose=0): Fits the gradient boosted decision tree regressor to the training data.
    predict(X): Predicts the target values for the input features.
    calculate_metrics(y_true, y_pred): Calculates the evaluation metrics.
    get_stats(y_true, y_pred, verbose=False): Returns the evaluation metrics.
 
  Methods defined here:
__init__(self, X=None, y=None, num_trees: int = 100, max_depth: int = 3, learning_rate: float = 0.1, min_samples_split: int = 2, random_seed: int = None)
Initializes the Gradient Boosted Decision Tree Regressor.
 
Args:
    X: (np.ndarray), optional - Input feature data (default is None).
    y: (np.ndarray), optional - Target data (default is None).
    num_trees (int): Number of boosting stages (trees).
    max_depth (int): Maximum depth of each individual tree regressor.
    learning_rate (float): Step size shrinkage to prevent overfitting.
    min_samples_split (int): Minimum samples required to split a node.
    random_seed (int): Seed for reproducibility (currently affects feature selection within trees).
calculate_metrics(self, y_true, y_pred)
Calculate common regression metrics.
 
Args:
    y_true (array-like): True target values.
    y_pred (array-like): Predicted target values.
 
Returns:
    dict: A dictionary containing calculated metrics (MSE, R^2, MAE, RMSE, MAPE).
fit(self, X=None, y=None, sample_weight=None, verbose=0)
Fits the gradient boosted decision tree regressor to the training data.
 
This method trains the ensemble of decision trees by iteratively fitting each tree to the residuals
of the previous iteration. The residuals are updated after each iteration by subtracting the predictions
made by the current tree from the :target values.
 
Args:
    X (array-like): Training input features of shape (n_samples, n_features).
    y (array-like): Training target values of shape (n_samples,).
    sample_weight (array-like): Sample weights for each instance (not used in this implementation).
    verbose (int): Whether to print progress messages (e.g., residuals). 0 for no output, 1 for output, >1 for detailed output
 
Returns:
    self: The fitted GradientBoostedRegressor instance.
get_params(self)
Get the parameters of the GradientBoostedRegressor.
get_stats(self, y_true, y_pred, verbose=False)
Calculate and optionally print evaluation metrics.
 
Args:
    y_true (array-like): True target values.
    y_pred (array-like): Predicted target values.
    verbose (bool): Whether to print progress messages (e.g., residuals).
 
Returns:
    dict: A dictionary containing calculated metrics (MSE, R^2, MAE, RMSE, MAPE).
predict(self, X)
Predicts target values for input features X using the fitted GBR model.
 
Args:
    X (array-like): Input features of shape (n_samples, n_features).
 
Returns:
    np.ndarray: Predicted target values of shape (n_samples,).

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class GridSearchCV(builtins.object)
    GridSearchCV(model, param_grid, cv=5, metric='mse', direction='minimize')
 
Implements a grid search cross-validation for hyperparameter tuning.
 
  Methods defined here:
__init__(self, model, param_grid, cv=5, metric='mse', direction='minimize')
Initializes the GridSearchCV object.
 
Args:
    model: The model Object to be tuned.
    param_grid: (list) - A list of dictionaries containing hyperparameters to be tuned.
    cv: (int) - The number of folds for cross-validation. Default is 5.
    metric: (str) - The metric to be used for evaluation. Default is 'mse'.
        - Regression Metrics: 'mse', 'r2', 'mae', 'rmse', 'mape', 'mpe'
        - Classification Metrics: 'accuracy', 'precision', 'recall', 'f1', 'log_loss'
    direction: (str) - The direction to optimize the metric. Default is 'minimize'.
fit(self, X, y, verbose=False)
Fits the model to the data for all hyperparameter combinations.
 
Args:
    X: (numpy.ndarray) - The feature columns.
    y: (numpy.ndarray) - The label column.
    verbose: (bool) - A flag to display the training progress. Default is True.
 
Returns:
    model: The best model with the optimal hyperparameters.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class HuberLoss(builtins.object)
    Custom Huber loss implementation using numpy.
 
Formula: mean(0.5 * (y_true - y_pred)**2) if abs(y_true - y_pred) <= delta else mean(delta * (abs(y_true - y_pred) - delta / 2))
 
Methods:
    __call__(self, y_true, y_pred, delta=1.0): Calculate the Huber loss.
 
  Methods defined here:
__call__(self, y_true, y_pred, delta=1.0)
Calculate the Huber loss.
 
Args:
    y_true (np.ndarray): The true labels of shape (num_samples,).
    y_pred (np.ndarray): The predicted values of shape (num_samples,).
    delta (float): The threshold for the Huber loss.
 
Returns:
    float: The Huber loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class IsolationForest(builtins.object)
    IsolationForest(n_trees=100, max_samples=None, max_depth=10, n_jobs=1, force_true_length=False)
 
IsolationForest is an implementation of the Isolation Forest algorithm for anomaly detection.
 
Attributes:
    n_trees (int): The number of isolation trees to build. Default is 100.
    max_samples (int or None): The maximum number of samples to draw for each tree. If None, defaults to the minimum of 256 or the number of samples in the dataset.
    max_depth (int): The maximum depth of each isolation tree. Default is 10.
    n_jobs (int): The number of parallel jobs to run. Set to -1 to use all available cores. Default is 1.
    force_true_length (bool): Whether to force the true path length calculation. Default is False.
    trees (list): A list to store the trained isolation trees.
    classes_ (numpy.ndarray): An array representing the classes (0 for normal, 1 for anomaly).
 
Methods:
    __init__(n_trees=100, max_samples=None, max_depth=10, n_jobs=1, force_true_length=False):
        Initializes the IsolationForest with the specified parameters.
    fit(X):
        Fits the isolation forest to the data.
            X (array-like): The input features.
    _fit_tree(X):
        Fits a single isolation tree to a subset of the data.
            X (array-like): The input features.
            IsolationTree: A trained isolation tree.
    anomaly_score(X):
        Computes the anomaly scores for given samples.
            X (array-like): The input samples.
            numpy.ndarray: An array of anomaly scores.
    predict(X, threshold=0.5):
        Predicts whether samples are anomalies.
            X (array-like): The input samples.
            threshold (float): The threshold for classifying anomalies (default: 0.5).
            numpy.ndarray: An array of predictions (1 if the sample is an anomaly, 0 otherwise).
    __sklearn_is_fitted__():
        Checks if the model has been fitted.
            bool: True if the model is fitted, False otherwise.
 
  Methods defined here:
__init__(self, n_trees=100, max_samples=None, max_depth=10, n_jobs=1, force_true_length=False)
Initializes the IsolationForest with the specified parameters.
 
Args:
    n_trees: (int), optional - The number of isolation trees to build (default: 100).
    max_samples: (int or None), optional - The maximum number of samples to draw for each tree.
        If None, defaults to the minimum of 256 or the number of samples in the dataset (default: None).
    max_depth: (int), optional - The maximum depth of each isolation tree (default: 10).
    n_jobs: (int), optional - The number of parallel jobs to run.
        Set to -1 to use all available cores (default: 1).
    force_true_length: (bool), optional - Whether to force the true path length calculation (default: False).
 
Attributes:
    n_trees: (int) - The number of isolation trees.
    max_samples: (int or None) - The maximum number of samples for each tree.
    max_depth: (int) - The maximum depth of the trees.
    force_true_length: (bool) - Indicates whether to use the true path length for scoring.
    trees: (list) - A list to store the trained isolation trees.
    n_jobs: (int) - The number of parallel jobs to run.
    classes_: (np.ndarray) - An array representing the classes (0 for normal, 1 for anomaly).
__sklearn_is_fitted__(self)
Checks if the model has been fitted.
anomaly_score(self, X)
Computes the anomaly scores for given samples.
 
Args:
    X: (array-like) - The input samples.
 
Returns:
    array: An array of anomaly scores.
fit(self, X, y=None)
Fits the isolation forest to the data.
 
Args:
    X: (array-like) - The input features.
    y: (array-like) - The target labels (not used in this implementation).
predict(self, X, threshold=0.5)
Predicts whether samples are anomalies.
 
Args:
    X: (array-like) - The input samples.
    threshold: (float) - The threshold for classifying anomalies (default: 0.5).
 
Returns:
    array: An array of predictions (1 if the sample is an anomaly, 0 otherwise).

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class IsolationTree(builtins.object)
    IsolationTree(max_depth=10, force_true_length=False)
 
IsolationTree is a class that implements an isolation tree, which is a fundamental building block of the Isolation Forest algorithm.
 
The Isolation Forest is an unsupervised learning method used for anomaly detection.
 
Attributes:
    max_depth (int): The maximum depth of the tree. Default is 10.
    tree (dict): The learned isolation tree structure.
    force_true_length (bool): If True, the true path length is used for scoring
        instead of the average path length.
 
Methods:
    __init__(max_depth=10, force_true_length=False):
        Initializes the IsolationTree with the specified maximum depth and
        scoring method.
    fit(X, depth=0):
        Fits the isolation tree to the input data by recursively partitioning
        the data based on randomly selected features and split values.
    path_length(X, tree=None, depth=0):
        Computes the path length for a given sample by traversing the tree
        structure. The path length is used to determine how isolated a sample is.
 
  Methods defined here:
__init__(self, max_depth=10, force_true_length=False)
Initializes the Isolation Forest with specified parameters.
 
Args:
    max_depth: (int), optional - Maximum depth of the tree (default is 10).
    force_true_length: (bool), optional - If True, use the true path length for scoring (default is False).
 
Attributes:
    max_depth: (int) - Maximum depth of the tree.
    tree: (object or None) - The tree structure used in the Isolation Forest (default is None).
    force_true_length: (bool) - Indicates whether to use the true path length for scoring.
fit(self, X, depth=0)
Fits the isolation tree to the data.
 
Args:
    X: (array-like) - The input features.
    depth: (int) - The current depth of the tree (default: 0).
 
Returns:
    dict: The learned isolation tree.
path_length(self, X, tree=None, depth=0)
Computes the path length for a given sample.
 
Args:
    X: (array-like) - The input sample.
    tree: (dict) - The current node of the tree (default: None).
    depth: (int) - The current depth of the tree (default: 0).
 
Returns:
    int: The path length.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class IsolationUtils(builtins.object)
    Utility functions for the Isolation Forest algorithm.
 
  Static methods defined here:
compute_avg_path_length(size)
Computes the average path length of unsuccessful searches in a binary search tree.
 
Args:
    size: (int) - The size of the tree.
 
Returns:
    average_path_length: (float) - The average path length.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class JITAdadeltaOptimizer(JITAdadeltaOptimizer)
    JITAdadeltaOptimizer(*args, **kwargs)
 
Adadelta optimizer class for training neural networks.
 
Formula:
    E[g^2]_t = rho * E[g^2]_{t-1} + (1 - rho) * g^2
    Delta_x = - (sqrt(E[delta_x^2]_{t-1} + epsilon) / sqrt(E[g^2]_t + epsilon)) * g
    E[delta_x^2]_t = rho * E[delta_x^2]_{t-1} + (1 - rho) * Delta_x^2
Derived from: https://arxiv.org/abs/1212.5701
Args:
    learning_rate (float, optional): The learning rate for the optimizer. Defaults to 1.0.
    rho (float, optional): The decay rate. Defaults to 0.95.
    epsilon (float, optional): A small value to prevent division by zero. Defaults to 1e-6.
    reg_lambda (float, optional): The regularization parameter. Defaults to 0.0.
 
 
Method resolution order:
JITAdadeltaOptimizer
JITAdadeltaOptimizer
builtins.object

Data and other attributes defined here:
class_type = jitclass.JITAdadeltaOptimizer#15672b7c250<learni...float64, 3d, C),E_delta_x2:array(float64, 3d, C)>

Methods inherited from JITAdadeltaOptimizer:
__init__(self, learning_rate=1.0, rho=0.95, epsilon=1e-06, reg_lambda=0.0)
Initializes the optimizer with specified hyperparameters.
 
Args:
    learning_rate: (float), optional - The learning rate for the optimizer (default is 1.0).
    rho: (float), optional - The decay rate for the running averages (default is 0.95).
    epsilon: (float), optional - A small value to prevent division by zero (default is 1e-6).
    reg_lambda: (float), optional - The regularization parameter (default is 0.0).
 
Attributes:
    E_g2: (np.ndarray) - Running average of squared gradients.
    E_delta_x2: (np.ndarray) - Running average of squared parameter updates.
initialize(self, layers)
Initializes the running averages for each layer's weights.
 
Args:
    layers: (list) - List of layers in the neural network.
 
Returns:
    None
update(self, layer, dW, db, index)
Updates the weights and biases of a layer using the Adadelta optimization algorithm.
 
Args:
    layer: (Layer) - The layer to update.
    dW: (np.ndarray) - The gradient of the weights.
    db: (np.ndarray) - The gradient of the biases.
    index: (int) - The index of the layer.
 
Returns:
    None
update_layers(self, layers, dWs, dbs)
Updates all layers' weights and biases using the Adadelta optimization algorithm.
 
Args:
    layers: (list) - List of layers in the neural network.
    dWs: (list of np.ndarray) - Gradients of the weights for each layer.
    dbs: (list of np.ndarray) - Gradients of the biases for each layer.
 
Returns:
    None

Data descriptors inherited from JITAdadeltaOptimizer:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class JITAdamOptimizer(JITAdamOptimizer)
    JITAdamOptimizer(*args, **kwargs)
 
Adam optimizer class for training neural networks.
 
Formula: w = w - alpha * m_hat / (sqrt(v_hat) + epsilon) - lambda * w
Derived from: https://arxiv.org/abs/1412.6980
Args:
    learning_rate (float, optional): The learning rate for the optimizer. Defaults to 0.001.
    beta1 (float, optional): The exponential decay rate for the first moment estimates. Defaults to 0.9.
    beta2 (float, optional): The exponential decay rate for the second moment estimates. Defaults to 0.999.
    epsilon (float, optional): A small value to prevent division by zero. Defaults to 1e-8.
    reg_lambda (float, optional): The regularization parameter. Defaults to 0.01.
 
 
Method resolution order:
JITAdamOptimizer
JITAdamOptimizer
builtins.object

Data and other attributes defined here:
class_type = jitclass.JITAdamOptimizer#15672b5bbd0<learning_r...t64, 2d, A),db:array(float64, 2d, A),index:int32>

Methods inherited from JITAdamOptimizer:
__init__(self, learning_rate=0.001, beta1=0.9, beta2=0.999, epsilon=1e-08, reg_lambda=0.01)
Initializes the optimizer with the specified hyperparameters.
 
Args:
    learning_rate: (float), optional - The learning rate for the optimizer (default is 0.001).
    beta1: (float), optional - Exponential decay rate for the first moment estimates (default is 0.9).
    beta2: (float), optional - Exponential decay rate for the second moment estimates (default is 0.999).
    epsilon: (float), optional - A small value to prevent division by zero (default is 1e-8).
    reg_lambda: (float), optional - Regularization parameter; larger values imply stronger regularization (default is 0.01).
initialize(self, layers)
Initializes the first and second moment estimates for each layer's weights.
 
Args:
    layers: (list) - List of layers in the neural network.
 
Returns:
    None
update(self, layer, dW, db, index)
Updates the weights and biases of a layer using the Adam optimization algorithm.
 
Args:
    layer: (Layer) - The layer to update.
    dW: (np.ndarray) - The gradient of the weights.
    db: (np.ndarray) - The gradient of the biases.
    index: (int) - The index of the layer.
 
Returns:
    None
update_layers(self, layers, dWs, dbs)
Updates all layers' weights and biases using the Adam optimization algorithm.
 
Args:
    layers: (list) - List of layers in the neural network.
    dWs: (list of np.ndarray) - Gradients of the weights for each layer.
    dbs: (list of np.ndarray) - Gradients of the biases for each layer.
 
Returns:
    None

Data descriptors inherited from JITAdamOptimizer:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class JITBCEWithLogitsLoss(builtins.object)
    Custom binary cross entropy loss with logits implementation using numba.
 
Formula: -mean(y * log(p) + (1 - y) * log(1 - p))
 
Methods:
    calculate_loss(self, logits, targets): Calculate the binary cross entropy loss.
 
  Methods defined here:
__init__(self)
Initializes the class with default values for logits and targets.
 
Attributes:
    logits (numpy.ndarray): A 2D array initialized to zeros with shape (1, 1),
                            representing the predicted values.
    targets (numpy.ndarray): A 2D array initialized to zeros with shape (1, 1),
                             representing the true target values.
calculate_loss(self, logits, targets)
Calculate the binary cross entropy loss.
 
Args:
    logits (np.ndarray): The logits (predicted values) of shape (num_samples,).
    targets (np.ndarray): The target labels of shape (num_samples,).
 
Returns:
    float: The binary cross entropy loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class JITConvLayer(JITConvLayer)
    JITConvLayer(*args, **kwargs)
 
A convolutional layer implementation for neural networks using Numba JIT compilation.
 
 
Method resolution order:
JITConvLayer
JITConvLayer
builtins.object

Data and other attributes defined here:
class_type = jitclass.JITConvLayer#15672014910<in_channels:in...2,w_out:int32,input_size:int32,output_size:int32>

Methods inherited from JITConvLayer:
__init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, activation='relu')
Initializes the convolutional layer with weights, biases, and activation function.
 
Args:
    in_channels: (int) - Number of input channels.
    out_channels: (int) - Number of output channels.
    kernel_size: (int) - Size of the convolutional kernel (assumes square kernels).
    stride: (int), optional - Stride of the convolution (default is 1).
    padding: (int), optional - Padding added to the input (default is 0).
    activation: (str), optional - Activation function to use (default is "relu").
 
Attributes:
    weights: (np.ndarray) - Convolutional weight matrix initialized using He initialization.
    biases: (np.ndarray) - Bias vector initialized to zeros.
    activation: (str) - Activation function for the layer.
    weight_gradients: (np.ndarray) - Gradients of the weights, initialized to zeros.
    bias_gradients: (np.ndarray) - Gradients of the biases, initialized to zeros.
    input_cache: (np.ndarray) - Cached input values for backpropagation, initialized to zeros.
    X_cols: (np.ndarray) - Cached column-transformed input for backpropagation, initialized to zeros.
    X_padded: (np.ndarray) - Cached padded input for backpropagation, initialized to zeros.
    h_out: (int) - Height of the output feature map, initialized to 0.
    w_out: (int) - Width of the output feature map, initialized to 0.
    input_size: (int) - Number of input channels.
    output_size: (int) - Number of output channels.
activate(self, Z)
Apply activation function.
activation_derivative(self, Z)
Apply activation derivative.
backward(self, d_out, reg_lambda=0)
Backward pass for convolutional layer.
 
Args:
    d_out (np.ndarray): Gradient of the loss with respect to the layer output
    reg_lambda (float, optional): Regularization parameter
 
Returns:
    dX: Gradient with respect to the input X
forward(self, X)
Forward pass for convolutional layer.
 
Args:
    X: numpy array with shape (batch_size, in_channels, height, width)
 
Returns:
    Output feature maps after convolution and activation.
zero_grad(self)
Reset the gradients of the weights and biases to zero.

Data descriptors inherited from JITConvLayer:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class JITCrossEntropyLoss(builtins.object)
    Custom cross entropy loss implementation using numba for multi-class classification.
 
Formula: -sum(y * log(p) + (1 - y) * log(1 - p)) / m
Methods:
    calculate_loss(self, logits, targets): Calculate the cross entropy loss.
 
  Methods defined here:
__init__(self)
Initializes the instance variables for the class.
 
Args:
    logits: (np.ndarray) - A 2D array initialized to zeros with shape (1, 1),
               representing the predicted values or outputs of the model.
    targets: (np.ndarray) - A 2D array initialized to zeros with shape (1, 1),
                representing the ground truth or target values.
calculate_loss(self, logits, targets)
Calculate the cross entropy loss.
 
Args:
    logits (np.ndarray): The logits (predicted values) of shape (num_samples, num_classes).
    targets (np.ndarray): The target labels of shape (num_samples,).
 
Returns:
    float: The cross entropy loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class JITDenseLayer(JITDenseLayer)
    JITDenseLayer(*args, **kwargs)
 
Initializes a fully connected layer object, where each neuron is connected to all neurons in the previous layer.
 
Each layer consists of weights, biases, and an activation function.
 
Args:
    input_size (int): The size of the input to the layer.
    output_size (int): The size of the output from the layer.
    activation (str): The activation function to be used in the layer.
 
Attributes:
    weights (np.ndarray): Weights of the layer.
    biases (np.ndarray): Biases of the layer.
    activation (str): Activation function name.
    weight_gradients (np.ndarray): Gradients of the weights.
    bias_gradients (np.ndarray): Gradients of the biases.
    input_cache (np.ndarray): Cached input for backpropagation.
    output_cache (np.ndarray): Cached output for backpropagation.
 
Methods:
    zero_grad(): Resets the gradients of the weights and biases to zero.
    forward(X): Performs the forward pass of the layer.
    backward(dA, reg_lambda): Performs the backward pass of the layer.
    activate(Z): Applies the activation function.
    activation_derivative(Z): Applies the derivative of the activation function.
 
 
Method resolution order:
JITDenseLayer
JITDenseLayer
builtins.object

Data and other attributes defined here:
class_type = jitclass.JITDenseLayer#15671ff3d50<weights:array...oat64, 2d, C),input_size:int32,output_size:int32>

Methods inherited from JITDenseLayer:
__init__(self, input_size, output_size, activation='relu')
Initializes the layer with weights, biases, and activation function.
 
Args:
    input_size: (int) - The number of input features to the layer.
    output_size: (int) - The number of output features from the layer.
    activation: (str), optional - The activation function to use (default is "relu").
 
Attributes:
    weights: (np.ndarray) - The weight matrix initialized using He initialization for ReLU or Leaky ReLU,
                or Xavier initialization for other activations.
    biases: (np.ndarray) - The bias vector initialized to zeros.
    activation: (str) - The activation function for the layer.
    weight_gradients: (np.ndarray) - Gradients of the weights, initialized to zeros.
    bias_gradients: (np.ndarray) - Gradients of the biases, initialized to zeros.
    input_cache: (np.ndarray) - Cached input values for backpropagation, initialized to zeros.
    output_cache: (np.ndarray) - Cached output values for backpropagation, initialized to zeros.
    input_size: (int) - The number of input features to the layer.
    output_size: (int) - The number of output features from the layer.
activate(self, Z)
Apply activation function.
activation_derivative(self, Z)
Apply activation derivative.
backward(self, dA, reg_lambda)
Perform the backward pass of the layer.
forward(self, X)
Perform the forward pass of the layer.
zero_grad(self)
Reset the gradients of the weights and biases to zero.

Data descriptors inherited from JITDenseLayer:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class JITFlattenLayer(JITFlattenLayer)
    JITFlattenLayer(*args, **kwargs)
 
A layer that flattens multi-dimensional input into a 2D array (batch_size, flattened_size).
 
Useful for transitioning from convolutional layers to dense layers.
 
 
Method resolution order:
JITFlattenLayer
JITFlattenLayer
builtins.object

Data and other attributes defined here:
class_type = jitclass.JITFlattenLayer#15672009d10<input_shape...put_cache:array(float64, 4d, A),input_size:int32>

Methods inherited from JITFlattenLayer:
__init__(self)
Initializes the layer with placeholder values for input and output dimensions.
 
Attributes:
    input_shape: (tuple) - Shape of the input data, initialized to (0, 0, 0).
               This will be set during the forward pass.
    output_size: (int) - Size of the output, initialized to 0.
             This will be set during the forward pass.
    input_size: (int) - Size of the input, initialized to 0.
            This will be set during the forward pass.
    input_cache: (any) - Cache for input data, to be set during the forward pass.
backward(self, dA, reg_lambda=0)
Reshapes the gradient back to the original input shape.
 
Args:
    dA (np.ndarray): Gradient of the loss with respect to the layer's output,
                   shape (batch_size, flattened_size)
    reg_lambda (float): Regularization parameter (unused in FlattenLayer).
 
Returns:
    np.ndarray: Gradient with respect to the input, reshaped to original input shape.
forward(self, X)
Flattens the input tensor.
 
Args:
    X (np.ndarray): Input data of shape (batch_size, channels, height, width)
 
Returns:
    np.ndarray: Flattened output of shape (batch_size, flattened_size)

Data descriptors inherited from JITFlattenLayer:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class JITHuberLoss(builtins.object)
    JITHuberLoss(delta=1.0)
 
Custom Huber loss implementation using numba.
 
Attributes:
    delta (float): The threshold parameter for Huber loss. Default is 1.0.
 
  Methods defined here:
__init__(self, delta=1.0)
Initializes the JITHuberLoss instance.
 
Args:
    delta (float): The threshold at which the loss function transitions
                   from quadratic to linear. Default is 1.0.
calculate_loss(self, y_pred, y_true)
Calculate the Huber loss using the stored delta.
 
Args:
    y_pred (np.ndarray): Predicted values.
    y_true (np.ndarray): True target values.
 
Returns:
    float: The calculated Huber loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class JITMeanAbsoluteErrorLoss(builtins.object)
    Custom mean absolute error loss implementation using numba.
 
  Methods defined here:
calculate_loss(self, y_pred, y_true)
Calculate the mean absolute error loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class JITMeanSquaredErrorLoss(builtins.object)
    Custom mean squared error loss implementation using numba.
 
  Methods defined here:
calculate_loss(self, y_pred, y_true)
Calculate the mean squared error loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class JITRNNLayer(builtins.object)
    JITRNNLayer(input_size, hidden_size, activation='tanh')
 
A recurrent layer implementation for neural networks using Numba JIT compilation.
 
  Methods defined here:
__init__(self, input_size, hidden_size, activation='tanh')
Will be implemented later.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class JITSGDOptimizer(JITSGDOptimizer)
    JITSGDOptimizer(*args, **kwargs)
 
Stochastic Gradient Descent (SGD) optimizer class for training neural networks.
 
Formula: w = w - learning_rate * dW, b = b - learning_rate * db
Args:
    learning_rate (float, optional): The learning rate for the optimizer. Defaults to 0.001.
    momentum (float, optional): The momentum factor. Defaults to 0.0.
    reg_lambda (float, optional): The regularization parameter. Defaults to 0.0.
 
 
Method resolution order:
JITSGDOptimizer
JITSGDOptimizer
builtins.object

Data and other attributes defined here:
class_type = jitclass.JITSGDOptimizer#15672b6e290<learning_ra...eg_lambda:float64,velocity:array(float64, 3d, C)>

Methods inherited from JITSGDOptimizer:
__init__(self, learning_rate=0.001, momentum=0.0, reg_lambda=0.0)
Initializes the optimizer with specified hyperparameters.
 
Args:
    learning_rate: (float), optional - The learning rate for the optimizer (default is 0.001).
    momentum: (float), optional - The momentum factor for the optimizer (default is 0.0).
    reg_lambda: (float), optional - The regularization parameter (default is 0.0).
 
Attributes:
    learning_rate: (float) - The learning rate for the optimizer.
    momentum: (float) - The momentum factor for the optimizer.
    reg_lambda: (float) - The regularization parameter.
    velocity: (np.ndarray) - The velocity used for momentum updates, initialized to zeros.
initialize(self, layers)
Initializes the velocity for each layer's weights.
 
Args:
    layers: (list) - List of layers in the neural network.
 
Returns:
    None
update(self, layer, dW, db, index)
Updates the weights and biases of a layer using the SGD optimization algorithm.
 
Args:
    layer: (Layer) - The layer to update.
    dW: (np.ndarray) - The gradient of the weights.
    db: (np.ndarray) - The gradient of the biases.
    index: (int) - The index of the layer.
 
Returns:
   None
update_layers(self, layers, dWs, dbs)
Updates all layers' weights and biases using the SGD optimization algorithm.
 
Args:
    layers: (list) - List of layers in the neural network.
    dWs: (list of np.ndarray) - Gradients of the weights for each layer.
    dbs: (list of np.ndarray) - Gradients of the biases for each layer.
 
Returns:
    None

Data descriptors inherited from JITSGDOptimizer:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class KMeans(builtins.object)
    KMeans(X, n_clusters=3, max_iter=300, tol=0.0001)
 
This class implements the K-Means clustering algorithm along with methods for evaluating the optimal number of clusters and visualizing the clustering results.
 
Args:
    X: The data matrix (numpy array).
    n_clusters: The number of clusters.
    max_iter: The maximum number of iterations.
    tol: The tolerance to declare convergence.
 
Methods:
    - __init__: Initializes the KMeans object with parameters such as the data matrix, number of clusters, maximum iterations, and convergence tolerance.
    - _handle_categorical: Handles categorical columns in the input data by one-hot encoding.
    - _convert_to_ndarray: Converts input data to a NumPy ndarray and handles categorical columns.
    - initialize_centroids: Randomly initializes the centroids for KMeans clustering.
    - assign_clusters: Assigns clusters based on the nearest centroid.
    - update_centroids: Updates centroids based on the current cluster assignments.
    - fit: Fits the KMeans model to the data by iteratively updating centroids and cluster assignments until convergence.
    - predict: Predicts the closest cluster each sample in new_X belongs to.
    - elbow_method: Implements the elbow method to determine the optimal number of clusters.
    - calinski_harabasz_index: Calculates the Calinski-Harabasz Index for evaluating clustering performance.
    - davies_bouldin_index: Calculates the Davies-Bouldin Index for evaluating clustering performance.
    - silhouette_score: Calculates the Silhouette Score for evaluating clustering performance.
    - find_optimal_clusters: Implements methods to find the optimal number of clusters using the elbow method,
                         Calinski-Harabasz Index, Davies-Bouldin Index, and Silhouette Score. It also plots the evaluation
                         metrics to aid in determining the optimal k value.
 
  Methods defined here:
__init__(self, X, n_clusters=3, max_iter=300, tol=0.0001)
Initialize the KMeans object.
 
Args:
    X: The data matrix (numpy array, pandas DataFrame, or list).
    n_clusters: The number of clusters.
    max_iter: The maximum number of iterations.
    tol: The tolerance to declare convergence.
assign_clusters(self, centroids)
Assign clusters based on the nearest centroid.
 
Args:
    centroids: The current centroids.
 
Returns:
    labels: The cluster assignments for each data point.
calinski_harabasz_index(self, X, labels, centroids)
Calculate the Calinski-Harabasz Index for evaluating clustering performance.
 
Args:
    X: The data matrix (numpy array).
    labels: The cluster labels for each data point.
    centroids: The centroids of the clusters.
 
Returns:
    ch_index: The computed Calinski-Harabasz Index.
davies_bouldin_index(self, X, labels, centroids)
Calculate the Davies-Bouldin Index for evaluating clustering performance.
 
Args:
    X: The data matrix (numpy array).
    labels: The cluster labels for each data point.
    centroids: The centroids of the clusters.
 
Returns:
    db_index: The computed Davies-Bouldin Index.
elbow_method(self, max_k=10)
Implement the elbow method to determine the optimal number of clusters.
 
Args:
    max_k: The maximum number of clusters to test.
 
Returns:
    distortions: A list of distortions for each k.
find_optimal_clusters(self, max_k=10, true_k=None, save_dir=None)
Find the optimal number of clusters using various evaluation metrics and plot the results.
 
Args:
    X: The data matrix (numpy array).
    max_k: The maximum number of clusters to consider.
    true_k: The true number of clusters in the data.
    save_dir: The directory to save the plot (optional).
 
Returns:
    ch_optimal_k: The optimal number of clusters based on the Calinski-Harabasz Index.
    db_optimal_k: The optimal number of clusters based on the Davies-Bouldin Index.
    silhouette_optimal_k: The optimal number of clusters based on the Silhouette Score.
fit(self)
Fit the KMeans model to the data.
initialize_centroids(self)
Randomly initialize the centroids.
 
Returns:
    centroids: The initialized centroids.
predict(self, new_X)
Predict the closest cluster each sample in new_X belongs to.
 
Args:
    new_X: The data matrix to predict (numpy array).
 
Returns:
    labels: The predicted cluster labels.
silhouette_score(self, X, labels)
Calculate the silhouette score for evaluating clustering performance.
 
Args:
    X: The data matrix (numpy array).
    labels: The cluster labels for each data point.
 
Returns:
    silhouette_score: The computed silhouette score.
update_centroids(self)
Update the centroids based on the current cluster assignments.
 
Returns:
    centroids: The updated centroids.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class KNeighborsClassifier(sega_learn.nearest_neighbors.base.KNeighborsBase)
    KNeighborsClassifier(n_neighbors=5, distance_metric='euclidean', one_hot_encode=False, fp_precision=&lt;class 'numpy.float64'&gt;, numba=False)
 
K-Nearest Neighbors classifier.
 
This class implements the k-nearest neighbors algorithm for classification.
 
 
Method resolution order:
KNeighborsClassifier
sega_learn.nearest_neighbors.base.KNeighborsBase
abc.ABC
builtins.object

Methods defined here:
predict(self, X)
Predict the class labels for the provided data.
 
Args:
    X: array-like, shape (n_samples, n_features) - The input data for which to predict the class labels.
 
Returns:
    predictions: array, shape (n_samples,) - The predicted class labels for the input data.

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Methods inherited from sega_learn.nearest_neighbors.base.KNeighborsBase:
__init__(self, n_neighbors=5, distance_metric='euclidean', one_hot_encode=False, fp_precision=<class 'numpy.float64'>, numba=False)
Initialize the KNeighborsBase class.
 
Args:
    n_neighbors: int, default=5. The number of neighbors to use for the KNN algorithm.
    distance_metric: str, default='euclidean'. The distance metric to use for calculating distances.
    one_hot_encode: bool, default=False. Whether to apply one-hot encoding to the categorical columns.
    fp_precision: data type, default=np.float64. The floating point precision to use for the calculations.
    numba: bool, default=True. Whether to use numba for speeding up the calculations.
fit(self, X, y)
Fit the model using the training data.
 
Args:
    X: array-like, shape (n_samples, n_features) - The training data.
    y: array-like, shape (n_samples,) - The target values.
get_distance_indices(self, X)
Compute the distances and return the indices of the nearest points im the training data.
 
Args:
    X: array-like, shape (n_samples, n_features) - The input data.
 
Returns:
    indices: array, shape (n_samples, n_neighbors) - The indices of the nearest neighbors.

Data descriptors inherited from sega_learn.nearest_neighbors.base.KNeighborsBase:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class KNeighborsRegressor(sega_learn.nearest_neighbors.base.KNeighborsBase)
    KNeighborsRegressor(n_neighbors=5, distance_metric='euclidean', one_hot_encode=False, fp_precision=&lt;class 'numpy.float64'&gt;, numba=False)
 
K-Nearest Neighbors classifier.
 
This class implements the k-nearest neighbors algorithm for regression.
 
 
Method resolution order:
KNeighborsRegressor
sega_learn.nearest_neighbors.base.KNeighborsBase
abc.ABC
builtins.object

Methods defined here:
predict(self, X)
Predict the class labels for the provided data.
 
Args:
    X: array-like, shape (n_samples, n_features) - The input data for which to predict the class labels.
 
Returns:
    predictions: array, shape (n_samples,) - The predicted class labels for the input data.

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Methods inherited from sega_learn.nearest_neighbors.base.KNeighborsBase:
__init__(self, n_neighbors=5, distance_metric='euclidean', one_hot_encode=False, fp_precision=<class 'numpy.float64'>, numba=False)
Initialize the KNeighborsBase class.
 
Args:
    n_neighbors: int, default=5. The number of neighbors to use for the KNN algorithm.
    distance_metric: str, default='euclidean'. The distance metric to use for calculating distances.
    one_hot_encode: bool, default=False. Whether to apply one-hot encoding to the categorical columns.
    fp_precision: data type, default=np.float64. The floating point precision to use for the calculations.
    numba: bool, default=True. Whether to use numba for speeding up the calculations.
fit(self, X, y)
Fit the model using the training data.
 
Args:
    X: array-like, shape (n_samples, n_features) - The training data.
    y: array-like, shape (n_samples,) - The target values.
get_distance_indices(self, X)
Compute the distances and return the indices of the nearest points im the training data.
 
Args:
    X: array-like, shape (n_samples, n_features) - The input data.
 
Returns:
    indices: array, shape (n_samples, n_neighbors) - The indices of the nearest neighbors.

Data descriptors inherited from sega_learn.nearest_neighbors.base.KNeighborsBase:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class Lasso(builtins.object)
    Lasso(alpha=1.0, fit_intercept=True, max_iter=10000, tol=0.0001, compile_numba=False)
 
Fits the Lasso Regression model to the training data.
 
Lasso regression implements L1 regularization, which helps to prevent overfitting by adding a penalty term to the loss function.
 
Args:
    X_train: (np.ndarray) - Training feature data of shape (n_samples, n_features).
    y_train: (np.ndarray) - Training target data of shape (n_samples,).
    X_test: (np.ndarray), optional - Testing feature data (default is None).
    y_test: (np.ndarray), optional - Testing target data (default is None).
    custom_metrics: (dict: str -> callable), optional - Custom metrics for evaluation (default is None).
    verbose: (bool), optional - If True, prints progress (default is False).
 
Attributes:
    coef_: (np.ndarray) - Estimated coefficients for the linear regression problem. If `fit_intercept` is True, the first element is the intercept.
    intercept_: (float) - Independent term in the linear model. Set to 0.0 if `fit_intercept` is False.
 
Returns:
    results: (list) - A list of dictionaries containing model performance metrics.
    predictions: (dict) - A dictionary of predictions for each model.
 
  Methods defined here:
__init__(self, alpha=1.0, fit_intercept=True, max_iter=10000, tol=0.0001, compile_numba=False)
Initializes the Lasso Regression model.
 
Lasso regression implements L1 regularization, which helps to prevent overfitting by adding a penalty term to the loss function.
 
Args:
    alpha: (float) - Regularization strength; must be a positive float (default is 1.0).
    fit_intercept: (bool), optional - Whether to calculate the intercept for this model (default is True).
    max_iter: (int), optional - Maximum number of iterations for the coordinate descent solver (default is 10000).
    tol: (float), optional - Tolerance for the optimization. The optimization stops when the change in the coefficients is less than this tolerance (default is 1e-4).
    compile_numba: (bool), optional - Whether to precompile the numba functions (default is False). If True, the numba fitting functions will be compiled before use.
__str__(self)
Returns the string representation of the model.
fit(self, X, y, numba=False)
Fits the Lasso Regression model to the training data using coordinate descent.
 
Args:
    X: (np.ndarray) - Training feature data of shape (n_samples, n_features).
    y: (np.ndarray) - Training target data of shape (n_samples,).
    numba: (bool), optional - Whether to use numba for faster computation (default is False).
 
Returns:
    self: (Lasso) - The fitted Lasso Regression model.
get_formula(self)
Computes the formula of the model.
 
Returns:
- formula : str: The formula of the model.
predict(self, X)
Predicts the target values using the Lasso Regression model.
 
Args:
    X: (np.ndarray) - Feature data of shape (n_samples, n_features).
 
Returns:
    y_pred: (np.ndarray) - Predicted target values of shape (n_samples,).

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class LinearDiscriminantAnalysis(builtins.object)
    LinearDiscriminantAnalysis(solver='svd', priors=None)
 
Implements Linear Discriminant Analysis.
 
A classifier with a linear decision boundary, generated by fitting class conditional densities to the data and using Bayes' rule.
 
Args:
    solver: (str) - {'svd', 'lsqr', 'eigen'}, default='svd'. Solver to use for the LDA.
    priors: (np.ndarray), optional - Prior probabilities of the classes (default is None).
 
  Methods defined here:
__init__(self, solver='svd', priors=None)
Initializes the Linear Discriminant Analysis model.
 
Args:
    solver: (str) - {'svd', 'lsqr', 'eigen'}, default='svd'. Solver to use for the LDA.
    priors: (np.ndarray), optional - Prior probabilities of the classes (default is None).
decision_function(self, X)
Computes the log-likelihood of each class for the input data. The decision function is the log-likelihood of each class.
 
Args:
    X: (np.ndarray) - Test feature data.
 
Returns:
    scores: (np.ndarray) - Log-likelihood of each class for the input samples.
fit(self, X, y)
Fits the LDA model to the training data.
 
Args:
    X: (np.ndarray) - Training feature data.
    y: (np.ndarray) - Training target data.
predict(self, X)
Predicts class labels for the input data.
 
Args:
    X: (np.ndarray) - Test feature data.
 
Returns:
    predictions: (np.ndarray) - Predicted class labels.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
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

 
class LogisticRegression(builtins.object)
    LogisticRegression(learning_rate=0.01, max_iter=1000)
 
Implements Logistic Regression using gradient descent. Supports binary and multiclass classification.
 
Args:
    learning_rate: (float) - Learning rate for gradient updates (default is 0.01).
    max_iter: (int) - Maximum number of iterations (default is 1000).
 
  Methods defined here:
__init__(self, learning_rate=0.01, max_iter=1000)
Initializes the classifier with specified hyperparameters.
 
Args:
    learning_rate (float, optional): The step size for updating weights during training. Defaults to 0.01.
    max_iter (int, optional): The maximum number of iterations for the training process. Defaults to 1000.
fit(self, X, y)
Fits the Logistic Regression model to the training data.
 
Args:
    X: (np.ndarray) - Training feature data of shape (n_samples, n_features).
    y: (np.ndarray) - Training target data of shape (n_samples,).
predict(self, X)
Predicts class labels for the input data.
 
Args:
    X: (np.ndarray) - Test feature data.
 
Returns:
    predictions: (np.ndarray) - Predicted class labels.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class MeanAbsoluteErrorLoss(builtins.object)
    Custom mean absolute error loss implementation using numpy.
 
Formula: mean(abs(y_true - y_pred))
 
Methods:
    __call__(self, y_true, y_pred): Calculate the mean absolute error loss.
 
  Methods defined here:
__call__(self, y_true, y_pred)
Calculate the mean absolute error loss.
 
Args:
    y_true (np.ndarray): The true labels of shape (num_samples,).
    y_pred (np.ndarray): The predicted values of shape (num_samples,).
 
Returns:
    float: The mean absolute error loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class MeanSquaredErrorLoss(builtins.object)
    Custom mean squared error loss implementation using numpy.
 
Formula: mean((y_true - y_pred) ** 2)
 
Methods:
    __call__(self, y_true, y_pred): Calculate the mean squared error loss.
 
  Methods defined here:
__call__(self, y_true, y_pred)
Calculate the mean squared error loss.
 
Args:
    y_true (np.ndarray): The true labels of shape (num_samples,).
    y_pred (np.ndarray): The predicted values of shape (num_samples,).
 
Returns:
    float: The mean squared error loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class Metrics(builtins.object)
    Implements various regression and classification metrics.
 
  Class methods defined here:
accuracy(y_true, y_pred)
Calculates the accuracy score between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    accuracy: (float) - The accuracy score.
classification_report(y_true, y_pred)
Generates a classification report for the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    report: (dict) - The classification report.
confusion_matrix(y_true, y_pred)
Calculates the confusion matrix between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    cm: (np.ndarray) - The confusion matrix.
f1_score(y_true, y_pred)
Calculates the F1 score between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    f1_score: (float) - The F1 score.
log_loss(y_true, y_pred)
Calculates the log loss between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted probabilities.
 
Returns:
    log_loss: (float) - The log loss.
mean_absolute_error(y_true, y_pred)
Calculates the mean absolute error between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    mae: (float) - The mean absolute error.
mean_absolute_percentage_error(y_true, y_pred)
Calculates the mean absolute percentage error between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    mape: (float) - The mean absolute percentage error as a decimal. Returns np.nan if y_true is all zeros.
mean_percentage_error(y_true, y_pred)
Calculates the mean percentage error between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    mpe: (float) - The mean percentage error.
mean_squared_error(y_true, y_pred)
Calculates the mean squared error between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    mse: (float) - The mean squared error.
precision(y_true, y_pred)
Calculates the precision score between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    precision: (float) - The precision score.
r_squared(y_true, y_pred)
Calculates the R-squared score between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    r_squared: (float) - The R-squared score.
recall(y_true, y_pred)
Calculates the recall score between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    recall: (float) - The recall score.
root_mean_squared_error(y_true, y_pred)
Calculates the root mean squared error between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    rmse: (float) - The root mean squared error.
show_classification_report(y_true, y_pred)
Generates and displays a classification report for the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    report: (dict) - The classification report.
show_confusion_matrix(y_true, y_pred)
Calculates and displays the confusion matrix between the true and predicted values.
 
Args:
    y_true: (np.ndarray) - The true values.
    y_pred: (np.ndarray) - The predicted values.
 
Returns:
    cm: (np.ndarray) - The confusion matrix.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ModelSelectionUtility(builtins.object)
    A utility class for hyperparameter tuning and cross-validation of machine learning models.
 
  Static methods defined here:
cross_validate(model, X, y, params, cv=5, metric='mse', direction='minimize', verbose=False)
Implements a custom cross-validation for hyperparameter tuning.
 
Args:
    model: The model Object to be tuned.
    X: (numpy.ndarray) - The feature columns.
    y: (numpy.ndarray) - The label column.
    params: (dict) - The hyperparameters to be tuned.
    cv: (int) - The number of folds for cross-validation. Default is 5.
    metric: (str) - The metric to be used for evaluation. Default is 'mse'.
        - Regression Metrics: 'mse', 'r2', 'mae', 'rmse', 'mape', 'mpe'
        - Classification Metrics: 'accuracy', 'precision', 'recall', 'f1', 'log_loss'
    direction: (str) - The direction to optimize the metric. Default is 'minimize'.
    verbose: (bool) - A flag to display the training progress. Default is False.
 
Returns:
    tuple: A tuple containing the scores (list) and the trained model.
get_param_combinations(param_grid)
Generates all possible combinations of hyperparameters.
 
Returns:
    param_combinations (list): A list of dictionaries containing hyperparameter combinations.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class MultiplicativeDecomposition(builtins.object)
    MultiplicativeDecomposition(period)
 
Performs classical multiplicative decomposition of a time series.
 
Decomposes the series Y into Trend (T), Seasonal (S), and Residual (R) components
such that Y = T * S * R. Assumes seasonality changes proportionally to the trend.
 
Handles non-positive values by shifting the data to be positive before decomposition.
Note: This affects the interpretation of the components.
 
Attributes:
    period (int): The seasonal period.
    time_series (np.ndarray): The original time series data.
    offset (float): The offset added to the series to make it positive (0 if originally positive).
    trend (np.ndarray): The estimated trend component (adjusted back to original scale).
    seasonal (np.ndarray): The estimated seasonal component (from shifted data).
    residual (np.ndarray): The estimated residual component (from shifted data).
    _trend_shifted (np.ndarray): Internal storage of trend from shifted data.
 
  Methods defined here:
__init__(self, period)
Initialize the MultiplicativeDecomposition model.
 
Args:
    period (int): The seasonal period (e.g., 12 for monthly, 7 for daily). Must be > 1.
__str__(self)
Return str(self).
fit(self, time_series)
Perform multiplicative decomposition on the time series.
 
If the series contains non-positive values, it is shifted before decomposition.
This is done to ensure positivity of the seasonal component, but affects the
interpretation of the components.
 
Args:
    time_series (array-like): The time series data. Must be 1-dimensional,and have length >= 2 * period.
 
Returns:
    tuple: The calculated trend, seasonal, and residual components.
get_components(self)
Return the calculated components.
 
Note: Trend is adjusted back to original scale. Seasonal and Residual
      are derived from the shifted data if an offset was applied.
reconstruct(self)
Reconstruct the series from components.
 
Accounts for any offset applied during fitting.
Reconstruction formula: Y_recon = T_shifted * S * R - offset
                            = (T + offset) * S * R - offset

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class NeuralNetworkBase(builtins.object)
    NeuralNetworkBase(layers, dropout_rate=0.0, reg_lambda=0.0, activations=None, loss_function=None, regressor=False)
 
NeuralNetworkBase is an abstract base class for building neural networks.
 
It provides a framework for initializing layers, performing forward and backward propagation,
training, evaluating, and predicting with a neural network. Subclasses should implement
the abstract methods to define specific behavior.
 
Attributes:
    layer_sizes (list): Sizes of the layers in the network.
    dropout_rate (float): Dropout rate for regularization.
    reg_lambda (float): Regularization strength for L2 regularization.
    activations (list): Activation functions for each layer.
    layers (list): List of layer objects or configurations.
    weights (list): List of weight matrices for the layers.
    biases (list): List of bias vectors for the layers.
    layer_outputs (ndarray): Outputs of each layer during forward propagation.
    is_binary (bool): Whether the network is for binary classification.
 
Methods:
    __init__(layers, dropout_rate=0.0, reg_lambda=0.0, activations=None, loss_function=None, regressor=False):
        Initializes the neural network with the given layers and parameters.
    initialize_layers():
        Abstract method to initialize the weights and biases of the layers.
    forward(X, training=True):
        Abstract method to perform forward propagation through the network.
    backward(y):
        Abstract method to perform backward propagation through the network.
    train(X_train, y_train, X_val=None, y_val=None, optimizer=None, epochs=100,
            batch_size=32, early_stopping_threshold=10, lr_scheduler=None, p=True,
            use_tqdm=True, n_jobs=1, track_metrics=False, track_adv_metrics=False):
        Abstract method to train the neural network using the provided training data.
    evaluate(X, y):
        Abstract method to evaluate the neural network on the provided data.
    predict(X):
        Abstract method to make predictions using the trained neural network.
    calculate_loss(X, y):
        Abstract method to calculate the loss of the neural network.
    apply_dropout(X):
        Applies dropout to the activation values for regularization.
    compute_l2_reg(weights):
        Computes the L2 regularization term for the given weights.
    calculate_precision_recall_f1(X, y):
        Calculates precision, recall, and F1 score for the predictions.
    create_scheduler(scheduler_type, optimizer, **kwargs):
        Creates a learning rate scheduler based on the specified type.
    plot_metrics(save_dir=None):
        Plots the training and validation metrics, including loss, accuracy,
        learning rate, and optionally precision, recall, and F1 score.
 
  Methods defined here:
__init__(self, layers, dropout_rate=0.0, reg_lambda=0.0, activations=None, loss_function=None, regressor=False)
Initializes the neural network with the specified layers, dropout rate, regularization, and activations.
 
Args:
    layers: (list) - A list of integers representing the sizes of each layer or a list of Layer objects.
    dropout_rate: (float), optional - The dropout rate for regularization (default is 0.0).
    reg_lambda: (float), optional - The regularization strength (default is 0.0).
    activations: (list of str), optional - A list of activation functions for each layer (default is None, which sets "relu" for hidden layers and "softmax" for the output layer).
    loss_function: (callable), optional - Custom loss function to use (default is None, which uses the default calculate_loss implementation).
    regressor: (bool), optional - If True, the network is treated as a regressor (default is False).
 
Raises:
    ValueError: If `layers` is not a list of integers or a list of Layer objects.
apply_dropout(self, X)
Applies dropout to the activation X.
 
Args:
    X: (ndarray) - Activation values.
 
Returns:
    ndarray: Activation values after applying dropout.
backward(self, y)
Performs backward propagation through the network.
calculate_loss(self, X, y)
Calculates the loss of the neural network.
calculate_precision_recall_f1(self, X, y)
Calculates precision, recall, and F1 score.
 
Args:
    X: (ndarray) - Input data
    y: (ndarray) - Target labels
Returns:
    precision: (float) - Precision score
    recall: (float) - Recall score
    f1: (float) - F1 score
compute_l2_reg(self, weights)
Computes the L2 regularization term.
 
Args:
    weights: (list) - List of weight matrices.
 
Returns:
    float: L2 regularization term.
create_scheduler(self, scheduler_type, optimizer, **kwargs)
Creates a learning rate scheduler.
evaluate(self, X, y)
Evaluates the neural network on the provided data.
forward(self, X, training=True)
Performs forward propagation through the network.
initialize_layers(self)
Initializes the weights and biases of the layers.
plot_metrics(self, save_dir=None)
Plots the training and validation metrics.
predict(self, X)
Makes predictions using the trained neural network.
train(self, X_train, y_train, X_val=None, y_val=None, optimizer=None, epochs=100, batch_size=32, early_stopping_threshold=10, lr_scheduler=None, p=True, use_tqdm=True, n_jobs=1, track_metrics=False, track_adv_metrics=False)
Trains the neural network using the provided training data.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class NumbaBackendNeuralNetwork(sega_learn.neural_networks.neuralNetworkBase.NeuralNetworkBase)
    NumbaBackendNeuralNetwork(layers, dropout_rate=0.2, reg_lambda=0.01, activations=None, loss_function=None, regressor=False, compile_numba=True, progress_bar=True)
 
A neural network implementation using Numba for Just-In-Time (JIT) compilation to optimize performance.
 
This class supports forward and backward propagation, training, evaluation, and hyperparameter tuning
with various optimizers and activation functions.
 
Attributes:
    compiled (bool): Indicates whether Numba functions are compiled.
    trainable_layers (list): Layers with trainable parameters (weights and biases).
    progress_bar (bool): Whether to display a progress bar during training.
 
Methods:
    __init__(layers, dropout_rate, reg_lambda, activations, compile_numba, progress_bar):
        Initializes the neural network with the specified parameters.
    store_init_layers():
        Stores the initial layers and their parameters for restoration after initialization.
    restore_layers():
        Restores the layers and their parameters after initialization.
    initialize_new_layers():
        Initializes the layers of the neural network with specified sizes and activation functions.
    forward(X, training):
        Performs forward propagation through the neural network.
    backward(y):
        Performs backward propagation to calculate gradients.
    is_not_instance_of_classes(obj, classes):
        Checks if an object is not an instance of any class in a list of classes.
    train(X_train, y_train, X_val, y_val, optimizer, epochs, batch_size, early_stopping_threshold,
          lr_scheduler, p, use_tqdm, n_jobs, track_metrics, track_adv_metrics, save_animation,
          save_path, fps, dpi, frame_every):
        Trains the neural network model with the specified parameters.
    evaluate(X, y):
        Evaluates the neural network on the given data and returns accuracy and predictions.
    predict(X):
        Predicts the output for the given input data.
    calculate_loss(X, y):
        Calculates the loss with L2 regularization.
    _create_optimizer(optimizer_type, learning_rate, JIT):
        Helper method to create optimizer instances.
    tune_hyperparameters(X_train, y_train, X_val, y_val, param_grid, layer_configs, optimizer_types,
                         lr_range, epochs, batch_size):
        Performs hyperparameter tuning using grid search.
    compile_numba_functions(progress_bar):
        Compiles all Numba JIT functions to improve performance.
 
 
Method resolution order:
NumbaBackendNeuralNetwork
sega_learn.neural_networks.neuralNetworkBase.NeuralNetworkBase
builtins.object

Methods defined here:
__init__(self, layers, dropout_rate=0.2, reg_lambda=0.01, activations=None, loss_function=None, regressor=False, compile_numba=True, progress_bar=True)
Initializes the Numba backend neural network.
 
Args:
    layers: (list) - List of layer sizes or Layer objects.
    dropout_rate: (float) - Dropout rate for regularization.
    reg_lambda: (float) - L2 regularization parameter.
    activations: (list) - List of activation functions for each layer.
    loss_function: (callable) optional - Custom loss function (default: selects based on task).
    regressor: (bool) - Whether the model is a regressor (default is False).
    compile_numba: (bool) - Whether to compile Numba functions.
    progress_bar: (bool) - Whether to display a progress bar.
backward(self, y)
Performs backward propagation to calculate the gradients.
 
Args:
    y (ndarray): Target labels of shape (m, output_size).
calculate_loss(self, X, y)
Calculates the loss with L2 regularization.
 
Args:
    X (ndarray): Input data.
    y (ndarray): Target labels.
 
Returns:
    float: The calculated loss value.
compile_numba_functions(self, progress_bar=True)
Compiles all Numba JIT functions to improve performance.
 
Args:
    progress_bar (bool): Whether to display a progress bar.
evaluate(self, X, y)
Evaluates the neural network on the given data.
 
Args:
    X (ndarray): Input data.
    y (ndarray): Target labels.
 
Returns:
    tuple: Accuracy and predicted labels.
forward(self, X, training=True)
Performs forward propagation through the neural network.
 
Args:
    X (ndarray): Input data of shape (batch_size, input_size).
    training (bool): Whether the network is in training mode (applies dropout).
 
Returns:
    ndarray: Output predictions of shape (batch_size, output_size).
initialize_new_layers(self)
Initializes the layers of the neural network.
 
Each layer is created with the specified number of neurons and activation function.
predict(self, X)
Predicts the output for the given input data.
 
Args:
    X (ndarray): Input data.
 
Returns:
    ndarray: Predicted outputs.
restore_layers(self)
Restores the layers after initialization.
store_init_layers(self)
Stores the layers to restore after initialization.
train(self, X_train, y_train, X_val=None, y_val=None, optimizer=None, epochs=100, batch_size=32, early_stopping_threshold=10, lr_scheduler=None, p=True, use_tqdm=True, n_jobs=1, track_metrics=False, track_adv_metrics=False, save_animation=False, save_path='training_animation.mp4', fps=1, dpi=100, frame_every=1)
Trains the neural network model.
 
Args:
    X_train: (ndarray) - Training data features.
    y_train: (ndarray) - Training data labels.
    X_val: (ndarray) - Validation data features, optional.
    y_val: (ndarray) - Validation data labels, optional.
    optimizer: (Optimizer) - Optimizer for updating parameters (default: JITAdam, lr=0.0001).
    epochs: (int) - Number of training epochs (default: 100).
    batch_size: (int) - Batch size for mini-batch gradient descent (default: 32).
    early_stopping_threshold: (int) - Patience for early stopping (default: 10).
    lr_scheduler: (Scheduler) - Learning rate scheduler (default: None).
    p: (bool) - Whether to print training progress (default: True).
    use_tqdm: (bool) - Whether to use tqdm for progress bar (default: True).
    n_jobs: (int) - Number of jobs for parallel processing (default: 1).
    track_metrics: (bool) - Whether to track training metrics (default: False).
    track_adv_metrics: (bool) - Whether to track advanced metrics (default: False).
    save_animation: (bool) - Whether to save the animation of metrics (default: False).
    save_path: (str) - Path to save the animation file. File extension must be .mp4 or .gif (default: 'training_animation.mp4').
    fps: (int) - Frames per second for the saved animation (default: 1).
    dpi: (int) - DPI for the saved animation (default: 100).
    frame_every: (int) - Capture frame every N epochs (to reduce file size) (default: 1).
tune_hyperparameters(self, X_train, y_train, X_val, y_val, param_grid, layer_configs=None, optimizer_types=None, lr_range=(0.0001, 0.01, 5), epochs=30, batch_size=32)
Performs hyperparameter tuning using grid search.
 
Args:
    X_train: (np.ndarray) - Training feature data.
    y_train: (np.ndarray) - Training target data.
    X_val: (np.ndarray) - Validation feature data.
    y_val: (np.ndarray) - Validation target data.
    param_grid: (dict) - Dictionary of parameters to try.
    layer_configs: (list), optional - List of layer configurations (default is None).
    optimizer_types: (list), optional - List of optimizer types (default is None).
    lr_range: (tuple), optional - (min_lr, max_lr, num_steps) for learning rates (default is (0.0001, 0.01, 5)).
    epochs: (int), optional - Max epochs for each trial (default is 30).
    batch_size: (int), optional - Batch size for training (default is 32).
 
Returns:
    best_params: (dict) - Best hyperparameters found.
    best_accuracy: (float) - Best validation accuracy.

Static methods defined here:
is_not_instance_of_classes(obj, classes)
Checks if an object is not an instance of any class in a list of classes.
 
Args:
    obj: The object to check.
    classes: A list of classes.
 
Returns:
    bool: True if the object is not an instance of any class in the list of classes, False otherwise.

Methods inherited from sega_learn.neural_networks.neuralNetworkBase.NeuralNetworkBase:
apply_dropout(self, X)
Applies dropout to the activation X.
 
Args:
    X: (ndarray) - Activation values.
 
Returns:
    ndarray: Activation values after applying dropout.
calculate_precision_recall_f1(self, X, y)
Calculates precision, recall, and F1 score.
 
Args:
    X: (ndarray) - Input data
    y: (ndarray) - Target labels
Returns:
    precision: (float) - Precision score
    recall: (float) - Recall score
    f1: (float) - F1 score
compute_l2_reg(self, weights)
Computes the L2 regularization term.
 
Args:
    weights: (list) - List of weight matrices.
 
Returns:
    float: L2 regularization term.
create_scheduler(self, scheduler_type, optimizer, **kwargs)
Creates a learning rate scheduler.
initialize_layers(self)
Initializes the weights and biases of the layers.
plot_metrics(self, save_dir=None)
Plots the training and validation metrics.

Data descriptors inherited from sega_learn.neural_networks.neuralNetworkBase.NeuralNetworkBase:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class OneClassSVM(sega_learn.svm.baseSVM.BaseSVM)
    OneClassSVM(C=1.0, tol=0.0001, max_iter=1000, learning_rate=0.01, kernel='linear', degree=3, gamma='scale', coef0=0.0)
 
OneClassSVM is a custom implementation of a One-Class Support Vector Machine (SVM) for anomaly detection using gradient descent.
 
It inherits from the BaseSVM class and supports various kernel functions.
 
Attributes:
    support_vectors_ (array-like of shape (n_support_vectors, n_features)):
        The support vectors identified during training.
    support_vector_alphas_ (array-like of shape (n_support_vectors,)):
        The Lagrange multipliers (alpha) corresponding to the support vectors.
    b (float):
        The bias term (rho) computed during training.
 
Methods:
    __init__(C=1.0, tol=1e-4, max_iter=1000, learning_rate=0.01, kernel="linear",
             degree=3, gamma="scale", coef0=0.0):
        Initialize the OneClassSVM with hyperparameters.
    _fit(X, y=None):
        Fit the OneClassSVM model using gradient descent for anomaly detection.
    decision_function(X):
        Compute the decision function values for the input samples.
    predict(X):
        Predict whether the input samples are inliers (1) or outliers (-1).
    score(X, y):
        Compute the mean accuracy of predictions compared to true labels.
    __sklearn_is_fitted__():
        Check if the model has been fitted. For compatibility with sklearn.
 
 
Method resolution order:
OneClassSVM
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)
Initialize the OneClassSVM with 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 (default is 1000).
    learning_rate: (float) - Learning rate for gradient descent (default is 0.01).
    kernel: (str) - Kernel type ("linear", "poly", "rbf", "sigmoid") (default is "linear").
    degree: (int) - Degree for polynomial kernel (default is 3).
    gamma: (str or float) - Kernel coefficient ("scale", "auto", or float) (default is "scale").
    coef0: (float) - Independent term in kernel function (default is 0.0).
__sklearn_is_fitted__(self)
Check if the model has been fitted. For compatibility with sklearn.
 
Returns:
    fitted: (bool) - True if the model has been fitted, otherwise False.
decision_function(self, X)
Compute the decision function values for the input samples.
predict(self, X)
Predict whether the input samples are inliers (1) or outliers (-1).
score(self, X, y)
Compute the mean accuracy of predictions.
 
Args:
    X: (array-like of shape (n_samples, n_features)) - Test samples.
    y: (array-like of shape (n_samples,)) - True labels (+1 for inliers, -1 for outliers).
 
Returns:
    score: (float) - Mean accuracy of predictions.

Methods inherited from sega_learn.svm.baseSVM.BaseSVM:
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

 
class OrdinaryLeastSquares(builtins.object)
    OrdinaryLeastSquares(fit_intercept=True) -&gt; None
 
Ordinary Least Squares (OLS) linear regression model.
 
Attributes:
    coef_ : ndarray of shape (n_features,) or (n_features + 1,) - Estimated coefficients for the linear regression problem. If `fit_intercept` is True, the first element is the intercept.
    intercept_ : float - Independent term in the linear model. Set to 0.0 if `fit_intercept` is False.
 
Methods:
    fit(X, y): Fit the linear model to the data.
    predict(X): Predict using the linear model.
    get_formula(): Returns the formula of the model as a string.
 
  Methods defined here:
__init__(self, fit_intercept=True) -> None
Initializes the OrdinaryLeastSquares object.
 
Args:
    fit_intercept: (bool) - Whether to calculate the intercept for this model (default is True).
__str__(self)
Returns the string representation of the model.
fit(self, X, y)
Fits the linear regression model to the training data.
 
Args:
    X: (np.ndarray) - Training feature data of shape (n_samples, n_features).
    y: (np.ndarray) - Training target data of shape (n_samples,).
 
Returns:
    self: (OrdinaryLeastSquares) - The fitted linear regression model.
get_formula(self)
Returns the formula of the model as a string.
 
Returns:
    formula: (str) - The formula of the model.
predict(self, X)
Predicts the target values using the linear model.
 
Args:
    X: (np.ndarray) - Feature data of shape (n_samples, n_features).
 
Returns:
    y_pred: (np.ndarray) - Predicted target values of shape (n_samples,).

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class PCA(builtins.object)
    PCA(n_components)
 
Principal Component Analysis (PCA) implementation.
 
  Methods defined here:
__init__(self, n_components)
Initializes the PCA model.
 
Args:
    n_components: (int) - Number of principal components to keep.
fit(self, X)
Fits the PCA model to the data.
 
Args:
    X: (np.ndarray) - Input data of shape (n_samples, n_features).
 
Raises:
    ValueError: If input data is not a 2D numpy array or if n_components exceeds the number of features.
fit_transform(self, X)
Fits the PCA model and applies dimensionality reduction on the input data.
 
Args:
    X: (np.ndarray) - Input data of shape (n_samples, n_features).
 
Returns:
    X_transformed: (np.ndarray) - Data transformed into the principal component space of shape (n_samples, n_components).
get_components(self)
Retrieves the principal components.
 
Returns:
    components_: (np.ndarray) - Array of principal components of shape (n_features, n_components).
get_explained_variance_ratio(self)
Retrieves the explained variance ratio.
 
Returns:
    explained_variance_ratio_: (np.ndarray) - Array of explained variance ratios for each principal component.
inverse_transform(self, X_reduced)
Reconstructs the original data from the reduced data.
 
Args:
    X_reduced: (np.ndarray) - Reduced data of shape (n_samples, n_components).
 
Returns:
    X_original: (np.ndarray) - Reconstructed data of shape (n_samples, n_features).
 
Raises:
    ValueError: If input data is not a 2D numpy array.
transform(self, X)
Applies dimensionality reduction on the input data.
 
Args:
    X: (np.ndarray) - Input data of shape (n_samples, n_features).
 
Returns:
    X_transformed: (np.ndarray) - Data transformed into the principal component space of shape (n_samples, n_components).
 
Raises:
    ValueError: If input data is not a 2D numpy array or if its dimensions do not match the fitted data.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class PassiveAggressiveRegressor(builtins.object)
    PassiveAggressiveRegressor(C=1.0, max_iter=1000, tol=0.001)
 
Fits the Passive Aggressive Regression model to the training data.
 
Args:
    X: (np.ndarray) - Training feature data of shape (n_samples, n_features).
    y: (np.ndarray) - Training target data of shape (n_samples,).
    save_steps: (bool), optional - Whether to save the weights and intercept at each iteration (default is False).
    verbose: (bool), optional - If True, prints progress during training (default is False).
 
Attributes:
    coef_: (np.ndarray) - Estimated coefficients for the regression problem.
    intercept_: (float) - Independent term in the linear model.
    steps_: (list of tuples), optional - The weights and intercept at each iteration if `save_steps` is True.
 
  Methods defined here:
__init__(self, C=1.0, max_iter=1000, tol=0.001)
Fits the Passive Aggressive Regression model to the training data.
 
Args:
    C: (float) - Regularization parameter/step size (default is 1.0).
    max_iter: (int) - The maximum number of passes over the training data (default is 1000).
    tol: (float) - The stopping criterion (default is 1e-3).
 
Attributes:
    coef_: (np.ndarray) - Estimated coefficients for the regression problem.
    intercept_: (float) - Independent term in the linear model.
__str__(self)
Returns the string representation of the model.
fit(self, X, y, save_steps=False, verbose=False)
Fits the Passive Aggressive Regression model to the training data.
 
Args:
    X: (np.ndarray) - Training feature data of shape (n_samples, n_features).
    y: (np.ndarray) - Training target data of shape (n_samples,).
    save_steps: (bool), optional - Whether to save the weights and intercept at each iteration (default is False).
    verbose: (bool), optional - If True, prints progress during training (default is False).
 
Returns:
    None
get_formula(self)
Computes the formula of the model.
 
Returns:
    formula : str: The formula of the model.
predict(self, X)
Predict using the linear model. Dot product of X and the coefficients.
predict_all_steps(self, X)
Predict using the linear model at each iteration. (save_steps=True).

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class Perceptron(builtins.object)
    Perceptron(max_iter=1000, learning_rate=0.01)
 
Implements the Perceptron algorithm for binary and multiclass classification.
 
Args:
    max_iter: (int) - Maximum number of iterations (default is 1000).
    learning_rate: (float) - Learning rate for weight updates (default is 0.01).
 
  Methods defined here:
__init__(self, max_iter=1000, learning_rate=0.01)
Initializes the classifier with the specified maximum number of iterations and learning rate.
 
Args:
    max_iter (int, optional): The maximum number of iterations for the training process. Defaults to 1000.
    learning_rate (float, optional): The learning rate for the optimization algorithm. Defaults to 0.01.
fit(self, X, y)
Fits the Perceptron model to the training data.
 
Args:
    X: (np.ndarray) - Training feature data of shape (n_samples, n_features).
    y: (np.ndarray) - Training target data of shape (n_samples,).
predict(self, X)
Predicts class labels for the input data.
 
Args:
    X: (np.ndarray) - Test feature data.
 
Returns:
    predictions: (np.ndarray) - Predicted class labels.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class PolynomialTransform(builtins.object)
    PolynomialTransform(degree=2)
 
Implements Polynomial Feature Transformation.
 
Polynomial feature transformation creates new features by raising existing features to a power or creating interaction terms.
 
Args:
    degree (int): The degree of the polynomial features (default is 2).
 
Attributes:
    n_samples (int): The number of samples in the input data.
    n_features (int): The number of features in the input data.
    n_output_features (int): The number of output features after transformation.
    combinations (list of tuples): The combinations of features for polynomial terms.
 
  Methods defined here:
__init__(self, degree=2)
Initialize the PolynomialTransform object.
fit(self, X)
Fit the model to the data.
 
Uses itertools.combinations_with_replacement to generate all possible combinations of features(X) of degree n.
fit_transform(self, X)
Fit to data, then transform it.
transform(self, X)
Transform the data into polynomial features by computing the product of the features for each combination of features.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class QuadraticDiscriminantAnalysis(builtins.object)
    QuadraticDiscriminantAnalysis(priors=None, reg_param=0.0)
 
Implements Quadratic Discriminant Analysis.
 
The quadratic term allows for more flexibility in modeling the class conditional
A classifier with a quadratic decision boundary, generated by fitting class conditional densities to the data and using Bayes' rule.
 
Args:
    priors: (np.ndarray), optional - Prior probabilities of the classes (default is None).
    reg_param: (float), optional - Regularization parameter (default is 0.0).
 
  Methods defined here:
__init__(self, priors=None, reg_param=0.0)
Initialize the Quadratic Discriminant Analysis model with the specified prior probabilities and regularization parameter.
 
Args:
    priors: (np.ndarray), optional - Prior probabilities of the classes (default is None).
    reg_param: (float), optional - Regularization parameter (default is 0.0).
decision_function(self, X)
Apply decision function to an array of samples.
 
The decision function is the log-likelihood of each class.
 
Args:
    X: (np.ndarray) - Test feature data.
 
Returns:
    scores: (np.ndarray) - Log-likelihood of each class for the input samples.
fit(self, X, y)
Fit the model according to the given training data. Uses the means and covariance matrices of each class.
 
Args:
    X: (np.ndarray) - Training feature data.
    y: (np.ndarray) - Training target data.
predict(self, X)
Perform classification on an array of test vectors X.
 
Args:
    X: (np.ndarray) - Test feature data.
 
Returns:
    predictions: (np.ndarray) - Predicted class labels.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class RANSAC(builtins.object)
    RANSAC(n=10, k=100, t=0.05, d=10, model=None, auto_scale_t=False, scale_t_factor=2, auto_scale_n=False, scale_n_factor=2)
 
Fits the RANSAC (RANdom SAmple Consensus) algorithm for robust linear regression.
 
Args:
    X_train: (np.ndarray) - Training feature data.
    y_train: (np.ndarray) - Training target data.
    X_test: (np.ndarray), optional - Testing feature data (default is None).
    y_test: (np.ndarray), optional - Testing target data (default is None).
    n: (int), optional - Number of data points to estimate parameters (default is 10).
    k: (int), optional - Maximum iterations allowed (default is 100).
    t: (float), optional - Threshold value to determine if points are fit well, in terms of residuals (default is 0.05).
    d: (int), optional - Number of close data points required to assert model fits well (default is 10).
    model: (object), optional - The model to use for fitting. If None, uses Ordinary Least Squares (default is None).
    auto_scale_t: (bool), optional - Whether to automatically scale the threshold until a model is fit (default is False).
    scale_t_factor: (float), optional - Factor by which to scale the threshold until a model is fit (default is 2).
    auto_scale_n: (bool), optional - Whether to automatically scale the number of data points until a model is fit (default is False).
    scale_n_factor: (float), optional - Factor by which to scale the number of data points until a model is fit (default is 2).
 
Returns:
    best_fit: (object) - The best model fit.
    best_error: (float) - The best error achieved by the model.
    best_n: (int) - The best number of data points used to fit the model.
    best_t: (float) - The best threshold value used to determine if points are fit well, in terms of residuals.
    best_model: (object) - The best model fit.
 
  Methods defined here:
__init__(self, n=10, k=100, t=0.05, d=10, model=None, auto_scale_t=False, scale_t_factor=2, auto_scale_n=False, scale_n_factor=2)
Fits the RANSAC (RANdom SAmple Consensus) algorithm for robust linear regression.
 
Args:
    X_train: (np.ndarray) - Training feature data.
    y_train: (np.ndarray) - Training target data.
    X_test: (np.ndarray), optional - Testing feature data (default is None).
    y_test: (np.ndarray), optional - Testing target data (default is None).
    n: (int), optional - Number of data points to estimate parameters (default is 10).
    k: (int), optional - Maximum iterations allowed (default is 100).
    t: (float), optional - Threshold value to determine if points are fit well, in terms of residuals (default is 0.05).
    d: (int), optional - Number of close data points required to assert model fits well (default is 10).
    model: (object), optional - The model to use for fitting. If None, uses Ordinary Least Squares (default is None).
    auto_scale_t: (bool), optional - Whether to automatically scale the threshold until a model is fit (default is False).
    scale_t_factor: (float), optional - Factor by which to scale the threshold until a model is fit (default is 2).
    auto_scale_n: (bool), optional - Whether to automatically scale the number of data points until a model is fit (default is False).
    scale_n_factor: (float), optional - Factor by which to scale the number of data points until a model is fit (default is 2).
 
Returns:
    best_fit: (object) - The best model fit.
    best_error: (float) - The best error achieved by the model.
    best_n: (int) - The best number of data points used to fit the model.
    best_t: (float) - The best threshold value used to determine if points are fit well, in terms of residuals.
    best_model: (object) - The best model fit.
__str__(self)
Returns the string representation of the model.
fit(self, X, y)
Fits the RANSAC model to the training data.
 
Args:
    X: (np.ndarray) - Training feature data of shape (n_samples, n_features).
    y: (np.ndarray) - Training target data of shape (n_samples,).
 
Returns:
    None
get_formula(self)
Computes the formula of the model if fit, else returns "No model fit available".
predict(self, X)
Predicts the target values using the best fit model.
 
Args:
    X: (np.ndarray) - Feature data of shape (n_samples, n_features).
 
Returns:
    y_pred: (np.ndarray) - Predicted target values of shape (n_samples,).

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class RNNLayer(builtins.object)
    RNNLayer(input_size, hidden_size, activation='tanh')
 
Will be implemented later.
 
  Methods defined here:
__init__(self, input_size, hidden_size, activation='tanh')
Will be implemented later.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class RandomForestClassifier(builtins.object)
    RandomForestClassifier(forest_size=100, max_depth=10, min_samples_split=2, n_jobs=-1, random_seed=None, X=None, y=None)
 
RandomForestClassifier is a custom implementation of a Random Forest classifier.
 
Attributes:
    n_estimators (int): The number of trees in the forest.
    max_depth (int): The maximum depth of each tree.
    n_jobs (int): The number of jobs to run in parallel. Defaults to -1 (use all available processors).
    random_state (int or None): The seed for random number generation. Defaults to None.
    trees (list): A list of trained decision trees.
    bootstraps (list): A list of bootstrapped indices for out-of-bag (OOB) scoring.
    X (numpy.ndarray or None): The feature matrix used for training.
    y (numpy.ndarray or None): The target labels used for training.
    accuracy (float): The accuracy of the model after fitting.
    precision (float): The precision of the model after fitting.
    recall (float): The recall of the model after fitting.
    f1_score (float): The F1 score of the model after fitting.
    log_loss (float or None): The log loss of the model after fitting (only for binary classification).
 
Methods:
    __init__(forest_size=100, max_depth=10, n_jobs=-1, random_seed=None, X=None, y=None):
        Initializes the RandomForestClassifier object with the specified parameters.
    fit(X=None, y=None, verbose=False):
        Fits the random forest model to the provided data using parallel processing.
    calculate_metrics(y_true, y_pred):
        Calculates evaluation metrics (accuracy, precision, recall, F1 score, and log loss) for classification.
    predict(X):
        Predicts class labels for the provided data using the trained random forest.
    get_stats(verbose=False):
        Returns the evaluation metrics (accuracy, precision, recall, F1 score, and log loss) as a dictionary.
 
  Methods defined here:
__init__(self, forest_size=100, max_depth=10, min_samples_split=2, n_jobs=-1, random_seed=None, X=None, y=None)
Initializes the RandomForest object.
calculate_metrics(self, y_true, y_pred)
Calculate evaluation metrics for classification.
fit(self, X=None, y=None, sample_weight=None, verbose=False)
Fit the random forest with parallel processing.
get_params(self)
Get the parameters of the RandomForestClassifier.
get_stats(self, verbose=False)
Return the evaluation metrics.
predict(self, X)
Predict class labels for the provided data.
predict_proba(self, X)
Predict class probabilities for the provided data.
 
Args:
    X (array-like): The input features.
 
Returns:
    np.ndarray: A 2D array where each row represents the probability distribution
                over the classes for a record.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class RandomForestRegressor(builtins.object)
    RandomForestRegressor(forest_size=100, max_depth=10, min_samples_split=2, n_jobs=-1, random_seed=None, X=None, y=None)
 
A class representing a Random Forest model for regression.
 
Attributes:
    n_estimators (int): The number of trees in the forest.
    max_depth (int): The maximum depth of each tree.
    min_samples_split (int): The minimum number of samples required to split an internal node.
    n_jobs (int): The number of jobs to run in parallel for fitting.
    random_state (int): Seed for random number generation for reproducibility.
    trees (list): List holding the fitted RegressorTree instances.
    X (numpy.ndarray or None): The feature matrix used for training.
    y (numpy.ndarray or None): The target labels used for training.
 
Methods:
    fit(X=None, y=None, verbose=False): Fits the random forest to the data.
    calculate_metrics(y_true, y_pred): Calculates the evaluation metrics.
    predict(X): Predicts the target values for the input features.
    get_stats(verbose=False): Returns the evaluation metrics.
 
  Methods defined here:
__init__(self, forest_size=100, max_depth=10, min_samples_split=2, n_jobs=-1, random_seed=None, X=None, y=None)
Initialize the Random Forest Regressor.
calculate_metrics(self, y_true, y_pred)
Calculate common regression metrics.
 
Args:
    y_true (array-like): True target values.
    y_pred (array-like): Predicted target values.
 
Returns:
    dict: A dictionary containing calculated metrics (MSE, R^2, MAE, RMSE, MAPE).
fit(self, X=None, y=None, sample_weight=None, verbose=False)
Fit the random forest to the training data X and y.
 
Args:
    X (array-like): Training input features of shape (n_samples, n_features).
    y (array-like): Training target values of shape (n_samples,).
    sample_weight (array-like): Sample weights for each instance in X.
    verbose (bool): Whether to print progress messages.
 
Returns:
    self: The fitted RandomForestRegressor instance.
get_params(self)
Get the parameters of the Random Forest Regressor.
 
Returns:
    dict: A dictionary containing the parameters of the model.
get_stats(self, y_true, y_pred, verbose=False)
Calculate and optionally print evaluation metrics.
 
Args:
    y_true (array-like): True target values.
    y_pred (array-like): Predicted target values.
    verbose (bool): Whether to print progress messages (e.g., residuals).
 
Returns:
    dict: A dictionary containing calculated metrics (MSE, R^2, MAE, RMSE, MAPE).
predict(self, X)
Predict target values for input features X using the trained random forest.
 
Args:
    X (array-like): Input features of shape (n_samples, n_features).
 
Returns:
    np.ndarray: Predicted target values of shape (n_samples,).

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class RandomOverSampler(builtins.object)
    RandomOverSampler(random_state=None)
 
Randomly over-sample the minority class by duplicating examples.
 
This technique helps to balance the class distribution by randomly duplicating samples from the minority class.
It is a simple yet effective method to address class imbalance in datasets.
 
Algorithm Steps:
    - Step 1: Identify the minority class and its samples.
    - Step 2: Calculate the number of samples needed to balance the class distribution.
    - Step 3: Randomly select samples from the minority class with replacement.
    - Step 4: Duplicate the selected samples to create a balanced dataset.
 
  Methods defined here:
__init__(self, random_state=None)
Initializes the RandomOverSampler with an optional random state.
fit_resample(self, X, y)
Resamples the dataset to balance the class distribution by duplicating minority class samples.
 
Args:
    X: (array-like) - Feature matrix.
    y: (array-like) - Target vector.
 
Returns:
    tuple: (np.ndarray, np.ndarray) - Resampled feature matrix and target vector.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class RandomSearchCV(builtins.object)
    RandomSearchCV(model, param_grid, iter=10, cv=5, metric='mse', direction='minimize')
 
Implements a random search cross-validation for hyperparameter tuning.
 
  Methods defined here:
__init__(self, model, param_grid, iter=10, cv=5, metric='mse', direction='minimize')
Initializes the RandomSearchCV object.
 
Args:
    model: The model Object to be tuned.
    param_grid: (list) - A list of dictionaries containing hyperparameters to be tuned.
    iter: (int) - The number of iterations for random search. Default is 10.
    cv: (int) - The number of folds for cross-validation. Default is 5.
    metric: (str) - The metric to be used for evaluation. Default is 'mse'.
        - Regression Metrics: 'mse', 'r2', 'mae', 'rmse', 'mape', 'mpe'
        - Classification Metrics: 'accuracy', 'precision', 'recall', 'f1', 'log_loss'
    direction: (str) - The direction to optimize the metric. Default is 'minimize'.
fit(self, X, y, verbose=False)
Fits the model to the data for iter random hyperparameter combinations.
 
Args:
    X: (numpy.ndarray) - The feature columns.
    y: (numpy.ndarray) - The label column.
    verbose: (bool) - A flag to display the training progress. Default is True.
 
Returns:
    model: The best model with the optimal hyperparameters.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class RandomUnderSampler(builtins.object)
    RandomUnderSampler(random_state=None)
 
Randomly under-sample the majority class by removing examples.
 
This technique helps to balance the class distribution by randomly removing samples from the majority class.
It is a simple yet effective method to address class imbalance in datasets.
 
Algorithm Steps:
    - Step 1: Identify the majority class and its samples.
    - Step 2: Calculate the number of samples to remove to balance the class distribution.
    - Step 3: Randomly select samples from the majority class without replacement.
    - Step 4: Remove the selected samples to create a balanced dataset.
 
  Methods defined here:
__init__(self, random_state=None)
Initializes the RandomUnderSampler with an optional random state.
fit_resample(self, X, y)
Resamples the dataset to balance the class distribution by removing majority class samples.
 
Args:
    X: (array-like) - Feature matrix.
    y: (array-like) - Target vector.
 
Returns:
    tuple: (np.ndarray, np.ndarray) - Resampled feature matrix and target vector.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class RegressionAnimation(AnimationBase)
    RegressionAnimation(model, X, y, test_size=0.3, dynamic_parameter=None, static_parameters=None, keep_previous=False, max_previous=None, pca_components=1, **kwargs)
 
Class for creating animations of regression models.
 
 
Method resolution order:
RegressionAnimation
AnimationBase
abc.ABC
builtins.object

Methods defined here:
__init__(self, model, X, y, test_size=0.3, dynamic_parameter=None, static_parameters=None, keep_previous=False, max_previous=None, pca_components=1, **kwargs)
Initialize the regression animation class.
 
Args:
    model: The regression model.
    X: Feature matrix (input data).
    y: Target vector (output data).
    test_size: Proportion of the dataset to include in the test split.
    dynamic_parameter: The parameter to update dynamically (e.g., 'alpha', 'beta').
    static_parameters: Additional static parameters for the model.
        Should be a dictionary with parameter names as keys and their values.
    keep_previous: Whether to keep all previous lines with reduced opacity.
    max_previous: Maximum number of previous lines to keep.
    pca_components: Number of components to use for PCA.
    **kwargs: Additional customization options (e.g., colors, line styles).
setup_plot(self, title, xlabel, ylabel, legend_loc='upper left', grid=True, figsize=(12, 6))
Set up the plot for regression animation.
update_model(self, frame)
Update the regression model for the current frame.
 
Args:
    frame: The current frame (e.g., parameter value).
update_plot(self, frame)
Update the plot for the current frame.
 
Args:
    frame: The current frame (e.g., parameter value).

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Methods inherited from AnimationBase:
animate(self, frames, interval=150, blit=True, repeat=False)
Create the animation.
 
Args:
    frames: Range of frames (e.g., window sizes).
    interval: Delay between frames in milliseconds.
    blit: Whether to use blitting for faster rendering.
    repeat: Whether to repeat the animation.
save(self, filename, writer='pillow', fps=5, dpi=100)
Save the animation to a file.
 
Args:
    filename: Path to save the animation.
    writer: Writer to use (e.g., 'pillow' for GIF).
    fps: Frames per second.
    dpi: Dots per inch for the saved figure.
show(self)
Display the animation.

Data descriptors inherited from AnimationBase:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class RegressorTree(builtins.object)
    RegressorTree(max_depth=5, min_samples_split=2)
 
A class representing a decision tree for regression.
 
Args:
    max_depth: (int) - The maximum depth of the decision tree.
    min_samples_split: (int) - The minimum number of samples required to split a node.
    n_features: (int) - The number of features in the dataset.
    X: (array-like) - The input features.
    y: (array-like) - The target labels.
 
Methods:
    fit(X, y, verbose=False): Fits the decision tree to the training data.
    predict(X): Predicts the target values for the input features.
    _traverse_tree(x, node): Traverses the decision tree for a single sample x.
    _leran_recursive(indices, depth): Recursive helper function for learning.
 
  Methods defined here:
__init__(self, max_depth=5, min_samples_split=2)
Initialize the decision tree.
 
Args:
    max_depth (int): The maximum depth of the decision tree.
    min_samples_split (int): The minimum number of samples required to split a node.
fit(self, X, y, sample_weight=None, verbose=False)
Fit the decision tree to the training data.
 
Args:
    X: (array-like) - The input features.
    y: (array-like) - The target labels.
    sample_weight: (array-like) - The sample weights (default: None).
    verbose: (bool) - If True, print detailed logs during fitting.
 
Returns:
    dict: The learned decision tree.
predict(self, X)
Predict the target value for a record or batch of records using the decision tree.
 
Args:
    X: (array-like) - The input features.
 
Returns:
    np.ndarray: The predicted target values.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class RegressorTreeUtility(builtins.object)
    RegressorTreeUtility(X, y, min_samples_split, n_features)
 
Utility class containing helper functions for building the Regressor Tree.
 
Handles variance calculation, leaf value calculation, and finding the best split.
 
  Methods defined here:
__init__(self, X, y, min_samples_split, n_features)
Initialize the utility class with references to data and parameters.
 
Args:
    X (np.ndarray): Reference to the feature data.
    y (np.ndarray): Reference to the target data.
    min_samples_split (int): Minimum number of samples required to split a node.
    n_features (int): Total number of features in X.
best_split(self, indices, sample_weight=None)
Finds the best split for the data subset defined by indices.
calculate_leaf_value(self, indices, sample_weight=None)
Calculate the weighted mean value for a leaf node.
calculate_variance(self, indices, sample_weight=None)
Calculate weighted variance for the subset defined by indices.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class Ridge(builtins.object)
    Ridge(alpha=1.0, fit_intercept=True, max_iter=10000, tol=0.0001, compile_numba=False)
 
Fits the Ridge Regression model to the training data.
 
Ridge regression implements L2 regularization, which helps to prevent overfitting by adding a penalty term to the loss function.
 
Args:
    alpha: (float) - Regularization strength; must be a positive float (default is 1.0).
    fit_intercept: (bool), optional - Whether to calculate the intercept for this model (default is True).
    max_iter: (int), optional - Maximum number of iterations for the coordinate descent solver (default is 10000).
    tol: (float), optional - Tolerance for the optimization. The optimization stops when the change in the coefficients is less than this tolerance (default is 1e-4).
 
Attributes:
    coef_: (np.ndarray) - Estimated coefficients for the linear regression problem. If `fit_intercept` is True, the first element is the intercept.
    intercept_: (float) - Independent term in the linear model. Set to 0.0 if `fit_intercept` is False.
 
Methods:
    fit(X, y): Fits the Ridge Regression model to the training data.
    predict(X): Predicts using the Ridge Regression model.
    get_formula(): Returns the formula of the model as a string.
 
  Methods defined here:
__init__(self, alpha=1.0, fit_intercept=True, max_iter=10000, tol=0.0001, compile_numba=False)
Initializes the Ridge Regression model.
 
Ridge regression implements L2 regularization, which helps to prevent overfitting by adding a penalty term to the loss function.
 
Args:
    alpha: (float) - Regularization strength; must be a positive float (default is 1.0).
    fit_intercept: (bool), optional - Whether to calculate the intercept for this model (default is True).
    max_iter: (int), optional - Maximum number of iterations for the coordinate descent solver (default is 10000).
    tol: (float), optional - Tolerance for the optimization. The optimization stops when the change in the coefficients is less than this tolerance (default is 1e-4).
    compile_numba: (bool), optional - Whether to precompile the numba functions (default is False). If True, the numba fitting functions will be compiled before use.
__str__(self)
Returns the string representation of the model.
fit(self, X, y, numba=False)
Fits the Ridge Regression model to the training data.
 
Args:
    X: (np.ndarray) - Training feature data of shape (n_samples, n_features).
    y: (np.ndarray) - Training target data of shape (n_samples,).
    numba: (bool), optional - Whether to use numba for faster computation (default is False).
 
Returns:
    self: (Ridge) - The fitted Ridge Regression model.
get_formula(self)
Computes the formula of the model.
 
Returns:
    formula: (str) - The formula of the model as a string.
predict(self, X)
Predicts the target values using the Ridge Regression model.
 
Args:
    X: (np.ndarray) - Feature data of shape (n_samples, n_features).
 
Returns:
    y_pred: (np.ndarray) - Predicted target values of shape (n_samples,).

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class SARIMA(ARIMA)
    SARIMA(order=(0, 0, 0), seasonal_order=(0, 0, 0, 1))
 
SARIMA model for time series forecasting.
 
SARIMA extends ARIMA by including seasonal components.
 
Attributes:
    order (tuple): The non-seasonal order of the ARIMA model (p, d, q).
    seasonal_order (tuple): The seasonal order of the SARIMA model (P, D, Q, m).
    p (int): The order of the Auto-Regressive (AR) component.
    d (int): The degree of differencing.
    q (int): The order of the Moving Average (MA) component.
    P (int): The order of the seasonal Auto-Regressive (SAR) component.
    D (int): The degree of seasonal differencing.
    Q (int): The order of the seasonal Moving Average (SMA) component.
    m (int): The number of time steps in a seasonal period.
 
 
Method resolution order:
SARIMA
ARIMA
builtins.object

Methods defined here:
__init__(self, order=(0, 0, 0), seasonal_order=(0, 0, 0, 1))
Initialize the SARIMA model.
 
Args:
    order (tuple): Non-seasonal ARIMA order (p, d, q).
    seasonal_order (tuple): Seasonal order (P, D, Q, m).
__str__(self)
Return str(self).
fit(self, time_series)
Fit the SARIMA model to the given time series data.
 
First fits the ARIMA model on the seasonally-differenced series.
Then, forecasts the seasonally-differenced series and inverts the seasonal differencing.
 
Args:
    time_series (array-like): The time series data to fit the model to.
forecast(self, steps)
Forecast future values using the fitted SARIMA model.
 
Args:
    steps (int): The number of steps to forecast.
 
Returns:
    array-like: The forecasted values.

Static methods defined here:
find_best_order(train_series, test_series, max_p=2, max_d=1, max_q=2, max_P=1, max_D=1, max_Q=1, max_m=100)
Find the best SARIMA order using grid search.
 
Args:
    train_series (array-like): The training time series data.
    test_series (array-like): The testing time series data.
    max_p, max_d, max_q: Maximum values for non-seasonal components.
    max_P, max_D, max_Q, max_m: Maximum values for seasonal components.
 
Returns:
    tuple: The best orders as ((p,d,q), (P,D,Q,m)).
suggest_order(time_series, max_p=3, max_d=2, max_q=3, max_P=2, max_D=1, max_Q=2, max_m=100)
Suggest the optimal SARIMA order for the given time series.
 
Args:
    time_series (array-like): The time series data.
    max_p (int): Maximum order for AR component.
    max_d (int): Maximum degree of differencing.
    max_q (int): Maximum order for MA component.
    max_P (int): Maximum order for seasonal AR component.
    max_D (int): Maximum degree of seasonal differencing.
    max_Q (int): Maximum order for seasonal MA component.
    max_m (int): Maximum seasonal period to consider.
 
Returns:
    tuple: The optimal orders (p, d, q, P, D, Q, m).

Data descriptors inherited from ARIMA:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class SARIMAX(SARIMA)
    SARIMAX(order=(0, 0, 0), seasonal_order=(0, 0, 0, 1))
 
SARIMAX model with exogenous regressors.
 
SARIMAX takes the same time_series input as SARIMA, but also allows for exogenous regressors.
These are additional variables that can help explain the time series.
 
Two-step approach:
  1. OLS regression of y on exog to get beta + residuals
    - beta = (X'X)^-1 X'y
    - resid = y - X @ beta
  2. SARIMA fit on the residuals of the OLS regression
 
Forecast = SARIMA_forecast(resid) + exog_future @ beta
 
Attributes:
    beta (np.ndarray): The beta coefficients.
    k_exog (int): The number of exogenous variables.
 
 
Method resolution order:
SARIMAX
SARIMA
ARIMA
builtins.object

Methods defined here:
__init__(self, order=(0, 0, 0), seasonal_order=(0, 0, 0, 1))
Initialize the SARIMAX model.
 
Args:
    order (tuple): Non-seasonal ARIMA order (p, d, q).
    seasonal_order (tuple): Seasonal order (P, D, Q, m).
__str__(self)
Return str(self).
fit(self, time_series, exog, bound_lower=None, bound_upper=None)
Fit the SARIMAX model to the given time series and exogenous regressors.
 
Args:
    time_series (array-like): The time series data.
    exog (array-like): The exogenous regressors.
    bound_lower (float): Lower bound for beta coefficients.
    bound_upper (float): Upper bound for beta coefficients.
 
Returns:
    self: The fitted SARIMAX model.
forecast(self, steps, exog_future)
Forecast future values using the fitted SARIMAX model.
 
Args:
    steps (int): The number of steps to forecast.
    exog_future (array-like): The exogenous regressors for the future values.
 
Returns:
    array-like: The forecasted values.

Static methods defined here:
find_best_order(train_endog, test_endog, train_exog, test_exog, max_p=2, max_d=1, max_q=2, max_P=1, max_D=1, max_Q=1, max_m=100)
Grid-search over ((p,d,q),(P,D,Q,m)) to minimize MSE on test set.
 
Args:
    train_endog (array-like): The training endogenous variable.
    test_endog (array-like): The testing endogenous variable.
    train_exog (array-like): The training exogenous regressors.
    test_exog (array-like): The testing exogenous regressors.
    max_p, max_d, max_q: Maximum values for non-seasonal components.
    max_P, max_D, max_Q, max_m: Maximum values for seasonal components.
 
Returns:
    tuple: The best orders ((p,d,q),(P,D,Q,m)).
suggest_order(endog, exog, max_p=3, max_d=2, max_q=3, max_P=2, max_D=1, max_Q=2, max_m=100)
Suggest ((p,d,q),(P,D,Q,m)) for SARIMAX.
 
Regress endog on exog to get residuals, then call SARIMA.suggest_order on residuals.
 
Args:
    endog (array-like): The endogenous variable.
    exog (array-like): The exogenous regressors.
    max_p, max_d, max_q: Maximum values for non-seasonal components.
    max_P, max_D, max_Q, max_m: Maximum values for seasonal components.
 
Returns:
    tuple: The optimal orders (p, d, q, P, D, Q, m).

Data descriptors inherited from ARIMA:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class SGDOptimizer(builtins.object)
    SGDOptimizer(learning_rate=0.001, momentum=0.0, reg_lambda=0.0)
 
Stochastic Gradient Descent (SGD) optimizer class for training neural networks.
 
Formula: w = w - learning_rate * dW, b = b - learning_rate * db
 
Args:
    learning_rate (float, optional): The learning rate for the optimizer. Defaults to 0.001.
    momentum (float, optional): The momentum factor. Defaults to 0.0.
    reg_lambda (float, optional): The regularization parameter. Defaults to 0.0.
 
  Methods defined here:
__init__(self, learning_rate=0.001, momentum=0.0, reg_lambda=0.0)
Initializes the optimizer with specified parameters.
 
Args:
    learning_rate (float, optional): The step size for updating weights. Defaults to 0.001.
    momentum (float, optional): The momentum factor to accelerate gradient descent. Defaults to 0.0.
    reg_lambda (float, optional): The regularization parameter to prevent overfitting. Defaults to 0.0.
initialize(self, layers)
Initializes the velocity for each layer's weights.
 
Args:
    layers (list): List of layers in the neural network.
 
Returns:
    None
update(self, layer, dW, db, index)
Updates the weights and biases of a layer using the SGD optimization algorithm.
 
Args:
    layer (Layer): The layer to update.
    dW (ndarray): The gradient of the weights.
    db (ndarray): The gradient of the biases.
    index (int): The index of the layer.
 
Returns:
    None

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class SMOTE(builtins.object)
    SMOTE(random_state=None, k_neighbors=5)
 
Synthetic Minority Over-sampling Technique (SMOTE) for balancing class distribution.
 
SMOTE generates synthetic samples for the minority class by interpolating between existing samples.
This helps to create a more balanced dataset, which can improve the performance of machine learning models.
 
Algorithm Steps:
    - Step 1: Identify the minority class and its samples.
    - Step 2: For each sample in the minority class, find its k nearest neighbors (using Euclidean distance.)
    - Step 3: Randomly select one or more of these neighbors.
    - Step 4: Create synthetic samples by interpolating between the original sample and the selected neighbors.
 
  Methods defined here:
__init__(self, random_state=None, k_neighbors=5)
Initializes the SMOTE with an optional random state and number of neighbors.
fit_resample(self, X, y, force_equal=False)
Resamples the dataset to balance the class distribution by generating synthetic samples.
 
Args:
    X: (array-like) - Feature matrix.
    y: (array-like) - Target vector.
    force_equal: (bool), optional - If True, resample until classes are equal (default is False).
 
Returns:
    tuple: (np.ndarray, np.ndarray) - Resampled feature matrix and target vector.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class SVD(builtins.object)
    SVD(n_components)
 
Singular Value Decomposition (SVD) implementation.
 
  Methods defined here:
__init__(self, n_components)
Initializes the SVD model.
 
Args:
    n_components: (int) - Number of singular values and vectors to keep.
fit(self, X)
Fits the SVD model to the data.
 
Args:
    X: (np.ndarray) - Input data of shape (n_samples, n_features).
 
Raises:
    ValueError: If input data is not a 2D numpy array or if n_components exceeds the minimum dimension of the input data.
fit_transform(self, X)
Fits the SVD model and applies the transformation on the input data.
 
Args:
    X: (np.ndarray) - Input data of shape (n_samples, n_features).
 
Returns:
    X_transformed: (np.ndarray) - Data transformed into the singular value space of shape (n_samples, n_components).
get_singular_values(self)
Retrieves the singular values.
 
Returns:
    S: (np.ndarray) - Array of singular values of shape (n_components,).
get_singular_vectors(self)
Retrieves the singular vectors.
 
Returns:
    U: (np.ndarray) - Left singular vectors of shape (n_samples, n_components).
    Vt: (np.ndarray) - Right singular vectors of shape (n_components, n_features).
transform(self, X)
Applies the SVD transformation on the input data.
 
Args:
    X: (np.ndarray) - Input data of shape (n_samples, n_features).
 
Returns:
    X_transformed: (np.ndarray) - Data transformed into the singular value space of shape (n_samples, n_components).
 
Raises:
    ValueError: If input data is not a 2D numpy array.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class Scaler(builtins.object)
    Scaler(method='standard')
 
A class for scaling data by standardization and normalization.
 
  Methods defined here:
__init__(self, method='standard')
Initializes the scaler with the specified method.
 
Args:
    method: (str) - The scaling method to use. Options are 'standard', 'minmax', or 'normalize'.
fit(self, X)
Fits the scaler to the data.
 
Args:
    X: (numpy.ndarray) - The data to fit the scaler to.
fit_transform(self, X)
Fits the scaler to the data and then transforms it.
 
Args:
    X: (numpy.ndarray) - The data to fit and transform.
 
Returns:
    X_transformed: (numpy.ndarray) - The transformed data.
inverse_transform(self, X)
Inverse transforms the data using the fitted scaler.
 
Args:
    X: (numpy.ndarray) - The data to inverse transform.
 
Returns:
    X_inverse: (numpy.ndarray) - The inverse transformed data.
transform(self, X)
Transforms the data using the fitted scaler.
 
Args:
    X: (numpy.ndarray) - The data to transform.
 
Returns:
    X_transformed: (numpy.ndarray) - The transformed data.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class SimpleExponentialSmoothing(builtins.object)
    SimpleExponentialSmoothing(alpha)
 
Simple Exponential Smoothing (SES) for non-seasonal time series without trend.
 
Forecasts are based on a weighted average of past observations, with weights decreasing exponentially over time.
Forecast is a flat line, this is because SES does not account for trend or seasonality.
 
Attributes:
    alpha (float): Smoothing parameter for the level (0 <= alpha <= 1).
    level (float): The final estimated level component after fitting.
    fitted_values (np.ndarray): The fitted values (one-step-ahead forecasts).
    model (np.ndarray): The original time series data.
 
  Methods defined here:
__init__(self, alpha)
Initialize SES model.
 
Args:
    alpha (float): Smoothing parameter for the level. Must be between 0 and 1.
__str__(self)
Return str(self).
fit(self, time_series)
Fit the SES model to the data.
 
Args:
    time_series (array-like): The time series data (1-dimensional).
 
Returns:
    np.ndarray: The fitted values (one-step-ahead forecasts).
forecast(self, steps)
Generate forecasts for future steps.
 
Args:
    steps (int): The number of steps to forecast ahead.
 
Returns:
    np.ndarray: An array of forecasted values.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class SimpleMovingAverage(builtins.object)
    SimpleMovingAverage(window)
 
Calculates the Simple Moving Average (SMA) of a time series.
 
SMA smooths out fluctuations by averaging data over a defined window.
 
Attributes:
    window (int): The number of periods in the moving average window.
    smoothed_values (np.ndarray): The calculated SMA values. NaNs prepended.
    model (np.ndarray): The original time series data.
 
  Methods defined here:
__init__(self, window)
Initialize SMA calculator.
 
Args:
    window (int): The size of the moving window. Must be > 0.
__str__(self)
Return str(self).
fit(self, time_series)
Calculate the Simple Moving Average for the series.
 
Args:
    time_series (array-like): The time series data (1-dimensional).
forecast(self, steps)
Generate forecasts using the last calculated moving average value.
 
Note: This is a naive forecast where the future is predicted to be the
last known smoothed value.
 
Args:
    steps (int): The number of steps to forecast ahead.
 
Returns:
    np.ndarray: An array of forecasted values (all the same).
get_smoothed(self)
Return the calculated moving average series.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class TripleExponentialSmoothing(builtins.object)
    TripleExponentialSmoothing(alpha, beta, gamma, period)
 
Triple Exponential Smoothing (TES) / Holt-Winters Method (Additive Seasonality).
 
Extends DES to handle time series with both trend and seasonality (additive).
 
Attributes:
    alpha (float): Smoothing parameter for the level (0 <= alpha <= 1).
    beta (float): Smoothing parameter for the trend (0 <= beta <= 1).
    gamma (float): Smoothing parameter for seasonality (0 <= gamma <= 1).
    period (int): The seasonal period (must be > 1).
    level (float): The final estimated level component after fitting.
    trend (float): The final estimated trend component after fitting.
    season (np.ndarray): The final estimated seasonal components (length `period`).
    fitted_values (np.ndarray): The one-step-ahead forecasts made during fitting.
    model (np.ndarray): The original time series data.
 
  Methods defined here:
__init__(self, alpha, beta, gamma, period)
Initialize TES model (Additive Seasonality).
 
Args:
    alpha (float): Smoothing parameter for the level (0 <= alpha <= 1).
    beta (float): Smoothing parameter for the trend (0 <= beta <= 1).
    gamma (float): Smoothing parameter for seasonality (0 <= gamma <= 1).
    period (int): The seasonal period (e.g., 12 for monthly). Must be > 1.
__str__(self)
Return str(self).
find_best_alpha_beta_gamma(self, train_series, test_series, alpha_values=None, beta_values=None, gamma_values=None, set_best=False)
Find the best alpha, beta, and gamma values for the TES model.
 
Args:
    train_series (array-like): The training time series data (1-dimensional).
    test_series (array-like): The testing time series data (1-dimensional).
    alpha_values (list, optional): List of alpha values to evaluate. Defaults to [0.1, 0.2, ..., 0.9].
    beta_values (list, optional): List of beta values to evaluate. Defaults to [0.1, 0.2, ..., 0.9].
    gamma_values (list, optional): List of gamma values to evaluate. Defaults to [0.1, 0.2, ..., 0.9].
    set_best (bool, optional): If True, set the best alpha, beta, and gamma values to the model. Defaults to False.
 
Returns:
    tuple: Best alpha, beta, and gamma values based on mean squared error.
fit(self, time_series)
Fit the TES model (additive seasonality) to the data.
 
Args:
    time_series (array-like): The time series data (1-dimensional).
                              Length should be >= 2 * period.
 
Returns:
    np.ndarray: The fitted values for the time series.
forecast(self, steps)
Generate forecasts for future steps (Additive Seasonality).
 
Args:
    steps (int): The number of steps to forecast ahead.
 
Returns:
    np.ndarray: An array of forecasted values.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class VotingClassifier(builtins.object)
    VotingClassifier(estimators, weights=None)
 
Implements a hard voting classifier.
 
Aggregates predictions from multiple fitted classification models based on
majority vote (optionally weighted).
 
  Methods defined here:
__init__(self, estimators, weights=None)
Initialize the VotingClassifier object for hard voting.
 
Args:
    estimators (list): A list of *fitted* classifier objects.
                       Each estimator must have a `predict` method.
    weights (array-like of shape (n_estimators,), optional): Sequence of
        weights (float or int) to weight the occurrences of predicted class
        labels during voting. Uses uniform weights if None. Defaults to None.
get_params(self, deep=True)
Get parameters for this estimator.
 
Args:
    deep (bool, optional): If True, will return the parameters for this
        estimator and contained subobjects that are estimators. (Not fully implemented for deep=True yet).
 
Returns:
    params (dict): Parameter names mapped to their values.
predict(self, X)
Predict class labels for X using hard voting.
 
Args:
    X (array-like of shape (n_samples, n_features)): The input samples.
 
Returns:
    maj (np.ndarray of shape (n_samples,)): Predicted class labels based on majority vote.
show_models(self)
Print the models and their weights.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class VotingRegressor(builtins.object)
    VotingRegressor(models, model_weights=None)
 
Implements a voting regressor.
 
Takes a list of fitted models and their weights and returns a weighted average of the predictions.
 
  Methods defined here:
__init__(self, models, model_weights=None)
Initialize the VotingRegressor object.
 
Args:
    models: list of models to be stacked
    model_weights: list of weights for each model. Default is None.
get_params(self)
Get the parameters of the VotingRegressor object.
 
Returns:
    params: dictionary of parameters
predict(self, X)
Predict the target variable using the fitted models.
 
Args:
    X: input features
 
Returns:
    y_pred: predicted target variable
show_models(self, formula=False)
Print the models and their weights.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class WeightedMovingAverage(builtins.object)
    WeightedMovingAverage(window, weights=None)
 
Calculates the Weighted Moving Average (WMA) of a time series.
 
WMA assigns different weights to data points within the window, typically giving
more importance to recent observations.
 
Attributes:
    window (int): The number of periods in the moving average window.
    weights (np.ndarray): The weights assigned to observations in the window.
    smoothed_values (np.ndarray): The calculated WMA values. NaNs prepended.
    model (np.ndarray): The original time series data.
 
  Methods defined here:
__init__(self, window, weights=None)
Initialize WMA calculator.
 
Args:
    window (int): The size of the moving window. Must be > 0.
    weights (array-like, optional): A sequence of weights for the window.
        Length must match `window`. If None, linear weights giving more
        importance to recent points are used (e.g., [1, 2, 3] for window=3).
        Weights are normalized to sum to 1.
__str__(self)
Return str(self).
fit(self, time_series)
Calculate the Weighted Moving Average for the series.
 
Args:
    time_series (array-like): The time series data (1-dimensional).
forecast(self, steps)
Generate forecasts using the last calculated weighted moving average value.
 
Note: This is a naive forecast.
 
Args:
    steps (int): The number of steps to forecast ahead.
 
Returns:
    np.ndarray: An array of forecasted values (all the same).
get_smoothed(self)
Return the calculated moving average series.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class lr_scheduler_exp(builtins.object)
    lr_scheduler_exp(optimizer, lr_decay=0.1, lr_decay_epoch=10)
 
Learning rate scheduler class for training neural networks.
 
Reduces the learning rate exponentially by lr_decay every lr_decay_epoch epochs.
 
  Methods defined here:
__init__(self, optimizer, lr_decay=0.1, lr_decay_epoch=10)
Initializes the scheduler with the given optimizer and learning rate decay parameters.
 
Args:
    optimizer (Optimizer): The optimizer whose learning rate will be scheduled.
    lr_decay (float, optional): The factor by which the learning rate will be multiplied at each decay step. Default is 0.1.
    lr_decay_epoch (int, optional): The number of epochs after which the learning rate will be decayed. Default is 10.
__repr__(self)
Returns a string representation of the scheduler.
reduce(self)
Reduces the learning rate exponentially.
step(self, epoch)
Adjusts the learning rate based on the current epoch. Decays the learning rate by lr_decay every lr_decay_epoch epochs.
 
Args:
    epoch (int): The current epoch number.
Returns: None

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class lr_scheduler_plateau(builtins.object)
    lr_scheduler_plateau(lr_scheduler, patience=5, threshold=0.01)
 
A custom learning rate scheduler that adjusts the learning rate based on the plateau of the loss function.
 
Args:
    lr_scheduler (object): The learning rate scheduler object.
    patience (int): The number of epochs to wait for improvement before reducing the learning rate. Default is 5.
    threshold (float): The minimum improvement threshold required to update the best loss. Default is 0.01.
 
Methods:
    step(loss): Updates the learning rate based on the loss value.
 
  Methods defined here:
__init__(self, lr_scheduler, patience=5, threshold=0.01)
Initializes the scheduler with the given learning rate scheduler, patience, and threshold.
 
Args:
    lr_scheduler (torch.optim.lr_scheduler): The learning rate scheduler to be used.
    patience (int, optional): Number of epochs to wait for improvement before taking action. Defaults to 5.
    threshold (float, optional): Minimum change in the monitored value to qualify as an improvement. Defaults to 0.01.
__repr__(self)
Returns a string representation of the scheduler.
step(self, epoch, loss)
Updates the learning rate based on the loss value.
 
Args:
    epoch (int): The current epoch number.
    loss (float): The current loss value.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class lr_scheduler_step(builtins.object)
    lr_scheduler_step(optimizer, lr_decay=0.1, lr_decay_epoch=10)
 
Learning rate scheduler class for training neural networks.
 
Reduces the learning rate by a factor of lr_decay every lr_decay_epoch epochs.
 
Args:
    optimizer (Optimizer): The optimizer to adjust the learning rate for.
    lr_decay (float, optional): The factor to reduce the learning rate by. Defaults to 0.1.
    lr_decay_epoch (int, optional): The number of epochs to wait before decaying the learning rate. Defaults to 10
 
  Methods defined here:
__init__(self, optimizer, lr_decay=0.1, lr_decay_epoch=10)
Initializes the scheduler with the given optimizer and learning rate decay parameters.
 
Args:
    optimizer (Optimizer): The optimizer whose learning rate will be scheduled.
    lr_decay (float, optional): The factor by which the learning rate will be multiplied at each decay step. Default is 0.1.
    lr_decay_epoch (int, optional): The number of epochs after which the learning rate will be decayed. Default is 10.
__repr__(self)
Returns a string representation of the scheduler.
reduce(self)
Reduces the learning rate by the decay factor.
step(self, epoch)
Adjusts the learning rate based on the current epoch. Decays the learning rate by lr_decay every lr_decay_epoch epochs.
 
Args:
    epoch (int): The current epoch number.
 
Returns:
    None

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
Functions
       
make_blobs(n_samples=100, n_features=2, centers=None, cluster_std=1.0, center_box=(-10.0, 10.0), shuffle=True, random_state=None)
Generates isotropic Gaussian blobs for clustering.
 
Args:
    n_samples (int or array-like, optional): Total number of samples if int, or number of samples per cluster if array-like (default is 100).
    n_features (int, optional): Number of features (default is 2).
    centers (int or array-like, optional): Number of centers to generate, or fixed center locations. If None, 3 centers are generated (default is None).
    cluster_std (float or array-like, optional): Standard deviation of the clusters (default is 1.0).
    center_box (tuple of float, optional): Bounding box for each cluster center when centers are generated at random (default is (-10.0, 10.0)).
    shuffle (bool, optional): Whether to shuffle the samples (default is True).
    random_state (int or None, optional): Random seed (default is None).
 
Returns:
    X (np.ndarray): Generated samples of shape (n_samples, n_features).
    y (np.ndarray): Integer labels for cluster membership of each sample of shape (n_samples,).
    centers (np.ndarray): Centers of each cluster of shape (n_centers, n_features).
make_classification(n_samples=100, n_features=20, n_informative=2, n_redundant=2, n_repeated=0, n_classes=2, n_clusters_per_class=2, weights=None, flip_y=0.01, class_sep=1.0, hypercube=True, shift=0.0, scale=1.0, shuffle=True, random_state=None)
Generates a random n-class classification problem.
 
Args:
    n_samples (int, optional): Number of samples (default is 100).
    n_features (int, optional): Total number of features (default is 20).
    n_informative (int, optional): Number of informative features (default is 2).
    n_redundant (int, optional): Number of redundant features (default is 2).
    n_repeated (int, optional): Number of duplicated features (default is 0).
    n_classes (int, optional): Number of classes (default is 2).
    n_clusters_per_class (int, optional): Number of clusters per class (default is 2).
    weights (array-like, optional): Proportions of samples assigned to each class (default is None).
    flip_y (float, optional): Fraction of samples whose class is randomly exchanged (default is 0.01).
    class_sep (float, optional): Factor multiplying the hypercube size (default is 1.0).
    hypercube (bool, optional): If True, clusters are placed on the vertices of a hypercube (default is True).
    shift (float, optional): Shift features by the specified value (default is 0.0).
    scale (float, optional): Multiply features by the specified value (default is 1.0).
    shuffle (bool, optional): Shuffle the samples and features (default is True).
    random_state (int or None, optional): Random seed (default is None).
 
Returns:
    X (np.ndarray): Generated samples of shape (n_samples, n_features).
    y (np.ndarray): Integer labels for class membership of each sample of shape (n_samples,).
make_regression(n_samples=100, n_features=100, n_informative=10, n_targets=1, bias=0.0, effective_rank=None, tail_strength=0.5, noise=0.0, shuffle=True, coef=False, random_state=None)
Generates a random regression problem.
 
Args:
    n_samples (int, optional): Number of samples (default is 100).
    n_features (int, optional): Number of features (default is 100).
    n_informative (int, optional): Number of informative features used to build the linear model (default is 10).
    n_targets (int, optional): Number of regression targets (default is 1).
    bias (float, optional): Bias term in the underlying linear model (default is 0.0).
    effective_rank (int or None, optional): Approximate dimension of the data matrix (default is None).
    tail_strength (float, optional): Relative importance of the noisy tail of the singular values profile (default is 0.5).
    noise (float, optional): Standard deviation of the Gaussian noise applied to the output (default is 0.0).
    shuffle (bool, optional): Whether to shuffle the samples and features (default is True).
    coef (bool, optional): If True, returns the coefficients of the underlying linear model (default is False).
    random_state (int or None, optional): Random seed (default is None).
 
Returns:
    X (np.ndarray): Input samples of shape (n_samples, n_features).
    y (np.ndarray): Output values of shape (n_samples,) or (n_samples, n_targets).
    coef (np.ndarray, optional): Coefficients of the underlying linear model of shape (n_features,) or (n_features, n_targets). Only returned if coef=True.
make_sample_data(n_samples, n_features, cov_class_1, cov_class_2, shift=None, seed=0)
Generates sample data for testing LDA and QDA models.
 
Args:
    n_samples: (int) - Number of samples per class.
    n_features: (int) - Number of features.
    cov_class_1: (np.ndarray) - Covariance matrix for class 1.
    cov_class_2: (np.ndarray) - Covariance matrix for class 2.
    shift: (list), optional - Shift applied to class 2 data (default is [1, 1]).
    seed: (int), optional - Random seed for reproducibility (default is 0).
 
Returns:
    X: (np.ndarray) - Generated feature data.
    y: (np.ndarray) - Generated target labels.
make_time_series(n_samples=100, n_timestamps=50, n_features=1, trend='linear', seasonality='sine', seasonality_period=None, noise=0.1, random_state=None)
Generates synthetic time series data.
 
Args:
    n_samples (int, optional): Number of time series samples (default is 100).
    n_timestamps (int, optional): Number of timestamps per sample (default is 50).
    n_features (int, optional): Number of features per timestamp (default is 1).
    trend (str, optional): Type of trend ('linear', 'quadratic', or None) (default is 'linear').
    seasonality (str, optional): Type of seasonality ('sine', 'cosine', or None) (default is 'sine').
    seasonality_period (int, optional): Period of the seasonality (default is None, which uses the length of the time series/2).
    noise (float, optional): Standard deviation of Gaussian noise (default is 0.1).
    random_state (int or None, optional): Random seed (default is None).
 
Returns:
    X (np.ndarray): Time series data of shape (n_samples, n_timestamps, n_features).
normalize(X, norm='l2')
Normalizes the input data using the specified norm.
 
Args:
    X: (numpy.ndarray) - The input data to be normalized.
    norm: (str), optional - The type of norm to use for normalization (default is 'l2').
        Options:
            - 'l2': L2 normalization (Euclidean norm).
            - 'l1': L1 normalization (Manhattan norm).
            - 'max': Max normalization (divides by the maximum absolute value).
            - 'minmax': Min-max normalization (scales to [0, 1]).
 
Returns:
    X: (numpy.ndarray) - The normalized data.
one_hot_encode(y, num_classes)
One-hot encode a vector of class labels.
train_test_split(*arrays, test_size=None, train_size=None, random_state=None, shuffle=True, stratify=None)
Split arrays or matrices into random train and test subsets.
 
Parameters
----------
*arrays : sequence of arrays
    Allowed inputs are lists, numpy arrays, scipy-sparse matrices or pandas DataFrames.
 
test_size : float or int, default=None
    If float, should be between 0.0 and 1.0 and represent the proportion
    of the dataset to include in the test split. If int, represents the
    absolute number of test samples.
 
train_size : float or int, default=None
    If float, should be between 0.0 and 1.0 and represent the
    proportion of the dataset to include in the train split. If int,
    represents the absolute number of train samples. If None, the value is
    automatically computed as the complement of the test size (unless both
    are None, in which case test_size defaults to 0.25).
 
random_state : int, RandomState instance or None, default=None
    Controls the shuffling applied to the data before applying the split.
    Pass an int for reproducible output across multiple function calls.
 
shuffle : bool, default=True
    Whether or not to shuffle the data before splitting. If shuffle=False
    then stratify must be None.
 
stratify : array-like, default=None
    If not None, data is split in a stratified fashion, using this as
    the class labels.
 
Returns:
-------
splitting : list, length=2 * len(arrays)
    List containing train-test split of inputs.

 
Data
        __all__ = ['AnimationBase', 'RegressionAnimation', 'ForcastingAnimation', 'ClassificationAnimation', 'PolynomialTransform', 'DataPrep', 'VotingRegressor', 'VotingClassifier', 'ForecastRegressor', 'ModelSelectionUtility', 'GridSearchCV', 'RandomSearchCV', 'Metrics', 'PCA', 'SVD', 'RandomOverSampler', 'RandomUnderSampler', 'SMOTE', 'Augmenter', 'make_blobs', ...]