I have a function findMaxEval which I invoke in a following way: eMax0,var0=findMaxEval(np.diag(eVal0),q,bWidth=.01) where np.diag(eVal0) is an ndarray of shape (1000,), q is a number (10). findMaxEval has the following definition: def findMaxEval(eVal,q,bWidth): out=minimize(lambda *x:errPDFs(*x),.5,args= (eVal,q,bWidth),bounds=((1E-5,1-1E-5),)) if out[‘success’]:var=out[‘x’][0] else:var=1 eMax=var*(1+(1./q)**.5)**2 return eMax,var This funtion tries to minimize errPDFs which is defined as follows: def errPDFs(var,eVal,q,bWidth,pts=1000): […]

Categories

## Python Exception: Data must be 1-dimensional

- Post author By Full Stack
- Post date June 30, 2020
- No Comments on Python Exception: Data must be 1-dimensional

- Tags -1/1e-5, :eval, 'copy', 'dtype':, 'MaxIter', "constraints", ("WA", ), ). I looked at all the other similar questions, )) 4 if out['success']:var=out['x'][0] 5 else:var=1 /opt/anaconda3/lib/python3.7/site-packages/scipy/optimize/_minimize., )) 4 if out['success']:var=out['x'][0] 5 else:var=1 in errPDFs(var, )) if out['success']:var=out['x'][0] else:var=1 eMax=var*(1+(1./q)**.5)**2 return eMax, **options) /opt/anaconda3/lib/python3.7/site-packages/scipy/optimize/lbfgsb.py in _minimize_lbfgsb(fun, **options) 599 elif meth == 'powell': --> 600 return _minimize_powell(fun, **options) 601 elif meth == 'cg': 602 return _minimize_cg(fun, **unknown_options) 333 334 while 1: --> 335 # x, *args, /opt/anaconda3/lib/python3.7/site-packages/scipy/optimize/lbfgsb.py in func_and_grad(x) 278 # unbounded variables must use None, 1) if len(x.shape)==1:x=x.reshape(-1, 1) kde=KernelDensity(kernel=kernel, 1) logProb=kde.score_samples(x) # log(density) pdf=pd.Series(np.exp(logProb), 337 pgtol, 5, args= (eVal, b(width), bandwidth=bWidth).fit(obs) if x is None:x=np.unique(obs).reshape(-1, bounds, bounds=((1E-5, but none seems to help me solve this. Thanks., bWidth) 1 def findMaxEval(eVal, bWidth): 2 # Find max random eVal by fitting Marcenko’s dist ----> 3 out=minimize(lambda *x:errPDFs(*x), bWidth): out=minimize(lambda *x:errPDFs(*x), bWidth=.01) 2 nFacts0=eVal0.shape[0]-np.diag(eVal0)[::-1].searchsorted(eMax0) in findMaxEval(eVal, bWidth=.01) where np.diag(eVal0) is an ndarray of shape (1000, bWidth=.25, callBack, csave, data); }, disp, dsave = \ 336 _lbfgsb.setulb(m, dtype=None): --> 314 """ 315 Derive the "_data" and "index" attributes of a new Series from a 316 dictionary, eMax, eMax=var*(1-(1./q)**.5)**2, EPS, f: '' }, factr, fastpath) 312 313 def _init_dict(self, for optimizer to work properly 279 bounds = [(None if l == -np.inf else l, ftol, g, gtol, hess, hessp, I get the following error: --------------------------------------------------------------------------- Exception, I have a function findMaxEval which I invoke in a following way: eMax0, index, index=eVal) 13 return pdf /opt/anaconda3/lib/python3.7/site-packages/pandas/core/series.py in __init__(self, index=eVal) return pdf def fitKDE(obs, index=None), index=x.flatten()) return pdf When I invoke findMaxEval (first line in the description), initial value is 0.5. Further, iprint, isave, iwa, Jac, kernel='gaussian', low_bnd, lsave, maxcor, maxfun, maxls, method, mpPDF and fitKDE are defined: def mpPDF(var, Name, nbd, None if u == np.inf else u) for l, not +-inf, options) 598 return _minimize_neldermead(fun, pts) # theoretical pdf 4 pdf1=fitKDE(eVal, pts) 1 def errPDFs(var, pts) 10 eVal=np.linspace(eMin, pts) 11 pdf=q/(2*np.pi*var*eVal)*((eMax-eVal)*(eVal-eMin))**.5 ---> 12 pdf=pd.Series(pdf, pts) pdf=q/(2*np.pi*var*eVal)*((eMax-eVal)*(eVal-eMin))**.5 pdf=pd.Series(pdf, pts) pdf1=fitKDE(eVal, pts): eMin, pts=1000): 2 # Fit error ----> 3 pdf0=mpPDF(var, pts=1000): pdf0=mpPDF(var, Q, q is a number (10). findMaxEval has the following definition: def findMaxEval(eVal, raise_cast_failure) Exception: Data must be 1-dimensional I don't understand what should be 1-Dimensional. np.diag(eVal0) is of shape (1000, task, TOL, u in bounds] --> 280 281 if disp is not None: 282 if disp == 0: /opt/anaconda3/lib/python3.7/site-packages/scipy/optimi, upper_bnd, var This funtion tries to minimize errPDFs which is defined as follows: def errPDFs(var, var*(1+(1./q)**.5)**2 eVal=np.linspace(eMin, var0=findMaxEval(np.diag(eVal0), X, x=None): if len(obs.shape)==1:obs=obs.reshape(-1, x=pdf0.index.values) # empirical pdf 5 sse=np.sum((pdf1-pdf0)**2) in mpPDF(var, x=pdf0.index.values) sse=np.sum((pdf1-pdf0)**2) return sse var is a number which I pass in the findMaxEval function in minimize, x0