added iif and tif functions
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
from lib.irt.models.three_parameter_logistic import ThreeParameterLogistic
|
||||
|
||||
class ItemInformationFunction():
|
||||
def __init__(self, irt_model):
|
||||
self.model_data = irt_model
|
||||
|
||||
def calculate(self, **kwargs):
|
||||
if self.model_data.model == '3PL':
|
||||
p = ThreeParameterLogistic(self.model_data, kwargs).result()
|
||||
q = 1 - p
|
||||
return self.model_data.a_param**2 * ((q / p) * ((p - (self.model_data.c_param**2)) / (1 - (self.model_data.c_param**2))))
|
||||
else:
|
||||
# potentially error out
|
||||
return None
|
||||
|
@ -0,0 +1,16 @@
|
||||
from lib.irt.item_information_function import ItemInformationFunction
|
||||
|
||||
class TestInformationFunction():
|
||||
def __init__(self, irt_model):
|
||||
self.irt_model = irt_model
|
||||
self.iif = ItemInformationFunction(irt_model)
|
||||
|
||||
def calculate(self, items, **kwargs):
|
||||
sum = 0
|
||||
|
||||
for item in items:
|
||||
result = self.iif.calculate(b_param=item.b_param, theta=kwargs['theta'])
|
||||
item.iif = result
|
||||
sum += item.iif
|
||||
|
||||
return sum
|
||||
|
Reference in New Issue
Block a user