Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
repos:

- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.11.5
hooks:
- id: isort
name: isort imports autosklearn
Expand All @@ -15,7 +15,7 @@ repos:
files: test/.*

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.3.0
hooks:
- id: black
name: black formatter autosklearn
Expand All @@ -31,15 +31,15 @@ repos:

# This is disabled as most modules fail this
- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
rev: 6.3.0
hooks:
- id: pydocstyle
files: DISABLED # autosklearn/.*
always_run: false
additional_dependencies: ["toml"] # Needed to parse pyproject.toml

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.990
rev: v1.2.0
hooks:
- id: mypy
name: mypy auto-sklearn
Expand Down
25 changes: 24 additions & 1 deletion autosklearn/pipeline/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,35 @@ def iterative_fit(self, X, y, n_iter=1, **fit_params):
)

def predict(self, X, batch_size=None):
"""Predict the classes using the selected model.

Predicted values are capped to approximately the maximum and minimum labels
seen during training.

Parameters
----------
X : array-like, shape = (n_samples, n_features)

batch_size: int or None, defaults to None
batch_size controls whether the pipeline will be
called on small chunks of the data. Useful when calling the
predict method on the whole array X results in a MemoryError.

Returns
-------
array, shape=(n_samples,) if n_classes == 2 else (n_samples, n_classes)
Returns the predicted values"""
y = super().predict(X, batch_size=batch_size)
y[y > (2 * self.y_max_)] = 2 * self.y_max_

if self.y_max_ > 0:
y[y > (2 * self.y_max_)] = 2 * self.y_max_
elif self.y_max_ < 0:
y[y > (0.5 * self.y_max_)] = 0.5 * self.y_max_
if self.y_min_ < 0:
y[y < (2 * self.y_min_)] = 2 * self.y_min_
elif self.y_min_ > 0:
y[y < (0.5 * self.y_min_)] = 0.5 * self.y_min_

return y

def _get_hyperparameter_search_space(
Expand Down