Calculate the RMSD of fitting.
976400
def fitting_rmsd(w_fit, C_fit, r_fit, Xs):
    ''''''
    return np.sqrt(sum((geometry.point_line_distance(p, C_fit, w_fit) - r_fit) ** 2
                    for p in Xs) / len(Xs))
167683
def fit(self):
        
        # solve for estimator of B
        n,p          = np.shape(self._X)
        self._df     = float(n - p)
        self._Cx     = np.linalg.pinv(np.dot(self._X.T,self._X))
        self._Bhat   = np.dot(np.dot(self._Cx, self._X.T), self._A)
        self._Y_rec  = self._compute_prediction(self._X)
887730
def mass_3d(self, R, Rs, rho0):
        
        Rs = float(Rs)
        m_3d = 4. * np.pi * rho0 * Rs**3 *(np.log((Rs + R)/Rs) - R/(Rs + R))
        return m_3d
494788
def rmsprop(grad, x, callback=None, num_iters=100,
            step_size=0.1, gamma=0.9, eps=10**-8):
    """"""
    avg_sq_grad = np.ones(len(x))
    for i in range(num_iters):
        g = grad(x, i)
        if callback: callback(x, i, g)
        avg_sq_grad = avg_sq_grad * gamma + g**2 * (1 - gamma)
        x = x - step_size * g/(np.sqrt(avg_sq_grad) + eps)
    return x
1019421
def _at(self, t):
        """"""
        rITRF, vITRF, error = self.ITRF_position_velocity_error(t)
        rGCRS, vGCRS = ITRF_to_GCRS2(t, rITRF, vITRF)
        return rGCRS, vGCRS, rGCRS, error
887927
def calculate_rsq(self):
        
        assert hasattr(self, 'betas'), 'no betas found, please run regression before rsq'

        explained_times = self.design_matrix.sum(axis = 0) != 0

        explained_signal = self.predict_from_design_matrix(self.design_matrix)
        self.rsq = 1.0 - np.sum((explained_signal[:,explained_times] - self.resampled_signal[:,explained_times])**2, axis = -1) / np.sum(self.resampled_signal[:,explained_times].squeeze()**2, axis = -1)
        self.ssr = np.sum((explained_signal[:,explained_times] - self.resampled_signal[:,explained_times])**2, axis = -1)
        return np.squeeze(self.rsq)
873291
def compute_rmsd_by_matrix(dataframe_1, dataframe_2, use_assertion = False):
    ''' '''
    if use_assertion: assert([i for i in dataframe_1.index] == [i for i in dataframe_2.index]) # Note: this assertion creates garbage memory allocations
    num_points = dataframe_1.shape[0]
    return numpy.linalg.norm(dataframe_1 - dataframe_2) / numpy.sqrt(num_points)
434220
def rsdl(self):
        """"""

        diff = self.Xf - self.Yfprv
        return sl.rfl2norm2(diff, self.X.shape, axis=self.cri.axisN)
687079
def _dK_dR(self, R):
        """"""
        return -self._ns * self._N / R**2 / self._sin_alpha
1219720
def contrast_rms(data, *kwargs):
    
    av = np.average(data, *kwargs)
    mal = 1 / (data.shape[0] * data.shape[1])
    return np.sqrt(mal * np.sum(np.square(data - av)))
57760
def get_distance_term(self, C, rrup, mag):
        
        return (C["r1"] + C["r2"] * mag) *\
            np.log(np.sqrt(rrup ** 2. + C["h1"] ** 2.))
1102730
def _D(self, R):
        """"""
        return (0.3 * self._HNn**2 / self._sin_alpha / R
                + self._HNn + R * self._sin_alpha) / (0.3 * self._HNn + R * self._sin_alpha)
680082
def _root_mean_square_error(y, y_pred, w):
    """"""
    return np.sqrt(np.average(((y_pred - y) ** 2), weights=w))
925192
def compare(self, other, t_threshold=1e-3):
        
        return compute_rmsd(self.t, other.t) < t_threshold
256310
def rmsd_eval(rmsd_params):
    
    specification, sequence, parsed_ind, reference_pdb = rmsd_params
    model = specification(*parsed_ind)
    model.pack_new_sequences(sequence)
    ca, bb, aa = run_profit(model.pdb, reference_pdb, path1=False, path2=False)
    return bb
1032425
def fit_transform(self, X, y, step_size=0.1, init_weights=None, warm_start=False):
        """"""
        self.fit(X=X, y=y, step_size=step_size, init_weights=init_weights, warm_start=warm_start)

        return self.transform(X=X)
744517
def fit(self, X, y):
        """"""

        self._data = X
        self._classes = np.unique(y)
        self._labels = y
        self._is_fitted = True