UnboundLocalError: local variable 'fit' referenced before assignment happens due to the assignment fit['beta'] = beta on line 233 not benefiting from fit = dict() of line 217 which is out of scope. It seems that the latter statement should be moved to just after line 188.
UnboundLocalError: local variable 'fit' referenced before assignment
happens due to the assignmentfit['beta'] = beta
on line 233 not benefiting fromfit = dict()
of line 217 which is out of scope. It seems that the latter statement should be moved to just after line 188.