Code Monkey home page Code Monkey logo

Comments (2)

ageron avatar ageron commented on May 22, 2024

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.

from handson-ml3.

allosharma avatar allosharma commented on May 22, 2024

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 @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.

from handson-ml3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.