Commit febcb511 by ichuang

make psychometrics curve fitting more robust

parent 26f14aaf
...@@ -246,6 +246,7 @@ def generate_plots_for_problem(problem): ...@@ -246,6 +246,7 @@ def generate_plots_for_problem(problem):
yset['ydat'] = ydat yset['ydat'] = ydat
if len(ydat) > 3: # try to fit to logistic function if enough data points if len(ydat) > 3: # try to fit to logistic function if enough data points
try:
cfp = curve_fit(func_2pl, xdat, ydat, [1.0, max_attempts / 2.0]) cfp = curve_fit(func_2pl, xdat, ydat, [1.0, max_attempts / 2.0])
yset['fitparam'] = cfp yset['fitparam'] = cfp
yset['fitpts'] = func_2pl(np.array(xdat), *cfp[0]) yset['fitpts'] = func_2pl(np.array(xdat), *cfp[0])
...@@ -253,6 +254,8 @@ def generate_plots_for_problem(problem): ...@@ -253,6 +254,8 @@ def generate_plots_for_problem(problem):
fitx = np.linspace(xdat[0], xdat[-1], 100) fitx = np.linspace(xdat[0], xdat[-1], 100)
yset['fitx'] = fitx yset['fitx'] = fitx
yset['fity'] = func_2pl(np.array(fitx), *cfp[0]) yset['fity'] = func_2pl(np.array(fitx), *cfp[0])
except Exception as err:
log.debug('Error in psychoanalyze curve fitting: %s' % err)
dataset['grade_%d' % grade] = yset dataset['grade_%d' % grade] = yset
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment