Release 12 (from main)
This commit is contained in:
@@ -73,6 +73,15 @@ class LinearRegressionModel(BaseEstimator, TransformerMixin):
|
||||
+ ', '.join(missing_model_features)
|
||||
)
|
||||
|
||||
def _apply_clipping(self, predictions: np.ndarray) -> None:
|
||||
"""Replace in place predictions above max with Q3 and below min with Q1."""
|
||||
for i in range(len(predictions)):
|
||||
# Each limit is optional on its own (SIENTIAPDE-2219)
|
||||
if 'max' in self.clipping and predictions[i] > self.clipping['max']:
|
||||
predictions[i] = self.q3_target
|
||||
elif 'min' in self.clipping and predictions[i] < self.clipping['min']:
|
||||
predictions[i] = self.q1_target
|
||||
|
||||
def create_poly_features(self, input_data: pd.DataFrame, fit: bool = False) -> pd.DataFrame:
|
||||
"""
|
||||
Function to create polynomial features
|
||||
@@ -289,13 +298,8 @@ class LinearRegressionModel(BaseEstimator, TransformerMixin):
|
||||
print(f'X_test shape after removing NaN rows: {x_valid.shape}')
|
||||
|
||||
valid_pred = self.regr.predict(x_valid[model_features])
|
||||
|
||||
if self.clipping:
|
||||
for i in range(len(valid_pred)):
|
||||
if valid_pred[i] > self.clipping['max']:
|
||||
valid_pred[i] = self.q3_target
|
||||
elif valid_pred[i] < self.clipping['min']:
|
||||
valid_pred[i] = self.q1_target
|
||||
self._apply_clipping(valid_pred)
|
||||
|
||||
y_pred[row_mask.to_numpy()] = valid_pred
|
||||
return y_pred
|
||||
|
||||
Reference in New Issue
Block a user