Skip to main content

A Python package that implements string kernels.

Project description

strkernels

strkernels is a Python package compatible with Scikit-learn that implements string kernels.

String kernels are functions that return a value representing how similar two input strings are. They are widely used in machine learning methods for text and biological sequence analysis.

The prominent aspect of string kernels is that the prior extraction and selection of sequence features are unnecessary. The sample symbol sequences are inputs to the kernel function, automatically finding the distinguishing string features.

Currently, the available string kernels are:

  • Locality Improved (Zien et al. 2000)
  • Subsequence (Lodhi et al. 2002)
  • Spectrum (Leslie et al. 2002)
  • Weighted Degree (Ratsch et al. 2004)
  • Fixed Degree (Sonnenburg et al. 2010)

Basic usage

Install with pip:

pip install strkernels

Import and create a kernel:

from strkernels import SubsequenceStringKernel
subsequence_kernel = SubsequenceStringKernel(maxlen=3, ssk_lambda=0.5)

Example data:

import numpy as np
strings = np.array(["ATCG", "ATGG", "TACG", "GCTA"])
y = np.array([-1, -1, 1, 1])

Compute the kernel matrix:

kernel_matrix = subsequence_kernel(strings, strings)

print(kernel_matrix)
[[1.         0.74037191 0.91640867 0.79256966]
 [0.74037191 1.         0.68420576 0.65356968]
 [0.91640867 0.68420576 1.         0.84210526]
 [0.79256966 0.65356968 0.84210526 1.        ]]

Or use the kernel object with Scikit-learn:

from sklearn.svm import SVC
clf = SVC(kernel=subsequence_kernel)

# train the classifier
clf.fit(strings, y)

# make predictions using the classifier
predictions = clf.predict(strings)

print(predictions)
[-1 -1  1  1]

Documentation

Refer to the documentation for comprehensive examples of applying string kernels to biological sequences.

Reference

If you use or discuss this package, please cite:

Barbosa, D.F., Rocha, M., Kashiwabara, A.Y. (2024). strkernels: a optimized string kernels Python package. Under development.

License

GNU GPLv3

Contact

To report bugs, to ask for help and to give any feedback, please contact denilsonfbar@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 Distribution

strkernels-0.2.14.tar.gz (25.1 kB view details)

Uploaded Source

Built Distributions

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

