Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# -*- coding: utf-8 -*- 

2""" 

3@file 

4@brief Implements @see cl SkBaseRegressor. 

5""" 

6from sklearn.metrics import r2_score 

7from .sklearn_base_learner import SkBaseLearner 

8 

9 

10class SkBaseRegressor(SkBaseLearner): 

11 """ 

12 Defines a custom regressor. 

13 """ 

14 

15 def __init__(self, **kwargs): 

16 """ 

17 constructor 

18 """ 

19 SkBaseLearner.__init__(self, **kwargs) 

20 

21 def score(self, X, y=None, sample_weight=None): 

22 """ 

23 Returns the mean accuracy on the given test data and labels. 

24 

25 @param X Training data, numpy array or sparse matrix of shape [n_samples,n_features] 

26 @param y Target values, numpy array of shape [n_samples, n_targets] (optional) 

27 @param sample_weight Weight values, numpy array of shape [n_samples, n_targets] (optional) 

28 @return score : float, Mean accuracy of self.predict(X) wrt. y. 

29 """ 

30 return r2_score(y, self.predict(X), sample_weight=sample_weight)