seldonian.models.sklearn_model.SupervisedSkLearnBaseModel¶
- class SupervisedSkLearnBaseModel(**kwargs)¶
Bases:
SupervisedModel
- __init__(**kwargs)¶
Base class for Supervised learning Seldonian models implemented in scikit-learn
- __repr__()¶
Return repr(self).
Methods
- backward_pass(predictions, external_grad)¶
Do a backward pass through the model and return the (vector) gradient of the model with respect to theta as a numpy ndarray
- create_model(**kwargs)¶
Create the sklearn model and return it
- forward_pass(X, **kwargs)¶
Do a forward pass through the Sklearn model and return the model outputs (predicted labels or probabilities, depending on the model). Here, a forward pass is just a call to self.sklearn_model.predict()
- Parameters:
X (numpy ndarray) – model features
- Returns:
predictions
- Return type:
numpy ndarray
- get_model_params(*args)¶
Return weights of the model as a flattened 1D array
- predict(theta, X, **kwargs)¶
Do a forward pass through the sklearn model. Must convert back to numpy array before returning
- Parameters:
theta (numpy ndarray) – model weights
X (numpy ndarray) – model features
- Returns:
model predictions
- Return type:
numpy ndarray same shape as labels
- update_model_params(theta, **kwargs)¶
Update all model parameters using theta, which must be reshaped
- Parameters:
theta (numpy ndarray) – model weights