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 Distributions

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

Built Distributions

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

strkernels-0.2.12-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.12-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.12-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.12-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.12-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.12-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.12-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.12-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.12-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.12-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.12-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for strkernels-0.2.12-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6eb81435d1a1ce41ecffcfafeb2d86e58a87a8f97b6b7a52c8bb5a62d91d5211
MD5 b85adabce598babe5a623f75bf6b968c
BLAKE2b-256 339a1aea7afe5c53f3cf5d6cb301aa3b8da594ee125f7c1ef566fbd6f86e9630

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.12-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 63225d04b5b7f70b2b807bce70d043299a840a45d2860e26efd3592908a81038
MD5 ba7986c8c44d113a84b3a21bf67575ee
BLAKE2b-256 a88d7888d9d3148c94f099470671ae665edffa034eefb2c3de18fa2139bb19fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.12-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 26bdaa74813579680e0e6007c06a17091914fdc5c6ab7ad45f10e3243c008f07
MD5 53c7e7edb361ff1348f474278892f898
BLAKE2b-256 87ed13748cc044b361e87cca9396bf6f0ab8ca9be7d5c166a805c13501653b7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 46021d0cd269b6e02a72e696a6d1df6f83c00bd2ba0485c2afbadfc450ca3159
MD5 baeb7d2c3b6502b4630d05f3db377ff4
BLAKE2b-256 b19e99fc2b2be371489939d52fb84671fe39a61ba5afa1c8721ff7cd423e614b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.12-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 163b9eeb0aaea730b0fdfdedc8838745c057e6d006306906abba77b756d8abcd
MD5 85fd6bcdee5ad7e5d43e01ee091dfb5b
BLAKE2b-256 8f0e7f7dd7ccb4c12dc5dd42bbd2edb85608882e603580abb13b191b68620058

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d508d55de12264a2534e49c20007b2b95071027445c6e6bce036ea8edd690383
MD5 1cc5f88da3432d4c0e5de3bc58d856ea
BLAKE2b-256 2c84b03ed05b5e43b4c714efd833c39c85728a9a211e8dd8790fa1dc66d86bce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.12-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 365370e1971b01302173e61deda87767771f3d9e6d26218d0d558b31f1833da8
MD5 3c03ec0cf4fc300781703bc831c608c0
BLAKE2b-256 2370b49d729cca316c2ec2a684d6350eb8a744b0c54df0f1115e650ccaea4c9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab8eb0ecd350fbf26995d1cc7326c3265ab9faa94a17b6fefd203343cd2da468
MD5 94cad6816a5fbe75c824ef73278090b4
BLAKE2b-256 68c02562af0a072870f2fe311f95531f80ce5f503aaca5e2f7dcdde6aadf4ddc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.12-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c835ca15b4becb755a5ee90f355fbfe3859b41278d209d51a6c270025e79e5ce
MD5 c20b4873134c8ec799f311b58588d9b5
BLAKE2b-256 dc9d495b4bc06432ab99970e1376471f64f9a948e28bb56cc9ed9f64486bae27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a2893a71d654c8999addebddf9d3d81f62df07ad40cda23d6fd3b49e1b7a896
MD5 1d47b2c52ffc9c03554345018f86f02e
BLAKE2b-256 4d22081e314b8e65bb4bea9b14509fcd571750662661723ecc6134b5fb00fe8a

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