From 1f8c20b1676f14364eae1092bfec49b96875c452 Mon Sep 17 00:00:00 2001 From: Markus Bilz Date: Sun, 26 Nov 2023 16:04:24 +0100 Subject: [PATCH] Remove checks for subsets --- src/tclf/classical_classifier.py | 10 ++-------- tests/test_classical_classifier.py | 13 ------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/tclf/classical_classifier.py b/src/tclf/classical_classifier.py index bac1d56..e106f2a 100644 --- a/src/tclf/classical_classifier.py +++ b/src/tclf/classical_classifier.py @@ -32,8 +32,6 @@ "nan", ) -allowed_subsets = ("all", "ex", "best") - class ClassicalClassifier(ClassifierMixin, BaseEstimator): """ClassicalClassifier implements several trade classification rules. @@ -88,7 +86,7 @@ def __init__( >>> pred = clf.predict_proba(X) Args: - layers (List[ tuple[ str, str, ] ]): Layers of classical rule. + layers (List[ tuple[str, str] ]): Layers of classical rule. features (List[str] | None, optional): List of feature names in order of columns. Required to match columns in feature matrix with label. Can be `None`, if `pd.DataFrame` is passed. Defaults to None. random_state (float | None, optional): random seed. Defaults to 42. strategy (Literal["random", "const"], optional): Strategy to fill unclassfied. Randomly with uniform probability or with constant 0. Defaults to "random". @@ -450,11 +448,7 @@ def fit( f"Expected {len(self.columns_)} columns, got {X.shape[1]}." ) - for func_str, subset in self.layers: - if subset not in allowed_subsets: - raise ValueError( - f"Unknown subset: {subset}, expected one of {allowed_subsets}." - ) + for func_str, _ in self.layers: if func_str not in allowed_func_str: raise ValueError( f"Unknown function string: {func_str}," diff --git a/tests/test_classical_classifier.py b/tests/test_classical_classifier.py index 0e80525..f319671 100644 --- a/tests/test_classical_classifier.py +++ b/tests/test_classical_classifier.py @@ -91,19 +91,6 @@ def test_invalid_func(self) -> None: with pytest.raises(ValueError, match=r"Unknown function string"): classifier.fit(self.x_train, self.y_train) - def test_invalid_subset(self) -> None: - """Test, if only valid subset strings can be passed. - - An exception should be raised for invalid subsets. - Test for 'bar', which is no valid subset. - """ - classifier = ClassicalClassifier( - layers=[("tick", "bar")], - random_state=42, - ) - with pytest.raises(ValueError, match=r"Unknown subset"): - classifier.fit(self.x_train, self.y_train) - def test_invalid_col_length(self) -> None: """Test, if only valid column length can be passed.