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
Remove param 'evals_result' 'early_stopping_rounds' in lightgbm version > 3.3.1 #5206
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
|
||
from moto.core import BaseBackend, BaseModel | ||
from moto.core.responses import BaseResponse | ||
from moto.ec2 import ec2_backends | ||
|
||
from moto.iam.models import ACCOUNT_ID | ||
from moto.core.models import base_decorator | ||
|
@@ -1076,10 +1075,7 @@ def response_object(self): | |
return response | ||
|
||
|
||
# Create a SageMaker backend for each EC2 region | ||
sagemaker_backends = {} | ||
for region, ec2_backend in ec2_backends.items(): | ||
new_backend = SageMakerBackend() | ||
sagemaker_backends[region] = new_backend | ||
# Create a SageMaker backend for EC2 region: "us-west-2" | ||
sagemaker_backends = {"us-west-2": SageMakerBackend()} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the description in getmoto/moto#4699:
So we need to create a SageMaker backend for "us-west-2", which is used in our test. Since "us-west-2" is hardcoded in our tests as the default AWS region, I also hardcoded it here. With moto==2.3.0, the old implementation only returns one region "us-east-1", which is the default region used by moto. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can probably update the small-requirements.txt now to instead of excluding version 2.0.7, just force use of >=2.3.0. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is also compatible with moto<2.3.0, so we don't have to change it now. |
||
|
||
mock_sagemaker = base_decorator(sagemaker_backends) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model.best_iteration > 0
can be used to determine whether early stopping is activated.model.best_iteration
is initiated as 0 and is assigned with a positive int whenEarlyStoppingException
is raised (this means early stopping is activated, including using theearly_stopping_rounds
param,lightgbm.early_stopping
callback function, or even a user-defined early_stopping callback that raisesEarlyStoppingException
).model.best_iteration
is returned as 0 when early stopping is not activated.Reference: https://github.com/microsoft/LightGBM/blob/ce486e5b45a6f5e67743e14765ed139ff8d532e5/python-package/lightgbm/engine.py#L226-L263