module mlmodel.classification_kmeans
#
Short summary#
module mlinsights.mlmodel.classification_kmeans
Combines a k-means followed by a predictor.
Classes#
class |
truncated documentation |
---|---|
Applies a k-means (see sklearn.cluster.KMeans) for each class, then adds the distance to each cluster … |
Properties#
property |
truncated documentation |
---|---|
|
HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should … |
Methods#
method |
truncated documentation |
---|---|
Overloads repr as scikit-learn now relies on the constructor signature. |
|
Calls decision_function. |
|
Runs a k-means on each class then trains a classifier on the extended set of features. |
|
Returns the parameters for both the clustering and the classifier. |
|
Runs the predictions. |
|
Converts predictions into probabilities. |
|
Sets the parameters before training. Every parameter prefixed by |
|
Applies all the clustering objects on every observations and extends the list of features. |
Documentation#
Combines a k-means followed by a predictor.
- class mlinsights.mlmodel.classification_kmeans.ClassifierAfterKMeans(estimator=None, clus=None, **kwargs)#
Bases:
BaseEstimator
,ClassifierMixin
Applies a k-means (see sklearn.cluster.KMeans) for each class, then adds the distance to each cluster as a feature for a classifier. See notebook LogisticRegression and Clustering.
- Parameters:
estimator – sklearn.linear_model.LogisiticRegression by default
clus – clustering applied on each class, by default k-means with two classes
kwargs – sent to
set_params
, see its documentation to understand how to specify parameters
- __init__(estimator=None, clus=None, **kwargs)#
- Parameters:
estimator – sklearn.linear_model.LogisiticRegression by default
clus – clustering applied on each class, by default k-means with two classes
kwargs – sent to
set_params
, see its documentation to understand how to specify parameters
- __repr__()#
Overloads repr as scikit-learn now relies on the constructor signature.
- decision_function(X)#
Calls decision_function.
- fit(X, y, sample_weight=None)#
Runs a k-means on each class then trains a classifier on the extended set of features.
- Parameters:
X – numpy array or sparse matrix of shape [n_samples,n_features] Training data
y – numpy array of shape [n_samples, n_targets] Target values. Will be cast to X’s dtype if necessary
sample_weight – numpy array of shape [n_samples] Individual weights for each sample
- Returns:
self : returns an instance of self.
Fitting attributes: * labels_: dictionary of clustering models * clus_: array of clustering models * estimator_: trained classifier
- get_params(deep=True)#
Returns the parameters for both the clustering and the classifier.
- Parameters:
deep – unused here
- Returns:
dict
set_params
describes the pattern parameters names follow.
- predict(X)#
Runs the predictions.
- predict_proba(X)#
Converts predictions into probabilities.
- set_params(**values)#
Sets the parameters before training. Every parameter prefixed by
'e_'
is an estimator parameter, every parameter prefixed by'c_'
is for the sklearn.cluster.KMeans.- Parameters:
values – valeurs
- Returns:
dict
- transform_features(X)#
Applies all the clustering objects on every observations and extends the list of features.
- Parameters:
X – features
- Returns:
extended features