@@ -88,7 +88,7 @@ def test_sklearn_binary_classifier(cancer_dataset, model, algorithm):
8888 assert info .analytic_function == "classification"
8989 assert info .algorithm == algorithm
9090 assert info .output_column_names == [target ] # target_variable
91- assert info .target_values == ["malignant" ] # target_event
91+ assert info .target_values == ["benign" , " malignant" ] # [non-event, event]
9292 assert info .predict_function == model .predict
9393
9494 # If output frame contains a column name then it should be retained
@@ -132,6 +132,33 @@ def test_sklearn_binary_classifier_target_column_name(cancer_dataset):
132132 assert info .output_column_names == ["I_Target" ]
133133
134134
135+ def test_sklearn_binary_classifier_target_values_registration (cancer_dataset ):
136+ """Regression test: registering a binary classifier should not raise ValueError.
137+
138+ write_model_properties_json requires either 0, 2, or >2 target values (raising
139+ a ValueError otherwise), but SklearnModelInfo.target_values used to return only
140+ the single event class for binary classifiers, which broke register_model.
141+ See: https://github.com/sassoftware/python-sasctl/issues/200
142+ """
143+ from sasctl .pzmm import JSONFiles
144+
145+ target = "Type"
146+ X = cancer_dataset .drop (columns = target )
147+ y = cancer_dataset [target ]
148+
149+ model = LogisticRegression (max_iter = 5000 ).fit (X , y )
150+ info = get_model_info (model , X , y )
151+
152+ assert len (info .target_values ) == 2
153+
154+ properties = JSONFiles ().write_model_properties_json (
155+ model_name = "test_model" ,
156+ target_variable = info .target_column ,
157+ target_values = info .target_values ,
158+ )
159+ assert properties is not None
160+
161+
135162@pytest .mark .parametrize (
136163 "model, algorithm" ,
137164 [
0 commit comments