Skip to main content

Sinc Kernel Function

Project description

Sinc Kernel Function (SKF)

Implementation of: "The Periodic Sinc Kernel: Theoretical Design and Applications in Machine Learning and Scientific Computing" Link to Paper


🔧 Overview

This repository provides a Python package implementing the propoesed kernel function described in the paper. The package can be installed via pip:

pip install sinc

🧪 Usage

SKF for SVMs

Use sinc.SKF as the kernel function for solving classification/regression tasks.

from sinc import SKF
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42
)

model = SVC(kernel=SKF(sigma=0.1))
model.fit(X_train, y_train)
score = model.score(X_test, y_test)
print(f"Test accuracy: {score:.2f}")

Nystroem Kernel Approximation

Use sinc.NystroemSKF to approximate the kernel function using a subset of training data.

from sinc import NystroemSKF
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.svm import SVC

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42
)

pipeline = make_pipeline(NystroemSKF(sigma=0.1, random_state=42), SVC(kernel="linear"))

pipeline.fit(X_train, y_train)
score = pipeline.score(X_test, y_test)
print(f"Test accuracy: {score:.2f}")

Solving ODEs

Use sinc.SincODE to solve linear boundary value Ordinary Differential Equations (ODEs). As an example consider the following linear boundary value problem:

$$ -u''(x) + 2 u(x) = e^{-x^2}\left[\left(8-4x^2\right)\sin\left(2x\right) + 8x\cos\left(2x\right)\right] $$

This problem is set on the entire real line, i.e. $(-\infty, \infty)$, with boundary conditions $u(\pm \infty) = 0$, and its solution exhibits both periodic behavior and decay to zero at infinity.

from sinc import SincODE
import numpy as np

f = lambda x: np.exp(-(x**2)) * ((8 - 4 * x**2) * np.sin(2 * x) + 8 * x * np.cos(2 * x))

ode = lambda D, x: -D[2] + 2 * D[0]
solver = SincODE(ode, f, kernel_mode=False)
solver.solve(n=40, sigma=10)

x = np.linspace(-100, 100, 500)
y_pred = solver.predict(x)
y_ex = np.exp(-(x**2)) * np.sin(2 * x)
np.abs(y_ex - y_pred).mean()

📚 Citation

If you use this module, please cite:

@article{aghaei2025periodic,
title = {The periodic Sinc kernel: Theoretical design and applications in machine learning and scientific computing},
journal = {Applied Soft Computing},
pages = {113151},
year = {2025},
issn = {1568-4946},
doi = {https://doi.org/10.1016/j.asoc.2025.113151},
url = {https://www.sciencedirect.com/science/article/pii/S1568494625004624},
author = {Alireza Afzal Aghaei}
}

🤝 Contact

For questions or collaboration, create issue, pull request or contact:
Alireza Afzal Aghaei – [alirezaafzalaghaei@gmail.com]

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

sinc-0.1.0-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sinc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for sinc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4016c58d71331af01c17c54d5d844923ed56ba8c435d1812a89f6a11067a5069
MD5 7e0ac3bfb2ea0f5b1f463585ee2e1325
BLAKE2b-256 c7f79c88d4910eb742e2abcbcf54b7ad5ce0350260d809abd3c937439bbeb51b

See more details on using hashes here.

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