-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
[python-package][PySpark] Expose Training and Validation Metrics #11133
Changes from 1 commit
25a06b8
984bc8e
3e60eec
92d7cec
84ca33a
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""Xgboost training summary integration submodule.""" | ||
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. how about renaming xgboost_training_summary.py to summary.py? 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. DONE |
||
|
||
from dataclasses import dataclass, field | ||
from typing import Dict, List | ||
|
||
|
||
@dataclass | ||
class _XGBoostTrainingSummary: | ||
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. Could be 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. DONE |
||
""" | ||
A class that holds the training and validation objective history | ||
of an XGBoost model during its training process. | ||
""" | ||
|
||
train_objective_history: Dict[str, List[float]] = field(default_factory=dict) | ||
validation_objective_history: Dict[str, List[float]] = field(default_factory=dict) | ||
|
||
@staticmethod | ||
def from_metrics( | ||
metrics: Dict[str, Dict[str, List[float]]] | ||
) -> "_XGBoostTrainingSummary": | ||
""" | ||
Create an XGBoostTrainingSummary instance from a nested dictionary of metrics. | ||
|
||
Parameters | ||
---------- | ||
metrics : dict of str to dict of str to list of float | ||
A dictionary containing training and validation metrics. | ||
Example format: | ||
{ | ||
"training": {"logloss": [0.1, 0.08]}, | ||
"validation": {"logloss": [0.12, 0.1]} | ||
} | ||
|
||
Returns | ||
------- | ||
A new instance of XGBoostTrainingSummary. | ||
|
||
""" | ||
train_objective_history = metrics.get("training", {}) | ||
validation_objective_history = metrics.get("validation", {}) | ||
return _XGBoostTrainingSummary( | ||
train_objective_history, validation_objective_history | ||
) |
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.
@trivialfis, Could you check this is ok by enabling it by default?
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.
Hi @trivialfis, I wonder if this default eval dataset is necessary?
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.
Will look into this.
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.
Looks good to me, it's unlikely someone will train a model without any evaluation.