示例#1
0
文件: prm.py 项目: amarvin/sprm
 def valscore(self, Xn, yn, scoring):
     if scoring == 'weighted':
         return (RegressorMixin.score(self,
                                      Xn,
                                      yn,
                                      sample_weight=self.caseweights_))
     elif scoring == 'normal':
         return (RegressorMixin.score(self, Xn, yn))
     else:
         ValueError('Scoring flag must be set to "weighted" or "normal".')
示例#2
0
 def valscore(self,Xn,yn,scoring):
     n,p,Xn = _predict_check_input(Xn)
     (n,p) = Xn.shape
     if p!= self.X.shape[1]:
         raise(ValueError('New data must have seame number of columns as the ones the model has been trained with'))
     if scoring=='weighted':
         return(RegressorMixin.score(self,Xn,yn,sample_weight=self.caseweights_))
     elif scoring=='normal':
         return(RegressorMixin.score(self,Xn,yn))
     else:
         raise(ValueError('Scoring flag must be set to "weighted" or "normal".'))
示例#3
0
 def valscore(self,Xn,yn,scoring):
     if type(Xn) == ps.core.frame.DataFrame:
         Xn = Xn.to_numpy()
     if type(yn) in [ps.core.frame.DataFrame,ps.core.series.Series]:
         yn = yn.to_numpy().T.astype('float64')
     (n,p) = Xn.shape
     if p!= self.X.shape[1]:
         raise(ValueError('New data must have seame number of columns as the ones the model has been trained with'))
     if scoring=='weighted':
         return(RegressorMixin.score(self,Xn,yn,sample_weight=self.caseweights_))
     elif scoring=='normal':
         return(RegressorMixin.score(self,Xn,yn))
     else:
         raise(ValueError('Scoring flag must be set to "weighted" or "normal".'))
示例#4
0
    def score(self, X, y, sample_weight=None):
        if len(X) == 1:
            output = self.predict(X)
            return output.shape[0] * mean_squared_error(y, output)

        return RegressorMixin.score(self, X, y, sample_weight=sample_weight)
示例#5
0
 def score(self, X, y, sample_weight=None):
     return RegressorMixin.score(self, X, y, sample_weight=sample_weight)
示例#6
0
 def score(
     self, X: np.ndarray, y: np.ndarray, sample_weight: Optional[np.ndarray] = None
 ) -> float:
     return RegressorMixin.score(self, X, y, sample_weight)