get ability estimation from source

This commit is contained in:
brmnjsh
2023-09-15 14:29:55 +00:00
parent f22d1c4cdb
commit 7a14856775
6 changed files with 78 additions and 4 deletions

View 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)