def rho(self, points):
""" Solves the goodness of fit.
"""
assert self._solved, 'you need to solve first.'
m, n = self.A.shape
projections = self.optimal_points(points)
_pts = [np.mat(pt).T for pt in points]
numer = [
np.linalg.norm(pj - pt, self.p)
for pj, pt in zip(projections, _pts)
]
numer = sum(numer)
denom = 0
for i in range(m):
ai = self.A[i]
bi = self.b[i]
result = self._project_to_hyperplane(points, ai, bi)
denom += result
rho = 1 - numer / denom
return rho
评论列表
文章目录