Skip to content

Commit

Permalink
clean up comments and if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
remyogasawara committed Jul 18, 2023
1 parent 121450f commit 90fb578
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion evalml/objectives/cost_benefit_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def objective_function(
Args:
y_predicted (pd.Series): Predicted labels.
y_true (pd.Series): True labels.
y_train (pd.Series): Training labels.
y_train (pd.Series): Ignored.
X (pd.DataFrame): Ignored.
sample_weight (pd.DataFrame): Ignored.
Expand Down
2 changes: 1 addition & 1 deletion evalml/objectives/fraud_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def objective_function(
Args:
y_predicted (pd.Series): Predicted fraud labels.
y_true (pd.Series): True fraud labels.
y_train (pd.Series): Training labels.
y_train (pd.Series): Ignored.
X (pd.DataFrame): Data with transaction amounts.
sample_weight (pd.DataFrame): Ignored.
Expand Down
2 changes: 1 addition & 1 deletion evalml/objectives/lead_scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def objective_function(
Args:
y_predicted (pd.Series): Predicted labels.
y_true (pd.Series): True labels.
y_train (pd.Series): Training labels.
y_train (pd.Series): Ignored.
X (pd.DataFrame): Ignored.
sample_weight (pd.DataFrame): Ignored.
Expand Down
11 changes: 4 additions & 7 deletions evalml/objectives/standard_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ def objective_function(


class MASE(TimeSeriesRegressionObjective):
"""Mean absolute scaled error for time series regression. Scaled by 100 to return a percentage.
"""Mean absolute scaled error for time series regression.
Only valid if there exists a nonzero input in y_train. Otherwise, will throw a ValueError.
Expand All @@ -1068,12 +1068,9 @@ def objective_function(
sample_weight=None,
):
"""Objective function for mean absolute scaled error for time series regression."""
# [0, 1, 1, 0] -- good
# [0, 0, 0, 0] -- bad

if (isinstance(y_train, pd.DataFrame) and (y_train.values == 0).all()) or (
isinstance(y_train, pd.Series) and (y_train == 0).all()
):
if isinstance(y_train, np.ndarray):
y_train = pd.Series(y_train)
if (y_train.values == 0).all():
raise ValueError(
"Mean Absolute Scaled Error cannot be used when "
"all training targets contain the value 0.",
Expand Down
1 change: 0 additions & 1 deletion evalml/tests/objective_tests/test_standard_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def test_negative_with_log():


@pytest.mark.parametrize("objective_class", _all_objectives_dict().values())
# @pytest.mark.parametrize("obj", [obj for obj in _all_objectives_dict().values()])
def test_regression_handles_dataframes(objective_class):
if not issubclass(objective_class, RegressionObjective):
pytest.skip("Skipping non-regression objective")
Expand Down

0 comments on commit 90fb578

Please sign in to comment.