Giter Site home page Giter Site logo

simonschoelly / graphkernels.jl Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 65 KB

A Julia package for kernel functions on graphs

License: MIT License

Julia 100.00%
machine-learning graph-kernels kernels kernel-functions julia graph-classification graph-similarity hacktoberfest

graphkernels.jl's Introduction

GraphKernels.jl

A Julia package for calculating graph kernels - kernel functions where the inputs are graphs.

Example

julia> using GraphKernels: ShortestPathGraphKernel, svmtrain, svmpredict

julia> using GraphDatasets: loadgraphs, TUDatasets
julia> using SimpleValueGraphs: get_graphval
julia> using Random: shuffle
julia> using Statistics: mean

# load the MUTAG dataset - it contains 188 graphs of two different classes
julia> graphs = loadgraphs(TUDatasets.MUTAGDataset(); resolve_categories=true)
188-element ValGraphCollection of graphs with
              eltype: Int8
  vertex value types: (chem = String,)
    edge value types: (bond_type = String,)
   graph value types: (class = Int8,)

# shuffle the graphs and split into train and test data
julia> graphs = shuffle(graphs);
julia> X_train, X_test = graphs[begin:120], graphs[121:end];
julia> y_train, y_test = get_graphval.(X_train, :class), get_graphval.(X_test, :class);

# instantiate a ShortestPathGraphKernel
# dist_key is set to nothing so that we use unit distances for all edges
julia> kernel = ShortestPathGraphKernel(;dist_key=nothing)
ShortestPathGraphKernel{ConstVertexKernel}(0.0, ConstVertexKernel(1.0), nothing)

# train a support vector machine with that kernel
julia> model = svmtrain(X_train, y_train, kernel);

# predict classe on the test data
julia> y_test_pred = svmpredict(model, X_test);

# compare with the actual classes and calculate the accuracy
julia> accuracy = mean(y_test .== y_test_pred)
0.8529411764705882

Alternatives

Graph Kernels

Python

  • GraKeL, A scikit-learn compatible library for graph kernels
  • graphkit-learn, A Python package for graph kernels, graph edit distances and graph pre-image problem.

General graph machine learning

Julia

Python

  • StellarGraph, Machine Learning on Graphs
  • DGL, Python package built to ease deep learning on graph, on top of existing DL frameworks.
  • Graph Nets, Build Graph Nets in Tensorflow
  • Spektral, Graph Neural Networks with Keras and Tensorflow 2.
  • PyTorch Geometric, Geometric Deep Learning Extension Library for PyTorch

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.