Skip to content

Commit

Permalink
style: apply automated linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
megalinter-bot committed Jul 13, 2024
1 parent 7ff98d2 commit 84033cf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
32 changes: 16 additions & 16 deletions src/safeds/ml/nn/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,23 +332,23 @@ def fit_by_exhaustive_search(
case "mean_squared_error":
error_of_fitted_model = RegressionMetrics.mean_squared_error(predicted=fitted_model.predict(test_data), expected=target_col) # type: ignore[arg-type]
if error_of_fitted_model < best_metric_value:
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
case "mean_absolute_error":
error_of_fitted_model = RegressionMetrics.mean_absolute_error(predicted=fitted_model.predict(test_data), expected=target_col) # type: ignore[arg-type]
if error_of_fitted_model < best_metric_value:
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
case "median_absolute_deviation":
error_of_fitted_model = RegressionMetrics.median_absolute_deviation(predicted=fitted_model.predict(test_data), expected=target_col) # type: ignore[arg-type]
if error_of_fitted_model < best_metric_value:
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
case "coefficient_of_determination":
error_of_fitted_model = RegressionMetrics.coefficient_of_determination(predicted=fitted_model.predict(test_data), expected=target_col) # type: ignore[arg-type]
if error_of_fitted_model > best_metric_value:
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
assert best_model is not None # just for linter
best_model._is_fitted = True
return best_model
Expand Down Expand Up @@ -753,23 +753,23 @@ def fit_by_exhaustive_search(
case "accuracy":
error_of_fitted_model = ClassificationMetrics.accuracy(predicted=fitted_model.predict(test_data), expected=target_col) # type: ignore[arg-type]
if error_of_fitted_model > best_metric_value:
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
case "precision":
error_of_fitted_model = ClassificationMetrics.precision(predicted=fitted_model.predict(test_data), expected=target_col, positive_class=positive_class) # type: ignore[arg-type]
if error_of_fitted_model > best_metric_value:
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
case "recall":
error_of_fitted_model = ClassificationMetrics.recall(predicted=fitted_model.predict(test_data), expected=target_col, positive_class=positive_class) # type: ignore[arg-type]
if error_of_fitted_model > best_metric_value:
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
case "f1_score":
error_of_fitted_model = ClassificationMetrics.f1_score(predicted=fitted_model.predict(test_data), expected=target_col, positive_class=positive_class) # type: ignore[arg-type]
if error_of_fitted_model > best_metric_value:
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
best_model = fitted_model # pragma: no cover
best_metric_value = error_of_fitted_model # pragma: no cover
assert best_model is not None # just for linter
best_model._is_fitted = True
return best_model
Expand Down
17 changes: 13 additions & 4 deletions tests/safeds/ml/nn/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,11 @@ def test_should_raise_when_fitting_by_exhaustive_search_without_choice(self, dev
0,
),
],
ids=["accuracy", "precision", "f1score", "recall"]
ids=["accuracy", "precision", "f1score", "recall"],
)
def test_should_assert_that_is_fitted_is_set_correctly_and_check_return_type(self, metric: ClassifierMetric, positive_class: Any, device: Device) -> None:
def test_should_assert_that_is_fitted_is_set_correctly_and_check_return_type(
self, metric: ClassifierMetric, positive_class: Any, device: Device,
) -> None:
configure_test_with_device(device)
model = NeuralNetworkClassifier(InputConversionTable(), [ForwardLayer(Choice(2, 4)), ForwardLayer(1)])
assert not model.is_fitted
Expand Down Expand Up @@ -861,9 +863,16 @@ def test_should_raise_when_fitting_by_exhaustive_search_without_choice(self, dev
RegressorMetric.MEDIAN_ABSOLUTE_DEVIATION,
RegressorMetric.COEFFICIENT_OF_DETERMINATION,
],
ids=["mean_squared_error", "mean_absolute_error", "median_absolute_deviation", "coefficient_of_determination"],
ids=[
"mean_squared_error",
"mean_absolute_error",
"median_absolute_deviation",
"coefficient_of_determination",
],
)
def test_should_assert_that_is_fitted_is_set_correctly_and_check_return_type(self, metric: RegressorMetric, device: Device) -> None:
def test_should_assert_that_is_fitted_is_set_correctly_and_check_return_type(
self, metric: RegressorMetric, device: Device,
) -> None:
configure_test_with_device(device)
model = NeuralNetworkRegressor(InputConversionTable(), [ForwardLayer(Choice(2, 4)), ForwardLayer(1)])
assert not model.is_fitted
Expand Down

0 comments on commit 84033cf

Please sign in to comment.