get ability estimation from source
This commit is contained in:
23
app/models/ability_estimation.py
Normal file
23
app/models/ability_estimation.py
Normal file
@ -0,0 +1,23 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import ClassVar, List
|
||||
|
||||
from models.item import Item
|
||||
from lib.irt.models.three_parameter_logistic import ThreeParameterLogistic
|
||||
from lib.irt.models.rasch import Rasch
|
||||
|
||||
class AbilityEstimation(BaseModel):
|
||||
exam_id: int
|
||||
items: List[Item] = []
|
||||
irt_model: str
|
||||
min_theta: float = -3.0
|
||||
max_theta: float = 3.0
|
||||
|
||||
IRT_MODELS: ClassVar[dict] = {
|
||||
'rasch': Rasch,
|
||||
# not supported
|
||||
# '3pl': ThreeParameterLogistic
|
||||
}
|
||||
|
||||
def calculate(self) -> float:
|
||||
model = self.IRT_MODELS[self.irt_model]
|
||||
return model.ability_estimate(self.items)
|
@ -11,8 +11,9 @@ class Item(BaseModel):
|
||||
position: Optional[int] = None
|
||||
passage_id: Optional[int] = None
|
||||
workflow_state: Optional[str] = None
|
||||
attributes: List[Attribute]
|
||||
attributes: List[Attribute] = None
|
||||
b_param: float = 0.00
|
||||
response: Optional[str] = None
|
||||
|
||||
def iif(self, solver_run, theta):
|
||||
return ItemInformationFunction(solver_run.irt_model).calculate(b_param=self.b_param, theta=theta)
|
||||
|
Reference in New Issue
Block a user