-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #750 regularization strength for logistic classifier
- Loading branch information
grefrathc
committed
Jun 21, 2024
1 parent
b81bcd6
commit 1b37cd6
Showing
2 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/safeds/ml/classical/classification/test_logistic_classifier.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
from safeds.data.labeled.containers import TabularDataset | ||
from safeds.data.tabular.containers import Table | ||
from safeds.ml.classical.classification import LogisticClassifier | ||
|
||
|
||
@pytest.fixture() | ||
def training_set() -> TabularDataset: | ||
table = Table({"col1": [1, 2, 3, 4], "col2": [1, 2, 3, 4]}) | ||
return table.to_tabular_dataset(target_name="col1") | ||
|
||
class TestC: | ||
def test_should_be_passed_to_fitted_model(self, training_set: TabularDataset) -> None: | ||
fitted_model = LogisticClassifier(c=2).fit(training_set) | ||
assert fitted_model.c == 2 | ||
|
||
def test_should_be_passed_to_sklearn(self, training_set: TabularDataset) -> None: | ||
fitted_model = LogisticClassifier(c=2).fit(training_set) | ||
assert fitted_model._wrapped_model is not None | ||
assert fitted_model._wrapped_model.C == 2 | ||
|
||
def test_clone(self, training_set: TabularDataset) -> None: | ||
fitted_model = LogisticClassifier(c=2).fit(training_set) | ||
cloned_classifier = fitted_model._clone() | ||
assert isinstance(cloned_classifier, LogisticClassifier) | ||
assert cloned_classifier.c == fitted_model.c |