make psychometrics curve fitting more robust
This commit is contained in:
@@ -246,13 +246,16 @@ 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
|
||||||
cfp = curve_fit(func_2pl, xdat, ydat, [1.0, max_attempts / 2.0])
|
try:
|
||||||
yset['fitparam'] = cfp
|
cfp = curve_fit(func_2pl, xdat, ydat, [1.0, max_attempts / 2.0])
|
||||||
yset['fitpts'] = func_2pl(np.array(xdat), *cfp[0])
|
yset['fitparam'] = cfp
|
||||||
yset['fiterr'] = [yd - yf for (yd, yf) in zip(ydat, yset['fitpts'])]
|
yset['fitpts'] = func_2pl(np.array(xdat), *cfp[0])
|
||||||
fitx = np.linspace(xdat[0], xdat[-1], 100)
|
yset['fiterr'] = [yd - yf for (yd, yf) in zip(ydat, yset['fitpts'])]
|
||||||
yset['fitx'] = fitx
|
fitx = np.linspace(xdat[0], xdat[-1], 100)
|
||||||
yset['fity'] = func_2pl(np.array(fitx), *cfp[0])
|
yset['fitx'] = fitx
|
||||||
|
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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user