-
-
Save mrgloom/d0d4a4b62ad559b0caf1 to your computer and use it in GitHub Desktop.
k-means feature mapper for scikit-learn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.base import BaseEstimator, TransformerMixin | |
from sklearn.metrics.pairwise import rbf_kernel | |
class KMeansTransformer(BaseEstimator, TransformerMixin): | |
def __init__(self, centroids): | |
self.centroids = centroids | |
def fit(self, X, y=None): | |
return self | |
def transform(self, X, y=None): | |
return rbf_kernel(X, self.centroids) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment