gpr.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:pmml-scoring-engine 作者: maxkferg 项目源码 文件源码
def score(self,xnew):
        """
        Generate scores for new x values
        xNew should be an array-like object where each row represents a test point
        Return the predicted mean and standard deviation [mu,s]
        @param{np.Array} xnew. An numpy array where each row corrosponds to an observation
        @output{Array} mu. A list containing predicted mean values
        @output{Array} s. A list containing predicted standard deviations
        """
        self._validate_xnew(xnew)
        #mu,sd = self.gp.predict(xnew,return_std=True)
        #return {'mu':mu.T.tolist()[0], 'sd':sd.tolist()}

        #K_trans = self.kernel(X, self.xTrain)
        #y_mean = K_trans.dot(self.alpha_)  # Line 4 (y_mean = f_star)
        #y_mean = self.y_train_mean + y_mean  # undo normal.


        # Compute variance of predictive distribution
        #y_var = self.kernel_.diag(X)
        #y_var -= np.einsum("ki,kj,ij->k", K_trans, K_trans, K_inv)

        # Check if any of the variances is negative because of
        # numerical issues. If yes: set the variance to 0.
        #y_var_negative = y_var < 0
        #if np.any(y_var_negative):
        #    warnings.warn("Predicted variances smaller than 0. "
        #                  "Setting those variances to 0.")
        #    y_var[y_var_negative] = 0.0
        #return y_mean, np.sqrt(y_var)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号