Skip to content

free variable 'gfk' referenced before assignment in enclosing scope #14

@abhiramsingh0

Description

@abhiramsingh0

NameError Traceback (most recent call last)
in ()
----> 1 calAcc()

in calAcc()
24
25 rvcObj = RVC()
---> 26 rvcFit = rvcObj.fit(featuresTrain, y_real[trainI])

/home/gnl/TF/local/lib/python2.7/site-packages/skrvm/rvm.pyc in fit(self, X, y)
281 self.multi_ = None
282 self.multi_ = OneVsOneClassifier(self)
--> 283 self.multi_.fit(X, y)
284 return self
285

/home/gnl/TF/local/lib/python2.7/site-packages/sklearn/multiclass.pyc in fit(self, X, y)
502 delayed(fit_ovo_binary)
503 (self.estimator, X, y, self.classes
[i], self.classes_[j])
--> 504 for i in range(n_classes) for j in range(i + 1, n_classes)))))
505
506 self.estimators_ = estimators_indices[0]

/home/gnl/TF/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in call(self, iterable)
777 # was dispatched. In particular this covers the edge
778 # case of Parallel used with an exhausted iterator.
--> 779 while self.dispatch_one_batch(iterator):
780 self._iterating = True
781 else:

/home/gnl/TF/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in dispatch_one_batch(self, iterator)
623 return False
624 else:
--> 625 self._dispatch(tasks)
626 return True
627

/home/gnl/TF/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in _dispatch(self, batch)
586 dispatch_timestamp = time.time()
587 cb = BatchCompletionCallBack(dispatch_timestamp, len(batch), self)
--> 588 job = self._backend.apply_async(batch, callback=cb)
589 self._jobs.append(job)
590

/home/gnl/TF/local/lib/python2.7/site-packages/sklearn/externals/joblib/_parallel_backends.pyc in apply_async(self, func, callback)
109 def apply_async(self, func, callback=None):
110 """Schedule a func to be run"""
--> 111 result = ImmediateResult(func)
112 if callback:
113 callback(result)

/home/gnl/TF/local/lib/python2.7/site-packages/sklearn/externals/joblib/_parallel_backends.pyc in init(self, batch)
330 # Don't delay the application, to avoid keeping the input
331 # arguments in memory
--> 332 self.results = batch()
333
334 def get(self):

/home/gnl/TF/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in call(self)
129
130 def call(self):
--> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items]
132
133 def len(self):

/home/gnl/TF/local/lib/python2.7/site-packages/sklearn/multiclass.pyc in _fit_ovo_binary(estimator, X, y, i, j)
421 return _fit_binary(estimator,
422 _safe_split(estimator, X, None, indices=indcond)[0],
--> 423 y_binary, classes=[i, j]), indcond
424
425

/home/gnl/TF/local/lib/python2.7/site-packages/sklearn/multiclass.pyc in _fit_binary(estimator, X, y, classes)
78 else:
79 estimator = clone(estimator)
---> 80 estimator.fit(X, y)
81 return estimator
82

/home/gnl/TF/local/lib/python2.7/site-packages/skrvm/rvm.pyc in fit(self, X, y)
277 self.t = np.zeros(y.shape)
278 self.t[y == self.classes_[1]] = 1
--> 279 return super(RVC, self).fit(X, self.t)
280 else:
281 self.multi_ = None

/home/gnl/TF/local/lib/python2.7/site-packages/skrvm/rvm.pyc in fit(self, X, y)
148
149 for i in range(self.n_iter):
--> 150 self.posterior()
151
152 self.gamma = 1 - self.alpha
*np.diag(self.sigma_)

/home/gnl/TF/local/lib/python2.7/site-packages/skrvm/rvm.pyc in _posterior(self)
258 jac=True,
259 options={
--> 260 'maxiter': self.n_iter_posterior
261 }
262 )

/home/gnl/TF/local/lib/python2.7/site-packages/scipy/optimize/_minimize.pyc in minimize(fun, x0, args, method, jac, hess, hessp, bounds, constraints, tol, callback, options)
482 elif meth == 'newton-cg':
483 return _minimize_newtoncg(fun, x0, args, jac, hess, hessp, callback,
--> 484 **options)
485 elif meth == 'l-bfgs-b':
486 return _minimize_lbfgsb(fun, x0, args, jac, bounds,

/home/gnl/TF/local/lib/python2.7/site-packages/scipy/optimize/optimize.pyc in _minimize_newtoncg(fun, x0, args, jac, hess, hessp, callback, xtol, eps, maxiter, disp, return_all, **unknown_options)
1597 msg = ("Warning: CG iterations didn't converge. The Hessian is not "
1598 "positive definite.")
-> 1599 return terminate(3, msg)
1600
1601 pk = xsupi # search direction is solution to system.

/home/gnl/TF/local/lib/python2.7/site-packages/scipy/optimize/optimize.pyc in terminate(warnflag, msg)
1517 print(" Hessian evaluations: %d" % hcalls)
1518 fval = old_fval
-> 1519 result = OptimizeResult(fun=fval, jac=gfk, nfev=fcalls[0],
1520 njev=gcalls[0], nhev=hcalls, status=warnflag,
1521 success=(warnflag == 0), message=msg, x=xk,

NameError: free variable 'gfk' referenced before assignment in enclosing scope.

Please fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions