skltemplate
.TemplateClassifier¶
-
class
skltemplate.
TemplateClassifier
(demo_param='demo')[source]¶ An example classifier which implements a 1-NN algorithm.
For more information regarding how to build your own classifier, read more in the User Guide.
- Parameters
- demo_paramstr, default=’demo’
A parameter used for demonstation of how to pass and store paramters.
- Attributes
-
__init__
(self, demo_param='demo')[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
fit
(self, X, y)[source]¶ A reference implementation of a fitting function for a classifier.
- Parameters
- Xarray-like, shape (n_samples, n_features)
The training input samples.
- yarray-like, shape (n_samples,)
The target values. An array of int.
- Returns
- selfobject
Returns self.
-
get_params
(self, deep=True)¶ Get parameters for this estimator.
- Parameters
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
- paramsmapping of string to any
Parameter names mapped to their values.
-
predict
(self, X)[source]¶ A reference implementation of a prediction for a classifier.
- Parameters
- Xarray-like, shape (n_samples, n_features)
The input samples.
- Returns
- yndarray, shape (n_samples,)
The label for each sample is the label of the closest sample seen during fit.
-
score
(self, X, y, sample_weight=None)¶ Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
- Parameters
- Xarray-like of shape (n_samples, n_features)
Test samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs)
True labels for X.
- sample_weightarray-like of shape (n_samples,), default=None
Sample weights.
- Returns
- scorefloat
Mean accuracy of self.predict(X) wrt. y.
-
set_params
(self, **params)¶ Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
- **paramsdict
Estimator parameters.
- Returns
- selfobject
Estimator instance.