Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added outlier detection with iterativetrimming #227

Merged
merged 7 commits into from
Jun 29, 2023

Conversation

swagataroy123
Copy link
Contributor

Hi @jduerholt ,
I have added the robust GP outlier as in this paper (https://arxiv.org/abs/2011.11057

Copy link
Contributor

@jduerholt jduerholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, I let some comments.

from typing import Union
try:
from bofire.data_models.outlier_detection.outlier_detection import OutlierDetection,IterativeTrimming
AnyOutlierDetection = Union[OutlierDetection,IterativeTrimming]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you have this try except structure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied it from api of data_models/surrogates

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not needed here, please remove it.

type: str


class IterativeTrimming(OutlierDetection):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a docstring in which you mention the method and the paper and explain the parameters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use google type docstrings

bofire/outlier_detection/mapper.py Outdated Show resolved Hide resolved
bofire/outlier_detection/mapper.py Outdated Show resolved Hide resolved
bofire/outlier_detection/api.py Outdated Show resolved Hide resolved
self.base_gp = data_model.base_gp
super().__init__()

def detect(self, experiments: pd.DataFrame):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def detect(self, experiments: pd.DataFrame):
def detect(self, experiments: pd.DataFrame) -> Tuple[pd.DataFrame, pd.DataFrame]:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call it in the tests exactly as in the the main structure, outlier_validation --> outlier_detection

tests/bofire/outlier_validation/test_outlier_detection.py Outdated Show resolved Hide resolved
Trimmed, outliers = ITGP.detect(experiments=experiments)
assert isinstance(Trimmed, pd.DataFrame)
assert isinstance(outliers, pd.DataFrame)
assert len(experiments) == len(Trimmed) + len(outliers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also check it it was able to finde most of the outliers?

experiments["valid_y"] = 1


@pytest.mark.parametrize(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not need the parameterization here. just write everything starting in line 20 into the test_IterativeTrimming method, and remove the argument experiments from it.

@swagataroy123
Copy link
Contributor Author

Thx, I let some comments.

I have answered them

@jduerholt
Copy link
Contributor

Please also add a specs module as shown here: https://github.com/experimental-design/bofire/blob/main/tests/bofire/data_models/specs/surrogates.py and add the serialization and deserialization tests.

@jduerholt
Copy link
Contributor

jduerholt commented Jun 28, 2023

Furthermore, a notebook under tutorials would be nice in which the ITGP outlier detection stuff is demonstrated based on the ITGP paper.

Call it outlier_detection.ipynb

Copy link
Contributor

@jduerholt jduerholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@jduerholt jduerholt merged commit aa39854 into experimental-design:main Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants