@@ -1103,7 +1103,6 @@ def _run_model_on_fold(
11031103 fold_no : int ,
11041104 y_train : Optional [np .ndarray ] = None ,
11051105 X_test : Optional [Union [np .ndarray , scipy .sparse .spmatrix , pd .DataFrame ]] = None ,
1106- classes : Optional [List ] = None ,
11071106 ) -> Tuple [np .ndarray , np .ndarray , 'OrderedDict[str, float]' , Optional [OpenMLRunTrace ]]:
11081107 """Run a model on a repeat,fold,subsample triplet of the task and return prediction
11091108 information.
@@ -1134,9 +1133,6 @@ def _run_model_on_fold(
11341133 indices to the potential classes specified by dataset.
11351134 X_test : Optional, array-like (default=None)
11361135 Test attributes to test for generalization in supervised tasks.
1137- classes : List
1138- List of classes for supervised classification tasks (and supervised data stream
1139- classification).
11401136
11411137 Returns
11421138 -------
@@ -1183,6 +1179,12 @@ def _prediction_to_probabilities(y: np.ndarray, classes: List[Any]) -> np.ndarra
11831179 result [obs ][prediction_idx ] = 1.0
11841180 return result
11851181
1182+ if isinstance (task , OpenMLSupervisedTask ):
1183+ if y_train is None :
1184+ raise TypeError ('argument y_train must not be of type None' )
1185+ if X_test is None :
1186+ raise TypeError ('argument X_test must not be of type None' )
1187+
11861188 # TODO: if possible, give a warning if model is already fitted (acceptable
11871189 # in case of custom experimentation,
11881190 # but not desirable if we want to upload to OpenML).
@@ -1259,21 +1261,18 @@ def _prediction_to_probabilities(y: np.ndarray, classes: List[Any]) -> np.ndarra
12591261
12601262 if isinstance (task , (OpenMLClassificationTask , OpenMLLearningCurveTask )):
12611263
1262- if classes is None :
1263- raise TypeError ("Argument classes must not be of type 'None'" )
1264-
12651264 try :
12661265 proba_y = model_copy .predict_proba (X_test )
12671266 except AttributeError :
1268- proba_y = _prediction_to_probabilities (pred_y , list (classes ))
1267+ proba_y = _prediction_to_probabilities (pred_y , list (task . class_labels ))
12691268
1270- if proba_y .shape [1 ] != len (classes ):
1269+ if proba_y .shape [1 ] != len (task . class_labels ):
12711270 # Remap the probabilities in case there was a class missing at training time
12721271 # By default, the classification targets are mapped to be zero-based indices to the
12731272 # actual classes. Therefore, the model_classes contain the correct indices to the
12741273 # correct probability array (the actually array might be incorrect if there are
12751274 # some classes not present during train time).
1276- proba_y_new = np .zeros ((proba_y .shape [0 ], len (classes )))
1275+ proba_y_new = np .zeros ((proba_y .shape [0 ], len (task . class_labels )))
12771276 for idx , model_class in enumerate (model_classes ):
12781277 proba_y_new [:, model_class ] = proba_y [:, idx ]
12791278 proba_y = proba_y_new
0 commit comments