Optimizers

class derrom.optimizers.base_optimizer[source]

Bases: object

Base class to define the methods, which are to implemented

solve()[source]
class derrom.optimizers.lstsqrs[source]

Bases: base_optimizer

Least squares optimizer.

This optimizer pipes the training data to numpy.linalg.lstsq. This can be understood as the most simple optimizer. Use with strong caution because no regularization is applied, which poses the risk of overfitting and bad out-of-sample predictions

solve(feature_matrix, target_matrix)[source]

Solver, which is invoked by derrom’s fit method.

Parameters:

feature_matrix2D numpy.ndarray

Feature matrix with the feature vectors stored in the rows. The feature matrix is automatically generated by derrom’s fit method

target_matrix2D numpy.ndarray

Target matrix with the target vectors stored in the rows. The target matrix is automatically generated by derrom’s fit method

class derrom.optimizers.ridge(alpha=1e-06)[source]

Bases: base_optimizer

Regularized least squares optimizer. Rigde regression.

This optimizer applies L2/Thikonov regularization to the regression weights. This approach counters overfitting and helps to improve out-of-sample predictions. It can be understood as sacrificing the models specificity to improve its ability to generalize. A balance between these two, i.e., an optimal alpha must be found to optimize the regression performance.

Parameters:

alphafloat

Regularization parameter. Larger values impose a stronger regularization. alpha = 0 eliminates the regularization und yields the least-squares estimator.

solve(feature_matrix, target_matrix)[source]

Solver, which is invoked by derrom’s fit method.

Parameters:

feature_matrix2D numpy.ndarray

Feature matrix with the feature vectors stored in the rows. The feature matrix is automatically generated by derrom’s fit method

target_matrix2D numpy.ndarray

Target matrix with the target vectors stored in the rows. The target matrix is automatically generated by derrom’s fit method