Skip to content

Commit c5bd7ed

Browse files
committed
keeping old API
1 parent 08efa66 commit c5bd7ed

1 file changed

Lines changed: 61 additions & 16 deletions

File tree

openml/tasks/task.py

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,6 @@ def __init__( # noqa: PLR0913
276276
evaluation_measure: str | None = None,
277277
data_splits_url: str | None = None,
278278
task_id: int | None = None,
279-
class_labels: list[str] | None = None,
280-
cost_matrix: np.ndarray | None = None,
281279
):
282280
resolved_estimation_procedure_id = self._resolve_estimation_procedure_id(
283281
estimation_procedure_id,
@@ -295,11 +293,6 @@ def __init__( # noqa: PLR0913
295293
target_name=target_name,
296294
)
297295

298-
self.class_labels = class_labels
299-
self.cost_matrix = cost_matrix
300-
if cost_matrix is not None:
301-
raise NotImplementedError("Costmatrix")
302-
303296
def get_X_and_y(self) -> tuple[pd.DataFrame, pd.Series | pd.DataFrame | None]:
304297
"""Get data associated with the current task.
305298
@@ -349,6 +342,26 @@ class OpenMLClassificationTask(OpenMLSupervisedTask):
349342
350343
Parameters
351344
----------
345+
task_id : Union[int, None]
346+
ID of the Classification task (if it already exists on OpenML).
347+
task_type_id : TaskType
348+
ID of the Classification task type.
349+
task_type : str
350+
Name of the Classification task type.
351+
data_set_id : int
352+
ID of the OpenML dataset associated with the Classification task.
353+
target_name : str
354+
Name of the target variable.
355+
estimation_procedure_id : int, default=1
356+
ID of the estimation procedure for the Classification task.
357+
estimation_procedure_type : str, default=None
358+
Type of the estimation procedure.
359+
estimation_parameters : dict, default=None
360+
Estimation parameters for the Classification task.
361+
evaluation_measure : str, default=None
362+
Name of the evaluation measure.
363+
data_splits_url : str, default=None
364+
URL of the data splits for the Classification task.
352365
class_labels : List of str, default=None
353366
A list of class labels (for classification tasks).
354367
cost_matrix : array, default=None
@@ -357,12 +370,46 @@ class OpenMLClassificationTask(OpenMLSupervisedTask):
357370

358371
DEFAULT_ESTIMATION_PROCEDURE_ID: ClassVar[int] = 1
359372

373+
def __init__( # noqa: PLR0913
374+
self,
375+
task_type_id: TaskType,
376+
task_type: str,
377+
data_set_id: int,
378+
target_name: str,
379+
estimation_procedure_id: int | None = None,
380+
estimation_procedure_type: str | None = None,
381+
estimation_parameters: dict[str, str] | None = None,
382+
evaluation_measure: str | None = None,
383+
data_splits_url: str | None = None,
384+
task_id: int | None = None,
385+
class_labels: list[str] | None = None,
386+
cost_matrix: np.ndarray | None = None,
387+
):
388+
super().__init__(
389+
task_type_id=task_type_id,
390+
task_type=task_type,
391+
data_set_id=data_set_id,
392+
target_name=target_name,
393+
estimation_procedure_id=estimation_procedure_id,
394+
estimation_procedure_type=estimation_procedure_type,
395+
estimation_parameters=estimation_parameters,
396+
evaluation_measure=evaluation_measure,
397+
data_splits_url=data_splits_url,
398+
task_id=task_id,
399+
)
400+
self.class_labels = class_labels
401+
self.cost_matrix = cost_matrix
402+
if cost_matrix is not None:
403+
raise NotImplementedError("Costmatrix")
404+
360405

361406
class OpenMLRegressionTask(OpenMLSupervisedTask):
362407
"""OpenML Regression object.
363408
364409
Parameters
365410
----------
411+
task_id : Union[int, None]
412+
ID of the OpenML Regression task.
366413
task_type_id : TaskType
367414
Task type ID of the OpenML Regression task.
368415
task_type : str
@@ -371,16 +418,14 @@ class OpenMLRegressionTask(OpenMLSupervisedTask):
371418
ID of the OpenML dataset.
372419
target_name : str
373420
Name of the target feature used in the Regression task.
374-
estimation_procedure_id : int, default=None
421+
estimation_procedure_id : int, default=7
375422
ID of the OpenML estimation procedure.
376423
estimation_procedure_type : str, default=None
377424
Type of the OpenML estimation procedure.
378425
estimation_parameters : dict, default=None
379426
Parameters used by the OpenML estimation procedure.
380427
data_splits_url : str, default=None
381428
URL of the OpenML data splits for the Regression task.
382-
task_id : Union[int, None]
383-
ID of the OpenML Regression task.
384429
evaluation_measure : str, default=None
385430
Evaluation measure used in the Regression task.
386431
"""
@@ -393,16 +438,16 @@ class OpenMLClusteringTask(OpenMLTask):
393438
394439
Parameters
395440
----------
441+
task_id : Union[int, None]
442+
ID of the OpenML clustering task.
396443
task_type_id : TaskType
397444
Task type ID of the OpenML clustering task.
398445
task_type : str
399446
Task type of the OpenML clustering task.
400447
data_set_id : int
401448
ID of the OpenML dataset used in clustering the task.
402-
estimation_procedure_id : int, default=None
449+
estimation_procedure_id : int, default=17
403450
ID of the OpenML estimation procedure.
404-
task_id : Union[int, None]
405-
ID of the OpenML clustering task.
406451
estimation_procedure_type : str, default=None
407452
Type of the OpenML estimation procedure used in the clustering task.
408453
estimation_parameters : dict, default=None
@@ -452,6 +497,8 @@ class OpenMLLearningCurveTask(OpenMLClassificationTask):
452497
453498
Parameters
454499
----------
500+
task_id : Union[int, None]
501+
ID of the Learning Curve task.
455502
task_type_id : TaskType
456503
ID of the Learning Curve task.
457504
task_type : str
@@ -460,16 +507,14 @@ class OpenMLLearningCurveTask(OpenMLClassificationTask):
460507
ID of the dataset that this task is associated with.
461508
target_name : str
462509
Name of the target feature in the dataset.
463-
estimation_procedure_id : int, default=None
510+
estimation_procedure_id : int, default=13
464511
ID of the estimation procedure to use for evaluating models.
465512
estimation_procedure_type : str, default=None
466513
Type of the estimation procedure.
467514
estimation_parameters : dict, default=None
468515
Additional parameters for the estimation procedure.
469516
data_splits_url : str, default=None
470517
URL of the file containing the data splits for Learning Curve task.
471-
task_id : Union[int, None]
472-
ID of the Learning Curve task.
473518
evaluation_measure : str, default=None
474519
Name of the evaluation measure to use for evaluating models.
475520
class_labels : list of str, default=None

0 commit comments

Comments
 (0)