Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/files/mock_responses/tasks/data_description_20.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<oml:data_set_description xmlns:oml="http://openml.org/openml">
<oml:id>20</oml:id>
<oml:name>diabetes</oml:name>
<oml:version>1</oml:version>
<oml:description>Pima Indians Diabetes dataset.</oml:description>
<oml:format>ARFF</oml:format>
<oml:upload_date>2014-04-06T23:19:24</oml:upload_date>
<oml:licence>Public</oml:licence>
<oml:url>https://test.openml.org/data/download/20/dataset_20.arff</oml:url>
<oml:file_id>20</oml:file_id>
<oml:default_target_attribute>class</oml:default_target_attribute>
<oml:visibility>public</oml:visibility>
<oml:status>active</oml:status>
<oml:md5_checksum>00000000000000000000000000000000</oml:md5_checksum>
</oml:data_set_description>
22 changes: 22 additions & 0 deletions tests/files/mock_responses/tasks/data_features_20.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<oml:data_features xmlns:oml="http://openml.org/openml">
<oml:feature>
<oml:index>0</oml:index>
<oml:name>preg</oml:name>
<oml:data_type>numeric</oml:data_type>
<oml:is_target>false</oml:is_target>
<oml:is_ignore>false</oml:is_ignore>
<oml:is_row_identifier>false</oml:is_row_identifier>
<oml:number_of_missing_values>0</oml:number_of_missing_values>
</oml:feature>
<oml:feature>
<oml:index>1</oml:index>
<oml:name>class</oml:name>
<oml:data_type>nominal</oml:data_type>
<oml:nominal_value>tested_negative</oml:nominal_value>
<oml:nominal_value>tested_positive</oml:nominal_value>
<oml:is_target>true</oml:is_target>
<oml:is_ignore>false</oml:is_ignore>
<oml:is_row_identifier>false</oml:is_row_identifier>
<oml:number_of_missing_values>0</oml:number_of_missing_values>
</oml:feature>
</oml:data_features>
22 changes: 22 additions & 0 deletions tests/files/mock_responses/tasks/task_801.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<oml:task xmlns:oml="http://openml.org/openml">
<oml:task_id>801</oml:task_id>
<oml:task_type_id>3</oml:task_type_id>
<oml:task_type>Learning Curve</oml:task_type>
<oml:input name="source_data">
<oml:data_set>
<oml:data_set_id>20</oml:data_set_id>
<oml:target_feature>class</oml:target_feature>
</oml:data_set>
</oml:input>
<oml:input name="estimation_procedure">
<oml:estimation_procedure>
<oml:id>13</oml:id>
<oml:type>crossvalidation</oml:type>
<oml:data_splits_url>https://test.openml.org/api_splits/get/801/Task_801_splits.arff</oml:data_splits_url>
<oml:parameter name="number_repeats">1</oml:parameter>
<oml:parameter name="number_folds">10</oml:parameter>
<oml:parameter name="percentage"></oml:parameter>
<oml:parameter name="stratified_sampling">true</oml:parameter>
</oml:estimation_procedure>
</oml:input>
</oml:task>
28 changes: 24 additions & 4 deletions tests/test_tasks/test_learning_curve_task.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# License: BSD 3-Clause
from __future__ import annotations

import requests
from unittest import mock

import pandas as pd
import pytest

import openml
from openml.tasks import TaskType, get_task
from openml.testing import create_request_response

from .test_supervised_task import OpenMLSupervisedTaskTest

Expand Down Expand Up @@ -34,7 +39,22 @@ def test_download_task(self):
assert task.task_type_id == TaskType.LEARNING_CURVE
assert task.dataset_id == 20

@pytest.mark.test_server()
def test_class_labels(self):
task = get_task(self.task_id)
assert task.class_labels == ["tested_negative", "tested_positive"]

@mock.patch.object(requests.Session, "get")
def test_class_labels(mock_get, test_files_directory, test_api_key):
task_response = create_request_response(
status_code=200,
content_filepath=test_files_directory / "mock_responses" / "tasks" / "task_801.xml",
)
description_response = create_request_response(
status_code=200,
content_filepath=test_files_directory / "mock_responses" / "tasks" / "data_description_20.xml",
)
features_response = create_request_response(
status_code=200,
content_filepath=test_files_directory / "mock_responses" / "tasks" / "data_features_20.xml",
)
mock_get.side_effect = [task_response, description_response, features_response]

task = openml.tasks.get_task(801)
assert task.class_labels == ["tested_negative", "tested_positive"]