Zero Inflated Regressor#
- class abil.zir.ZeroInflatedRegressor(classifier, regressor, threshold=0.5)#
A custom regressor to handle zero-inflated target variables.
Combines a classifier to predict non-zero occurrences and a regressor for non-zero targets.
- fit(X, y, sample_weight=None)#
Fit the model.
- Parameters:
X (np.ndarray of shape (n_samples, n_features)) – The training data.
y (np.ndarray, 1-dimensional) – The target values.
sample_weight (Optional[np.array], default=None) – Individual weights for each sample.
- Returns:
Fitted regressor.
- Return type:
- Raises:
ValueError – If classifier is not a classifier or regressor is not a regressor.
- predict(X)#
Get predictions.
- Parameters:
X (np.ndarray, shape (n_samples, n_features)) – Samples to get predictions of.
- Returns:
y – The predicted values.
- Return type:
np.ndarray, shape (n_samples,)