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.9-cp313-cp313-musllinux_1_2_x86_64.whl (204.1 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

strkernels-0.2.9-cp313-cp313-musllinux_1_2_i686.whl (210.9 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ i686

strkernels-0.2.9-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.9-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl (129.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ i686

strkernels-0.2.9-cp312-cp312-musllinux_1_2_x86_64.whl (204.1 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

strkernels-0.2.9-cp312-cp312-musllinux_1_2_i686.whl (210.9 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ i686

strkernels-0.2.9-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.9-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (129.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ i686

strkernels-0.2.9-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.9-cp311-cp311-musllinux_1_2_i686.whl (210.9 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ i686

strkernels-0.2.9-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.9-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (129.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ i686

strkernels-0.2.9-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.9-cp310-cp310-musllinux_1_2_i686.whl (210.9 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ i686

strkernels-0.2.9-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.9-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (129.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ i686

strkernels-0.2.9-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.9-cp39-cp39-musllinux_1_2_i686.whl (210.9 kB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ i686

strkernels-0.2.9-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

strkernels-0.2.9-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (129.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ i686

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.9-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 323273a27b005b6610d65c85337dd9007631febc7345b1a89b38a550fe8e5f1c
MD5 afadefeed3d6a84c00b6b8719585beb4
BLAKE2b-256 432d876554d30a63011c27c74a0e2f6eae59eb9128c062c6ecde47e1c70fe898

See more details on using hashes here.

File details

Details for the file strkernels-0.2.9-cp313-cp313-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for strkernels-0.2.9-cp313-cp313-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 736f0ff827390edbcbc58a74780e0048fcb4b2e416df8288e9d46f8478ec9e45
MD5 e6de4a6c66378a0d951bada4d8f2ef81
BLAKE2b-256 a2b728689dbf7b45abb0d0dbc995dce3ecbda730892aabd940327d3216879ac1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 55c714eacfa67d56bd1ef3c58103a429f0383c302fb4c8f69ea66fa0bde50cc7
MD5 50616bacd1bb2301498b49884a6df434
BLAKE2b-256 1987397a3abb6b4b034af8ffb9aeaa7b2526d6312c7b5351c63ab9a2a2a40b55

See more details on using hashes here.

File details

Details for the file strkernels-0.2.9-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for strkernels-0.2.9-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 8b642a198bf6e25e7f8a3379120af612c95f1d379d2fd55e29d63981d80abd36
MD5 9b68e3c8db69a6d8eb194256f3b12c61
BLAKE2b-256 af56664ecc098657c764b27f7831fb0917d383720d67501fe412cfe8a558410e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.9-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d5aac63a4bbccffb089c75819be9f76baf9e373fb73b9a78833d98ac94b13a41
MD5 92ec5732213da756c97b9775acb3cac2
BLAKE2b-256 37390a443d732b8e5a499728075ae335078b5d3cd7a4fbbc2f0dc96b14bf1d9a

See more details on using hashes here.

File details

Details for the file strkernels-0.2.9-cp312-cp312-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for strkernels-0.2.9-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 b93fa76181497233ce7f9c6c57490f8fa06de664d088d20ce22bf9cce1c212f5
MD5 7c8dd9cef7d33230189b931a848dde95
BLAKE2b-256 5033490790f21d37c79fa861afe9bd5baaee2ef465874003e9d4ecf682427734

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 98116236ad40a1988ed5b58ae149ec3c40508b2ac838cdb5133e4a72014e2e40
MD5 07450e2569214ba52a3ccead7e3cd8bb
BLAKE2b-256 18da3fe668daf4a8fe2049dd1362053400fde65790418e0a6a1b5c327d4cf8f4

See more details on using hashes here.

File details

Details for the file strkernels-0.2.9-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for strkernels-0.2.9-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 38e742a5c29fce43f9476e77deb0980c01e6723885a67a6acf1588f2204a8740
MD5 be9cc8fa9aa36a11fc05450c607bb36e
BLAKE2b-256 0e8cfbe1565f9bd57bdb430449e90a2270b624f4ef332524057c05fb419ff206

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.9-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 99cd709b9174a3e9af27bbad2639035254f14a1395bd289725c74114480c5571
MD5 73b73e8cb04425148dbcf5773544a755
BLAKE2b-256 5e4eb59624a46f0c0d824fa02cac26c90d23ce2f4e927a96c9873dacd2f25333

See more details on using hashes here.

File details

Details for the file strkernels-0.2.9-cp311-cp311-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for strkernels-0.2.9-cp311-cp311-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 837e0b2906efc04eed122b7234e090a18f86af33e103334b10f875dbb6194f59
MD5 4f27a8564cbd816ee1f0e06c203bef58
BLAKE2b-256 0e5ccd63d1a4bd5daea1bc4a32b1018e1bc0230574ca399a9291d3ce373a286e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1c1e577a289b2a908d96215fbfeb7589ecf525bc4cd750a257ad8ea91eaef746
MD5 d83eec85efd28715822c07b403c96956
BLAKE2b-256 9794d149a514a8101f98ce5acafa342be7c9a3cfba60c8a3a8ed27656a714902

See more details on using hashes here.

File details

Details for the file strkernels-0.2.9-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for strkernels-0.2.9-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 fc79b258d916fbe30457fffaf983a52e3185e6a19a79b6343307d8c1882197cc
MD5 9db69c2532e41585b128a4a3f6bf92c0
BLAKE2b-256 30fc8cb70b4af594c3879cc89352fcd189fe02f347544e1b485a5d1cf18e1b93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.9-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b47acf671548812de20ead2414f93463b512448f2fd4ff158e935539837012f5
MD5 dc60376e26f95a91c6297a9c11cdfbb1
BLAKE2b-256 fab371ed8574df2e21a0f0df541d70cc4ef73cf42a3cd641ad8fba6d0cda2418

See more details on using hashes here.

File details

Details for the file strkernels-0.2.9-cp310-cp310-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for strkernels-0.2.9-cp310-cp310-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 4067653280318e27d8d985b80d608f053d2aa26d4745b4dd7ab72032d9cd261f
MD5 9ec397596fc2bcecb81f678571c25da5
BLAKE2b-256 65843b5c3b48d88a2c494b509d66435d76cec52f455ea298cc5a955f43318bae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1c21a8713c72b29e5bb9e8380d6eb627bffde5d9c4e07e585332b7e6e430d49
MD5 4e3910be2eaccf2cf24c8f85834e80dc
BLAKE2b-256 d801b6352eb845fe5f2d32b4bfa977a27ef916bf24a8b810e73abc0f9c9a9877

See more details on using hashes here.

File details

Details for the file strkernels-0.2.9-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for strkernels-0.2.9-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 ca5fde50bb1e7841cbd2065f49ec2acbd96ca5c9bc61672b299e92d17bdfc8d6
MD5 4765b37a4d2f4af4ecbf940846eec7b9
BLAKE2b-256 cc5e041d235fc21724d677cd09713dc8cf701ab3889ee52c8b8b3e158d760fca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.9-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2f7a077923df5ba542f15240724bafcdd7a43ad69b19563372f63368c214ab89
MD5 c97b06929de21e56890d11c0e127d2f6
BLAKE2b-256 0e27009a4b14662107e0c6b38a60dc42a67784ec450caa63325ccd7d9078f29f

See more details on using hashes here.

File details

Details for the file strkernels-0.2.9-cp39-cp39-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for strkernels-0.2.9-cp39-cp39-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 9edb7b3471569b9ab9b350663f104fb452a3cbf062fd2fe767dfe0f4045980f0
MD5 8f4c4b214c19186f5042fec471bbfd6f
BLAKE2b-256 69b67c7a6240990bd0eb2eb450250192428e383a5a2f1b85054aa4a465653ba9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strkernels-0.2.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a71be68458a47392a96a6ae3544369a445620327323e445cadbe8201d728fa7d
MD5 c98ef490ecb6362860601d4b6c7863b1
BLAKE2b-256 f80c886054dfa01c6ff9b3ed5bce393714c0779708b6f1d129cb9321606f2dc5

See more details on using hashes here.

File details

Details for the file strkernels-0.2.9-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for strkernels-0.2.9-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 eb1b15e7295fb7d03693bf8d5fe690187d97502053b6a188f86c21132a9f3010
MD5 27b4e1f89ca1b69c05578585bae20117
BLAKE2b-256 549023f7e4d0fb256a86ff394ea2f7dc15762725b9c84a4157d9c51cdca8856e

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