regressor_project documentation

Add your content using reStructuredText syntax. See the reStructuredText documentation for details.

API Reference

class regressor.BaseRegressor(alpha: float = 0.01, n_iterations: int = 1000, lambda_: float = 0)[source]

Bases: ABC

Base regressor model with regularization.

w

Shape(n,). A 1D array of model weights, corresponding to each feature.

Type:

numpy.ndarray | None

b

The model bias.

Type:

float

J_history

A list of costs for each iteration.

Type:

list

J_history: list
b: float
fit(X: ndarray, y: ndarray) None[source]

Complete batch gradient descent learning algorithm and update parameters w and b.

Parameters:
  • X – Shape(m,n). A 2D array of training features, where ‘m’ is the number of training examples and ‘n’ is the number of features.

  • y – Shape(m,). A 1D array of target values.

property is_fitted

Returns True if the model weights have been trained.

abstract predict(X: ndarray) ndarray[source]

Calculate predictions from the regressor model.

Parameters:

X – Shape(m,n). A 2D array of training features, where ‘m’ is the number of training examples and ‘n’ is the number of features.

Returns:

Shape(m,). A 1D array of predicted values from the model.

Return type:

pred

w: ndarray | None
class regressor.LinearRegressor(alpha: float = 0.01, n_iterations: int = 1000, lambda_: float = 0)[source]

Bases: BaseRegressor

Linear regressor, using mean least squares cost and regularization.

w

Shape(n,). A 1D array of model weights, corresponding to each feature.

Type:

numpy.ndarray | None

b

The model bias.

Type:

float

J_history

A list of costs for each iteration.

Type:

list

predict(X: ndarray) ndarray[source]

Calculate predictions from the regressor model.

Parameters:

X – Shape(m,n). A 2D array of training features, where ‘m’ is the number of training examples and ‘n’ is the number of features.

Returns:

Shape(m,). A 1D array of predicted values from the model.

Return type:

pred

class regressor.LogisticRegressor(alpha: float = 0.01, n_iterations: int = 1000, lambda_: float = 0, threshold: float = 0.5)[source]

Bases: BaseRegressor

Logistic regressor for binary classification, using log loss cost and regularization.

w

Shape(n,). A 1D array of model weights, corresponding to each feature.

Type:

numpy.ndarray | None

b

The model bias.

Type:

float

J_history

A list of costs for each iteration.

Type:

list

predict(X: ndarray) ndarray[source]

Calculate predictions from the regressor model.

Parameters:

X – Shape(m,n). A 2D array of training features, where ‘m’ is the number of training examples and ‘n’ is the number of features.

Returns:

Shape(m,). A 1D array of predicted values from the model.

Return type:

pred

threshold: float