Closed RogerRuben closed 4 months ago
LinAlgError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_17280\3317559320.py in ----> 1 mgtwr=MGTWR(g_coords, g_t, g_X, g_y, selector, kernel='gaussian', fixed=True).fit()
D:\anaconda\lib\site-packages\mgtwr\model.py in fit(self, n_chunks, skip_calculate) 691 self.n_chunks = n_chunks 692 result = map(self._chunk_compute, (range(n_chunks))) --> 693 result_list = list(zip(*result)) 694 ENP_j = np.sum(np.array(result_list[0]), axis=0) 695 CCT = np.sum(np.array(result_list[1]), axis=0)
D:\anaconda\lib\site-packages\mgtwr\model.py in _chunk_compute(self, chunk_id) 643 wi = self._build_wi(i, self.bw, self.tau).reshape(-1, 1) 644 xT = (self.X wi).T --> 645 P = np.linalg.solve(xT.dot(self.X), xT).dot(init_pR).T 646 pR[i, :, :] = P self.X[i] 647
D:\anaconda\lib\site-packages\numpy\core\overrides.py in solve(*args, **kwargs)
D:\anaconda\lib\site-packages\numpy\linalg\linalg.py in solve(a, b) 384 signature = 'DD->D' if isComplexType(t) else 'dd->d' 385 extobj = get_linalg_error_extobj(_raise_linalgerror_singular) --> 386 r = gufunc(a, b, signature=signature, extobj=extobj) 387 388 return wrap(r.astype(result_t, copy=False))
D:\anaconda\lib\site-packages\numpy\linalg\linalg.py in _raise_linalgerror_singular(err, flag) 87 88 def _raise_linalgerror_singular(err, flag): ---> 89 raise LinAlgError("Singular matrix") 90 91 def _raise_linalgerror_nonposdef(err, flag):
LinAlgError: Singular matrix
参考一下这个issue呢?https://github.com/sunkun1997/mgtwr/issues/15#issuecomment-1960931093
孙老师您好,我在使用mgtwr模型时遇到了以下报错,用的数据在GTWR和MGWR上都是可以正常跑出结果,想请教下是哪里出现了问题
LinAlgError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_17280\3317559320.py in
----> 1 mgtwr=MGTWR(g_coords, g_t, g_X, g_y, selector, kernel='gaussian', fixed=True).fit()
D:\anaconda\lib\site-packages\mgtwr\model.py in fit(self, n_chunks, skip_calculate) 691 self.n_chunks = n_chunks 692 result = map(self._chunk_compute, (range(n_chunks))) --> 693 result_list = list(zip(*result)) 694 ENP_j = np.sum(np.array(result_list[0]), axis=0) 695 CCT = np.sum(np.array(result_list[1]), axis=0)
D:\anaconda\lib\site-packages\mgtwr\model.py in _chunk_compute(self, chunk_id) 643 wi = self._build_wi(i, self.bw, self.tau).reshape(-1, 1) 644 xT = (self.X wi).T --> 645 P = np.linalg.solve(xT.dot(self.X), xT).dot(init_pR).T 646 pR[i, :, :] = P self.X[i] 647
D:\anaconda\lib\site-packages\numpy\core\overrides.py in solve(*args, **kwargs)
D:\anaconda\lib\site-packages\numpy\linalg\linalg.py in solve(a, b) 384 signature = 'DD->D' if isComplexType(t) else 'dd->d' 385 extobj = get_linalg_error_extobj(_raise_linalgerror_singular) --> 386 r = gufunc(a, b, signature=signature, extobj=extobj) 387 388 return wrap(r.astype(result_t, copy=False))
D:\anaconda\lib\site-packages\numpy\linalg\linalg.py in _raise_linalgerror_singular(err, flag) 87 88 def _raise_linalgerror_singular(err, flag): ---> 89 raise LinAlgError("Singular matrix") 90 91 def _raise_linalgerror_nonposdef(err, flag):
LinAlgError: Singular matrix