Code Monkey home page Code Monkey logo

Comments (1)

giannisnik avatar giannisnik commented on June 7, 2024

Hi @LittleWhite-Hai ,

For some kernels where the mapping to the feature space is explicit, you can indeed obtain such features. For instance, for the Weisfeiler-Lehman subtree kernel, you can obtain the features for the different iterations as follows:

from grakel.datasets import fetch_dataset
from grakel.kernels import WeisfeilerLehman, VertexHistogram

dataset = fetch_dataset("MUTAG", verbose=False)
Gs = dataset.data
wl_kernel = WeisfeilerLehman(n_iter=3,  base_graph_kernel=VertexHistogram)
wl_kernel.fit(Gs)
features_it_0 = wl_kernel.X[0].X
features_it_1 = wl_kernel.X[1].X
features_it_2 = wl_kernel.X[2].X
features_it_3 = wl_kernel.X[3].X

In this example, features_it_0, features_it_1, features_it_2, features_it_3 are all sparse matrices where the number of rows is equal to the number of graphs (i.e., len(Gs)) and the number of columns is equal to the number of different labels assigned to the nodes of all graphs at that iteration.

from grakel.

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.