strkernels-0.2.14-cp313-cp313-musllinux_1_2_x86_64.whl (204.2 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

strkernels-0.2.14-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (129.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

strkernels-0.2.14-cp312-cp312-musllinux_1_2_x86_64.whl (204.2 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

strkernels-0.2.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (129.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

strkernels-0.2.14-cp311-cp311-musllinux_1_2_x86_64.whl (204.1 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

strkernels-0.2.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (129.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

strkernels-0.2.14-cp310-cp310-musllinux_1_2_x86_64.whl (204.1 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

strkernels-0.2.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (129.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

strkernels-0.2.14-cp39-cp39-musllinux_1_2_x86_64.whl (204.1 kB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

strkernels-0.2.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (129.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file strkernels-0.2.14.tar.gz.

File metadata

  • Download URL: strkernels-0.2.14.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for strkernels-0.2.14.tar.gz
Algorithm Hash digest
SHA256 51cce1be026eb835633b2c2feca5f3bf8ec4063e06f31990490a5e735d7daa10
MD5 1af7ff1ce104014f9938930b02fcbb42
BLAKE2b-256 459d2fa38060c7f0a249f8c51f9eed997ace612ae31851178d28c592a1eb1caa

See more details on using hashes here.

File details

Details for the file strkernels-0.2.14-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for strkernels-0.2.14-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ffe82496e145dc2b6e0e3ceea53f3e03864b3bc03a2b4fb58ce167801a835e63
MD5 cd4be30c184cbe85b6db809bb1ee3ad0
BLAKE2b-256 dada66cd3d8e745e6622745d7ead31ade602f0998c6138432110c9f3475b84ab

See more details on using hashes here.

File details

Details for the file strkernels-0.2.14-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for strkernels-0.2.14-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54468ece28f938fcc0405fe431b8dbf41e7940a4dd19ab52ba94da6fa68a3f9f
MD5 f77ecb0a94b7e928d286143a5530c4cc
BLAKE2b-256 73f93999bb414d414e9ca33d46222ad2cfc71c8111a6cfe7df589c31a07587bd

See more details on using hashes here.

File details

Details for the file strkernels-0.2.14-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for strkernels-0.2.14-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 edd3271b848ddd9245157f0ffd8e3d0b7d70a7ed6643d0f963a2d9d5815a6512
MD5 ccebd8286d6b1fa5da7a09872ce7801d
BLAKE2b-256 96e47bcf5b0c9c46f3f6c29992c5589647ef983f5421b269578fe426ff04147f

See more details on using hashes here.

File details

Details for the file strkernels-0.2.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for strkernels-0.2.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cc5bec7227d0bd0da0c030506068459192fd4fc3585602d5fa14760e283eae64
MD5 258cec51498e4cda25009c3d19387b6f
BLAKE2b-256 ea6e3b8d816312d5c29d3cab226461868c06fd9ad0b636cc5a039b70054249ce

See more details on using hashes here.

File details

Details for the file strkernels-0.2.14-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for strkernels-0.2.14-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8d7ad88c7b44a0387e6d735855e5b60c28ad7b7850a4b39b68d1c31690ffc8dd
MD5 54d12ceebcf91cf4d941bff2c6783f9b
BLAKE2b-256 2dcd3242559d5a533256bdd0406b079720bf7cc254ef7fa455ed02d364fb6aa8

See more details on using hashes here.

File details

Details for the file strkernels-0.2.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for strkernels-0.2.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 098f0d9bfc18157058d3271fcf96d2fb2c880bad6cc0c0df44f0713ad4dc4371
MD5 e53034f11762de97e7b410624f7c029f
BLAKE2b-256 05a51e61b642716f281979f1b0eadbcdf68b3e5ad3027e5df0bb3736e47c84f8

See more details on using hashes here.

File details

Details for the file strkernels-0.2.14-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for strkernels-0.2.14-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8f5a7d162f2e11a434862f226a251a2e2d661ea906dfeb5be6177548d182da66
MD5 d0f7fe0d70a5d2bc91a09e62a2c8247a
BLAKE2b-256 3a23c8e5bc57567cb2f3dcca7d9040fc15c451124843a9fa1e7c3752c6b2d9eb

See more details on using hashes here.

File details

Details for the file strkernels-0.2.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for strkernels-0.2.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 29f191ab909702a61ac0bf11008cb867369006e163d2ba958572ebb4cdcc88da
MD5 887f56013d608d9ceb19ccc8df50e7da
BLAKE2b-256 1db456e016b4dc00898d4133441abf39158f13f59be1d20e20c40f716d0ac584

See more details on using hashes here.

File details

Details for the file strkernels-0.2.14-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for strkernels-0.2.14-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 af45b1658ac5f0480b6d476b8f6ce63f48bcc52328a15041a898e06a0ee9b7f1
MD5 d6b6652ba551d877c945198499cc2962
BLAKE2b-256 845a1f1ed514761d48fcedb62fd183ec97270bed01f0efeeb91dac3b4300cb7f

See more details on using hashes here.

File details

Details for the file strkernels-0.2.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for strkernels-0.2.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f44f585dfa6c69a762ca64d64b9e5f9774df998a955ea663cf7bb15562bb7ff1
MD5 9ff3160eb8d7a68d3bf497082865e541
BLAKE2b-256 2ab5359ad1baadf03dc374b60e3985375fcab6f8a780b0dc7633933dcaf95d7a

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