Skip to content

Commit 421f56d

Browse files
author
adam-bialy
committed
add a test according to review requirements
1 parent 12ee458 commit 421f56d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_survival.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,23 @@ def test_getting_training_dataset_kaplan_meier_estimator(self):
185185
"Estimator should contain probabilities for each unique time from the dataset",
186186
)
187187

188+
def test_max_rule_count(self):
189+
MAX_RULE_COUNT = 3
190+
df: pd.DataFrame = read_arff(
191+
os.path.join(dir_path, "resources", "data", "bmt-train-0.arff")
192+
)
193+
X, y = df.drop("survival_status", axis=1), df["survival_status"]
194+
clf = survival.SurvivalRules(
195+
survival_time_attr="survival_time",
196+
max_rule_count=MAX_RULE_COUNT,
197+
)
198+
clf.fit(X, y)
199+
self.assertLessEqual(
200+
len(clf.model.rules),
201+
MAX_RULE_COUNT,
202+
f"Ruleset should contain no more than {MAX_RULE_COUNT} rules according to max_rule_count parameter",
203+
)
204+
188205

189206
class TestExpertSurvivalRules(unittest.TestCase):
190207

0 commit comments

Comments
 (0)