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 class @see cl SkBaseClassifier.
5"""
6from sklearn.metrics import accuracy_score
7from .sklearn_base_learner import SkBaseLearner
10class SkBaseClassifier(SkBaseLearner):
11 """
12 Defines a custom classifier.
13 """
15 def __init__(self, **kwargs):
16 """
17 constructor
18 """
19 SkBaseLearner.__init__(self, **kwargs)
21 def score(self, X, y=None, sample_weight=None):
22 """
23 Returns the mean accuracy on the given test data and labels.
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 accuracy_score(y, self.predict(X), sample_weight=sample_weight)
32 def predict_proba(self, X):
33 """
34 Returns probability estimates for the test data X.
36 @param X Training data, numpy array or sparse matrix of shape [n_samples,n_features]
37 @return array, shape = (n_samples,.), Returns predicted values.
38 """
39 raise NotImplementedError()