Source code for mlinsights.sklapi.sklearn_base_learner
from.sklearn_baseimportSkBase
[docs]classSkBaseLearner(SkBase):""" Pattern of a *learner* qui suit la même API que :epkg:`scikit-learn`. """def__init__(self,**kwargs):""" constructor """SkBase.__init__(self,**kwargs)#################### API scikit-learn###################
[docs]deffit(self,X,y=None,sample_weight=None):""" Trains a model. @param X features @param y targets @param sample_weight weight @return self """raiseNotImplementedError()
[docs]defpredict(self,X):""" Predicts. @param X features @return prédictions """raiseNotImplementedError()
[docs]defdecision_function(self,X):""" Output of the model in case of a regressor, matrix with a score for each class and each sample for a classifier. :param X: Samples, {array-like, sparse matrix}, shape = (n_samples, n_features) :return: array, shape = (n_samples,.), Returns predicted values. """raiseNotImplementedError()
[docs]defscore(self,X,y=None,sample_weight=None):""" Returns the mean accuracy on the given test data and labels. :param X: Training data, numpy array or sparse matrix of shape [n_samples,n_features] :param y: Target values, numpy array of shape [n_samples, n_targets] (optional) :param sample_weight: Weight values, numpy array of shape [n_samples, n_targets] (optional) :return: score : float, Mean accuracy of self.predict(X) wrt. y. """raiseNotImplementedError()