objective_base¶
Module Contents¶
Classes Summary¶
Base class for all objectives. |
Contents¶
-
class
evalml.objectives.objective_base.
ObjectiveBase
[source]¶ Base class for all objectives.
Attributes
problem_types
None
Methods
Calculate the percent difference between scores.
Returns a boolean determining if a greater score indicates better model performance.
Returns whether this objective is bounded between 0 and 1, inclusive.
Returns a name describing the objective.
Computes the relative value of the provided predictions compared to the actual labels, according a specified metric
Returns the score obtained by evaluating this objective on a perfect model.
If True, this objective is only valid for positive data. Default False.
Returns a numerical score indicating performance based on the differences between the predicted and actual values.
Returns a boolean determining if the score() method needs probability estimates. This should be true for objectives which work with predicted probabilities, like log loss or AUC, and false for objectives which compare predicted class labels to the actual labels, like F1 or correlation.
Validates the input based on a few simple checks.
-
classmethod
calculate_percent_difference
(cls, score, baseline_score)[source]¶ Calculate the percent difference between scores.
- Parameters
score (float) – A score. Output of the score method of this objective.
baseline_score (float) – A score. Output of the score method of this objective. In practice, this is the score achieved on this objective with a baseline estimator.
- Returns
- The percent difference between the scores. Note that for objectives that can be interpreted
as percentages, this will be the difference between the reference score and score. For all other objectives, the difference will be normalized by the reference score.
- Return type
float
-
property
greater_is_better
(cls)¶ Returns a boolean determining if a greater score indicates better model performance.
-
property
is_bounded_like_percentage
(cls)¶ Returns whether this objective is bounded between 0 and 1, inclusive.
-
property
name
(cls)¶ Returns a name describing the objective.
-
abstract classmethod
objective_function
(cls, y_true, y_predicted, X=None, sample_weight=None)[source]¶ Computes the relative value of the provided predictions compared to the actual labels, according a specified metric
- Arguments:
y_predicted (pd.Series): Predicted values of length [n_samples] y_true (pd.Series): Actual class labels of length [n_samples] X (pd.DataFrame or np.ndarray): Extra data of shape [n_samples, n_features] necessary to calculate score sample_weight (pd.DataFrame or np.ndarray): Sample weights used in computing objective value result
- Returns
Numerical value used to calculate score
-
property
perfect_score
(cls)¶ Returns the score obtained by evaluating this objective on a perfect model.
-
positive_only
(cls)¶ If True, this objective is only valid for positive data. Default False.
-
score
(self, y_true, y_predicted, X=None, sample_weight=None)[source]¶ Returns a numerical score indicating performance based on the differences between the predicted and actual values.
- Parameters
y_predicted (pd.Series) – Predicted values of length [n_samples]
y_true (pd.Series) – Actual class labels of length [n_samples]
X (pd.DataFrame or np.ndarray) – Extra data of shape [n_samples, n_features] necessary to calculate score
sample_weight (pd.DataFrame or np.ndarray) – Sample weights used in computing objective value result
- Returns
score
-
property
score_needs_proba
(cls)¶ Returns a boolean determining if the score() method needs probability estimates. This should be true for objectives which work with predicted probabilities, like log loss or AUC, and false for objectives which compare predicted class labels to the actual labels, like F1 or correlation.
-
classmethod