Skip to main content

Kerch

PyPI version PyPi downloads License: LGPL-3.0 Documentation Status Size of the repository Total number of commits

Kerch is a Python package meant for various kernel methods, and in particular Deep Restricted Kernel Machines. You can natively perform SVMs, LS-SVMs, (K)PCA with various kernels, automatic centering, out-of-sample, etc.

The package is built upon PyTorch and supports GPU acceleration.

Examples

Training and plotting an LS-SVM

This is done by first instantiating a model, setting its dataset, searching for the hyperparameters, fitting with those parameters and plotting. The implementation can be found here.

import kerch                                        # importation is fast as the modules are only loaded when called
mdl = kerch.model.LSSVM(type="rbf",                 # kernel name
                     representation="dual")         # initiate model
mdl.set_data_prop(data=data,                        # value
                  labels=labels,                    # corresponding labels
                  proportions=[1, 0, 0])            # initiate data
mdl.hyperopt({"gamma", "sigma"},                    # define which parameters to tune
             max_evals=500,                         # define how many trials
             k=10)                                  # 10-fold cross-validation
mdl.fit()                                           # fit the optimal parameters found
kerch.plot.plot_model(mdl)                          # plot the model using the built-in method

The final fitted LS-SVM

Out-of-sample kernels with normalization and centering

The factory class alows for the fast instantiation of various implemented kernels. Centering and normalization are options to choose from and the out-of-sample will also satisfy these properties, based on statistics relative ti the sample. You can easily use numpy arrays ore even python builtins such as range(). An implementation can be found here

sample = np.sin(np.arange(0, 15) / np.pi) + .1
oos = np.sin(np.arange(15, 30) / np.pi) + .1

k = kerch.kernel.factory(type="polynomial", sample=sample, center=True, normalize=True)

k.K  # = k1.k1()
k.k1(y=oos)
k.k1(x=oos)
k.k1(x=oos, y=oos)

A centered and normalized kernel with out-of-sample parts

Installation

As for now, there are two ways to install the package.

PIP

Using pip, it suffices to run pip install kerch. Just rerun this command with the suffix --upgrade to upgrade the package to its newest version.

From source

You can also install the package directly from the GitHub repository.

git clone --recursive https://github.com/hdeplaen/kerch
cd kerch
pip install -e .

Resources

  • Documentation
  • E-DUALITY: ERC Adv. Grant website.
  • ESAT-STADIUS: KU Leuven, Department of Electrical Engineering (ESAT), STADIUS Center for Dynamical Systems, Signal Processing and Data Analytics.

Contributors

The contributors and acknowledgements can be found in the CONRIBUTORS file.

License

Kerch has a LGPL-3.0 license, as found in the LICENSE file.

Metadata

Release files for kerch 0.3.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kerch 0.3.1.5
File Size Uploaded
kerch-0.3.1.5.tar.gz 21.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kerch 0.3.1.5
File Interpreter ABI Platform
kerch-0.3.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 41.0 kB

Release files / kerch-0.3.1.5.tar.gz

Download URL kerch-0.3.1.5.tar.gz
Size 21.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f1de828c536d9918384edc14ad62f2491cf179bbd27daff0de1a99149136f64f
BLAKE2b-256 checksum
How to use checksums
570d51be35fbdb262c70ef3f607e8d826787aee74e18daa4b315dbe0b3ff1227
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / kerch-0.3.1.5-py3-none-any.whl

Download URL kerch-0.3.1.5-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8b3dfd37fb41c0925a644cb3c9d11cd3f904207e0ebe8ecf59f594ea8b8f796
BLAKE2b-256 checksum
How to use checksums
6bb462e4ed222a2e7117bdb476c01b14f2ccf2a64045e61fe27304747ee50d5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.3.1.5 This release

2 release files

0.3.1

2 release files

0.2.2

2 release files

0.2.1

3 release files

0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page