-
Notifications
You must be signed in to change notification settings - Fork 1
API models
class adaptivetesting.models.AdaptiveTest(item_pool: ItemPool, simulation_id: str, participant_id: str, true_ability_level: float | None = None, initial_ability_level: float = 0, simulation: bool = True, DEBUG=False, **kwargs)
Bases: ABC
Abstract implementation of an adaptive test. All abstract methods have to be overridden to create an instance of this class.
Abstract methods: : - estimate_ability_level
Args:
: item_pool (ItemPool): item pool used for the test
simulation_id (str): simulation id
participant_id (str): participant id
true_ability_level (float): true ability level (must always be set)
initial_ability_level (float): initially assumed ability level
simulation (bool): will the test be simulated.
If it is simulated and a response pattern is not yet set in the item pool, it will be generated for the given true ability level. A seed may also be set using the additional argument seed and set it to an int value, e.g. AdaptiveTest(…, seed=1234)
DEBUG (bool): enables debug mode
__init__(item_pool: ItemPool, simulation_id: str, participant_id: str, true_ability_level: float | None = None, initial_ability_level: float = 0, simulation: bool = True, DEBUG=False, **kwargs)
Abstract implementation of an adaptive test. All abstract methods have to be overridden to create an instance of this class.
Abstract methods: : - estimate_ability_level
Args:
: item_pool (ItemPool): item pool used for the test
simulation_id (str): simulation id
participant_id (str): participant id
true_ability_level (float): true ability level (must always be set)
initial_ability_level (float): initially assumed ability level
simulation (bool): will the test be simulated.
If it is simulated and a response pattern is not yet set in the item pool, it will be generated for the given true ability level. A seed may also be set using the additional argument seed and set it to an int value, e.g. AdaptiveTest(…, seed=1234)
DEBUG (bool): enables debug mode
Estimates ability level. The method has to be implemented by subclasses.
Returns: : (float, float): estimated ability level, standard error of the estimation
get_answered_items() → List[TestItem]
Returns: : List[TestItem]: answered items
Returns: : List[float]: difficulties of answered items
Returns: : List[float]: difficulties of items in the item pool
abstractmethod get_next_item() → TestItem
Select next item.
Returns: : TestItem: selected item
get_response(item: TestItem) → int
If the adaptive test is not used for simulation. This method is used to get user feedback.
Args: : item (TestItem): test item shown to the participant
Return: : int: participant’s response
Runs the test procedure once. Saves the result to test_results of the current instance.
Bases: Exception
Exception that is thrown when the estimation process did not find a maximum.
class adaptivetesting.models.ItemPool(test_items: List[TestItem], simulated_responses: List[int] | None = None)
Bases: object
An item pool has to be created for an adaptive test. For that, a list of test items has to be provided. If the package is used to simulate adaptive tests, simulated responses have to be supplied as well. The responses are matched to the items internally. Therefore, both have to be in the same order.
Args:
: test_items (List[TestItem]): A list of test items. Necessary for any adaptive test.
simulated_responses (List[int]): A list of simulated responses.
Required for CAT simulations.
__init__(test_items: List[TestItem], simulated_responses: List[int] | None = None)
An item pool has to be created for an adaptive test. For that, a list of test items has to be provided. If the package is used to simulate adaptive tests, simulated responses have to be supplied as well. The responses are matched to the items internally. Therefore, both have to be in the same order.
Args:
: test_items (List[TestItem]): A list of test items. Necessary for any adaptive test.
simulated_responses (List[int]): A list of simulated responses.
Required for CAT simulations.
delete_item(item: TestItem) → None
Deletes item from item pool. If simulated responses are defined, they will be deleted as well.
Args: : item (TestItem): The test item to delete.
Returns item and if defined the simulated response.
Args: : index (int): Index of the test item in the item pool to return.
Returns: : TestItem or (TestItem, Simulated Response)
Returns item and if defined the simulated response.
Args: : item (TestItem): item to return.
Returns: : TestItem or (TestItem, Simulated Response)
get_item_response(item: TestItem) → int
Gets the simulated response to an item if available. A ValueError will be raised if a simulated response is not available.
Args: : item (TestItem): item to get the corresponding response
Returns: : (int): response (either 0 or 1)
static load_from_dataframe(source: DataFrame) → ItemPool
Creates item pool from a pandas DataFrame. Required columns are: a, b, c, d. Each column has to contain float values. A simulated_responses (int values) column can be added to the DataFrame to provide simulated responses.
Args: : source (DataFrame): source data frame
Returns: : ItemPool: parsed item pool
static load_from_dict(source: dict[str, List[float]], simulated_responses: List[int] | None = None, ids: List[int] | None = None, content_categories: list[list[str]] | None = None) → ItemPool
Creates test items from a dictionary. The dictionary has to have the following keys:
- a
- b
- c
- d
each containing a list of float.
Args:
: source (dict[str, List[float]]): item pool dictionary
simulated_responses (List[int]): simulated responses
ids (List[int], optional): item IDs. Default None.
content_categories (list[list[str]], optional): List of categories for each item.
This list is used for content balancing.
Returns: : List[TestItem]: item pool
static load_from_list(b: List[float], a: List[float] | None = None, c: List[float] | None = None, d: List[float] | None = None, simulated_responses: List[int] | None = None, ids: List[int] | None = None, content_categories: list[list[str]] | None = None) → ItemPool
Creates test items from a list of floats.
Args:
: a (List[float]): discrimination parameter
b (List[float]): difficulty parameter
c (List[float]): guessing parameter
d (List[float]): slipping parameter
simulated_responses (List[int]): simulated responses
ids (List[int]): item IDs
content_categories (list[list[str]], optional): List of categories for each item.
This list is used for content balancing.
Returns: : List[TestItem]: item pool
Bases: Exception
Custom exception for item selection errors in adaptive testing.
Bases: Enum
Enum for selecting the output format for the test results
Bases: Enum
Enum for selecting the stopping criterion for the adaptive test
Bases: object
Representation of a test item in the item pool. The format is equal to the implementation in catR.
Properties: : - id (int | None): item ID
- a (float): discrimination parameter
- b (float): difficulty parameter
- c (float): guessing parameter
- d (float): slipping parameter / upper asymptote
- additional_properties (dict): addtional properties can be set if required. : This functionality is used for content balancing. To use content balancing, set set category key of the class instance to a list of string which indicate the corresponding constraint classes. Example: item.additional_properties[“category”] = [“Math”]
Representation of a test item in the item pool. The format is equal to the implementation in catR.
Properties: : - id (int | None): item ID
- a (float): discrimination parameter
- b (float): difficulty parameter
- c (float): guessing parameter
- d (float): slipping parameter / upper asymptote
- additional_properties (dict): addtional properties can be set if required. : This functionality is used for content balancing. To use content balancing, set set category key of the class instance to a list of string which indicate the corresponding constraint classes. Example: item.additional_properties[“category”] = [“Math”]
static from_dict(source: dict) → TestItem
class adaptivetesting.models.TestResult(test_id: str, ability_estimation: float, standard_error: float, showed_item: dict, response: int, true_ability_level: float)
Bases: object
Representation of simulation test results
__init__(test_id: str, ability_estimation: float, standard_error: float, showed_item: dict, response: int, true_ability_level: float) → None
static from_dict(dictionary: Dict) → TestResult
Create a TestResult from a dictionary
Args: : dictionary: with the fields test_id, ability_estimation, standard_error, showed_item, response, true_ability_level
Getting Started
Tutorials
API Reference