Skip to main content

Adaptive Density Variance (ADV) Kernel — a locally-adaptive hybrid RBF×Polynomial kernel for scikit-learn SVMs

Project description

ADV Kernel — Adaptive Density Variance Kernel

CI PyPI Python License: MIT

A scikit-learn compatible SVM kernel that adapts its bandwidth sample-by-sample using two complementary signals:

Signal Meaning
k-NN density Sparse neighbourhood → wider kernel
Feature variance High intra-sample heterogeneity → wider kernel

The final kernel is a pointwise product of an adaptive RBF and a polynomial term:

K(xᵢ, xⱼ) = exp(−‖xᵢ−xⱼ‖² / 2σᵢσⱼ) × (1 + β⟨xᵢ,xⱼ⟩)^degree

Installation

pip install adv-kernel

Or directly from GitHub:

pip install git+https://github.com/InquietoPartho/adv_kernel.git

Quick start

from adv_kernel import ADVKernelSVC

clf = ADVKernelSVC(C=1.0, beta=0.5, degree=2, probability=True)
clf.fit(X_train, y_train)

y_pred  = clf.predict(X_test)
y_proba = clf.predict_proba(X_test)

Use kernel functions directly

from adv_kernel import adv_bandwidth, adv_kernel

sigma = adv_bandwidth(X, k=10, gamma_density=1.0, gamma_var=0.5)
K     = adv_kernel(X, X, sigma, sigma, beta=0.5, degree=2)

scikit-learn GridSearchCV

from sklearn.model_selection import GridSearchCV
from adv_kernel import ADVKernelSVC

param_grid = {"C": [0.1, 1.0, 10.0], "beta": [0.2, 0.5], "gamma_density": [0.5, 1.0]}
gs = GridSearchCV(ADVKernelSVC(), param_grid, cv=5, n_jobs=-1)
gs.fit(X_train, y_train)
print(gs.best_params_)

API reference

adv_bandwidth(X, k=10, gamma_density=1.0, gamma_var=0.5)

Returns per-sample bandwidth array of shape (n_samples,).

adv_kernel(X, Y, sigma_X, sigma_Y, beta=0.5, degree=2)

Returns kernel matrix of shape (n_X, n_Y).

ADVKernelSVC parameters

Parameter Default Description
C 1.0 SVM regularisation
beta 0.5 Polynomial scaling
degree 2 Polynomial degree
k_bw 10 k-NN neighbours for bandwidth
gamma_density 1.0 Density term weight
gamma_var 0.5 Variance term weight
probability True Enable predict_proba

License

MIT © Pijush Kanti Roy Partho

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adv_kernel-0.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adv_kernel-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file adv_kernel-0.1.0.tar.gz.

File metadata

  • Download URL: adv_kernel-0.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for adv_kernel-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4922f97bab3bf71a058f66c42f7f1b30abd37e98e253e37191f42aab117c41d6
MD5 c573e6aef40fbf9ad6286941aeade96d
BLAKE2b-256 c474749fbb243a5ea62207dacb8da5ab2046b6c18be32910a7e930e7ff892060

See more details on using hashes here.

Provenance

The following attestation bundles were made for adv_kernel-0.1.0.tar.gz:

Publisher: ci.yml on InquietoPartho/adv_kernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adv_kernel-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: adv_kernel-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for adv_kernel-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1954a322d0b65f18ac42983ff3e0590dd08f1da4cca51e8caca83ad4b33cdd0
MD5 18ed6522a56601e78ac11fee88c498fd
BLAKE2b-256 5b235cb16a8e9b2441224eb488c666ef2126bd0a1a13d2f858216263df70f6e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for adv_kernel-0.1.0-py3-none-any.whl:

Publisher: ci.yml on InquietoPartho/adv_kernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page