{"id":13806767,"url":"https://github.com/ExpectationMax/sklearn-jax-kernels","last_synced_at":"2025-05-13T22:30:49.890Z","repository":{"id":57468078,"uuid":"246383857","full_name":"ExpectationMax/sklearn-jax-kernels","owner":"ExpectationMax","description":"Composable kernels for scikit-learn implemented in JAX.","archived":false,"fork":false,"pushed_at":"2020-10-26T20:36:35.000Z","size":98,"stargazers_count":43,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-25T19:49:10.024Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ExpectationMax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-10T18:59:36.000Z","updated_at":"2025-03-04T15:32:40.000Z","dependencies_parsed_at":"2022-09-19T08:51:48.109Z","dependency_job_id":null,"html_url":"https://github.com/ExpectationMax/sklearn-jax-kernels","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpectationMax%2Fsklearn-jax-kernels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpectationMax%2Fsklearn-jax-kernels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpectationMax%2Fsklearn-jax-kernels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpectationMax%2Fsklearn-jax-kernels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ExpectationMax","download_url":"https://codeload.github.com/ExpectationMax/sklearn-jax-kernels/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036812,"owners_count":22003655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T01:01:15.878Z","updated_at":"2025-05-13T22:30:49.527Z","avatar_url":"https://github.com/ExpectationMax.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["New Libraries","Inactive Libraries"],"readme":"# sklearn-jax-kernels\n\n[![PyPI version](https://badge.fury.io/py/sklearn-jax-kernels.svg)](https://badge.fury.io/py/sklearn-jax-kernels) [![Build Status](https://travis-ci.com/ExpectationMax/sklearn-jax-kernels.svg?token=3sUUnmMzs9wxN3Qapssj\u0026branch=master)](https://travis-ci.com/ExpectationMax/sklearn-jax-kernels) [![Downloads](https://pepy.tech/badge/sklearn-jax-kernels)](https://pepy.tech/project/sklearn-jax-kernels)\n\n**Warning: This project is still in an early stage it could be that the API\nwill change in the future. Further, functionality is still quite limited to the\nuse cases which defined the creation of the project (application to DNA\nsequences present in Biology).**\n\n## Why?\nEver wanted to run a kernel-based model from\n[scikit-learn](https://scikit-learn.org/) on a relatively large dataset?  If so\nyou will have noticed, that this can take extraordinarily long and require huge\namounts of memory, especially if you are using compositions of kernels (such as\nfor example `k1 * k2 + k3`).  This is due to the way Kernels are computed in\nscikit-learn: For each kernel, the complete kernel matrix is computed, and the\ncompositions are then computed from the kernel matrices.  Further,\n`scikit-learn` does not rely on an automatic differentiation framework for the\ncomputation of gradients though kernel operations.\n\n## Introduction\n\n`sklearn-jax-kernels` was designed to circumvent these issues:\n\n - The utilization of [JAX](https://github.com/google/jax) allows accelerating\n   kernel computations through [XLA](https://www.tensorflow.org/xla)\n   optimizations, computation on GPUs and simplifies the computation of\n   gradients though kernels\n - The composition of kernels takes place on a per-element basis, such that\n   unnecessary copies can be optimized away by JAX compilation\n\nThe goal of `sklearn-jax-kernels` is to provide the same flexibility and ease\nof use as known from `scikit-learn` kernels while improving speed and allowing\nthe faster design of new kernels through Automatic Differentiation.\n\nThe kernels in this package follow the [scikit-learn kernel\nAPI](https://scikit-learn.org/stable/modules/gaussian_process.html#gaussian-process-kernel-api).\n\n## Installation\n\n`sklearn-jax-kernels` can simply be installed via `pip`:\n\n```bash\npip install sklearn-jax-kernels\n```\n\n## Quickstart\n\nA short demonstration of how the kernels can be used, inspired by the\n[scikit-learn\ndocumentation](https://scikit-learn.org/stable/auto_examples/gaussian_process/plot_gpc_iris.html).\n\n```python\nfrom sklearn import datasets\nimport jax.numpy as jnp\nfrom sklearn_jax_kernels import RBF, GaussianProcessClassifier\n\niris = datasets.load_iris()\nX = jnp.asarray(iris.data)\ny = jnp.array(iris.target, dtype=int)\n\nkernel = 1. + RBF(length_scale=1.0)\ngpc = GaussianProcessClassifier(kernel=kernel).fit(X, y)\n```\n\nHere a further example demonstrating how kernels can be combined:\n\n```python\nfrom sklearn_jax_kernels.base_kernels import RBF, NormalizedKernel\nfrom sklearn_jax_kernels.structured.strings import SpectrumKernel\n\nmy_kernel = RBF(1.) * SpectrumKernel(n_gram_length=3)\nmy_kernel_2 = RBF(1.) + RBF(2.)\nmy_kernel_2 = NormalizedKernel(my_kernel_2)\n```\n\nSome further inspiration can be taken from the tests in the subfolder `tests`.\n\n## Implemented Kernels\n\n - Kernel compositions ($+,-,*,/$, exponentiation)\n - Kernels for real valued data:  \n     - RBF kernel\n - Kernels for same length strings:  \n     - SpectrumKernel\n     - DistanceSpectrumKernel, SpectrumKernel with distance weight between\n       matching substrings\n     - ReverseComplement Spectrum kernel (relevant for applications in Biology\n       when working with DNA sequences)\n\n## TODOs\n\n - Implement more fundamental Kernels\n - Implement jax compatible version of GaussianProcessRegressor\n - Optimize GaussianProcessClassifier for performance\n - Run benchmarks to show benefits in speed\n - Add fake \"split\" kernel which allows to apply different kernels to different\n   parts of the input\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FExpectationMax%2Fsklearn-jax-kernels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FExpectationMax%2Fsklearn-jax-kernels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FExpectationMax%2Fsklearn-jax-kernels/lists"}