Closed allosharma closed 1 year ago
Hi @allosharma ,
Thanks for your feedback. Could you please copy/paste the definition of the ClusterSimilarity
class from your notebook here? It should contain a get_feature_names_out()
method. The error message says that it doesn't, but it's supposed to. If you read page 82 in the book, or look at cell [100] in the notebook, you should see it.
Perhaps there's a typo in your notebook?
Hope this helps.
Hi @allosharma ,
Thanks for your feedback. Could you please copy/paste the definition of the
ClusterSimilarity
class from your notebook here? It should contain aget_feature_names_out()
method. The error message says that it doesn't, but it's supposed to. If you read page 82 in the book, or look at cell [100] in the notebook, you should see it. Perhaps there's a typo in your notebook? Hope this helps.
Hi @ageron , Thank you so much for the response, yes I got the typo. while defining the method I had a typo.
class ClusterSimilarity(BaseEstimator, TransformerMixin):
def __init__(self, n_clusters=10, gamma=1.0, random_state=None):
self.n_clusters = n_clusters
self.gamma = gamma
self.random_state = random_state
def fit(self, X, y=None, sample_weight=None):
self.kmeans_ = KMeans(self.n_clusters, random_state=self.random_state)
self.kmeans_.fit(X, sample_weight=sample_weight)
return self #always return self
def transform(self, X):
return rbf_kernel(X, self.kmeans_.cluster_centers_, gamma=self.gamma)
def get_features_names_out(self, names=None):
return [f"Cluster {i} similarity" for i in range(self.n_clusters)]
It should have been a feature instead of features.
Describe the bug The issue occurs while creating the final preprocessing pipeline before Select and Train a Model topic. Expected output of preprocessing.get_feature_names_out() should be the list of all the features in the preprocessing pipeline, but instead, I get an AttributeError: Transformer geo (type ClusterSimilarity) does not provide get_feature_names_out.
To Reproduce
And if you got an exception, please copy the full stacktrace here:
Expected behavior It should list of the names of all the features in the pipeline.
Versions (please complete the following information):