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

Add the validation score and training time for create_function in XGBoost #1327

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 12 additions & 1 deletion evadb/executor/create_function_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,16 @@ def handle_xgboost_function(self):

impl_path = Path(f"{self.function_dir}/xgboost.py").absolute().as_posix()
io_list = self._resolve_function_io(None)
best_score = model.best_loss
train_time = model.best_config_train_time
return (
self.node.name,
impl_path,
self.node.function_type,
io_list,
self.node.metadata,
best_score,
train_time,
)

def handle_ultralytics_function(self):
Expand Down Expand Up @@ -586,6 +590,8 @@ def exec(self, *args, **kwargs):
)

overwrite = False
best_score = False
train_time = False
# check catalog if it already has this function entry
if self.catalog().get_function_catalog_entry_by_name(self.node.name):
if self.node.if_not_exists:
Expand Down Expand Up @@ -648,6 +654,8 @@ def exec(self, *args, **kwargs):
function_type,
io_list,
metadata,
best_score,
train_time,
) = self.handle_xgboost_function()
elif string_comparison_case_insensitive(self.node.function_type, "Forecasting"):
(
Expand All @@ -674,7 +682,10 @@ def exec(self, *args, **kwargs):
msg = f"Function {self.node.name} overwritten."
else:
msg = f"Function {self.node.name} added to the database."
yield Batch(pd.DataFrame([msg]))
if best_score and train_time:
yield Batch(pd.DataFrame([msg, best_score, train_time]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we add some text? Other wise, it will be just two numbers without any explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some annotations

else:
yield Batch(pd.DataFrame([msg]))

def _try_initializing_function(
self, impl_path: str, function_args: Dict = {}
Expand Down
8 changes: 6 additions & 2 deletions test/integration_tests/long/test_model_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def test_xgboost_regression(self):
METRIC 'r2'
TASK 'regression';
"""
execute_query_fetch_all(self.evadb, create_predict_function)
result = execute_query_fetch_all(self.evadb, create_predict_function)
self.assertEqual(len(result.columns), 1)
self.assertEqual(len(result), 3)

predict_query = """
SELECT PredictRentXgboost(number_of_rooms, number_of_bathrooms, days_on_market, rental_price) FROM HomeRentals LIMIT 10;
Expand All @@ -158,7 +160,9 @@ def test_xgboost_classification(self):
METRIC 'accuracy'
TASK 'classification';
"""
execute_query_fetch_all(self.evadb, create_predict_function)
result = execute_query_fetch_all(self.evadb, create_predict_function)
self.assertEqual(len(result.columns), 1)
self.assertEqual(len(result), 3)

predict_query = """
SELECT PredictEmployeeXgboost(payment_tier, age, gender, experience_in_current_domain, leave_or_not) FROM Employee LIMIT 10;
Expand Down