Kernel SVM library based on sklearn and GPlib.
Project description
kSVMlib
Kernel SVM library based on sklearn and GPlib. Provides similar functionality to GPlib for SVMs.
Setup kSVMlib
-
Create and activate venv
python3 -m venv .env source .env/bin/activate
-
Upgrade pip
python -m pip install --upgrade pip
-
Install kSVMlib package
python -m pip install ksvmlib
Use kSVMlib
-
Import kSVMlib to use it in your python script.
import ksvmlib
-
Generate some random data.
import numpy as np data = {} data['X'] = np.vstack(( np.random.multivariate_normal([1, 1], [[1, 0], [0, 1]], 100), np.random.multivariate_normal([3, 3], [[1, 0], [0, 1]], 100) )) data['Y'] = np.vstack(( np.ones((100, 1)), np.zeros((100, 1)), )) validation = ksvmlib.vm.RandFold(fold_len=0.2, n_folds=1) train_set, test_set = validation.get_folds(data)[0]
-
Initialize the KSVM model and a metric to measure the results.
model = ksvmlib.KSVM(ksvmlib.ker.SquaredExponential()) accuracy = ksvmlib.me.Accuracy()
-
Fit the model to the data.
fitting_method = ksvmlib.fit.GridSearch( obj_fun=accuracy.fold_measure, max_fun_call=300 ) train_validation = ksvmlib.vm.RandFold(fold_len=0.2, n_folds=3) log = fitting_method.fit(model, train_validation.get_folds( train_set )) print("Fitting log: {}".format(log))
-
Finally plot the results.
print("Accuracy: {}".format(accuracy.measure(model, train_set, test_set))) ksvmlib.plot.kernel_sort_data(model, test_set)
-
There are more examples in examples/ directory. Check them out!
Develop kSVMlib
-
Update API documentation
source ./.env/bin/activate pip install Sphinx cd docs/ sphinx-apidoc -f -o ./ ../ksvmlib
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ksvmlib-0.2.1.tar.gz.
File metadata
- Download URL: ksvmlib-0.2.1.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
611dd6789ee93cd24bf459baa2e1afcbca8529e008aa9a93a2ee45ce4e08d47c
|
|
| MD5 |
9c5540a02e0f57c7368c1c806931cfc0
|
|
| BLAKE2b-256 |
2b16739673c3fe91b7ee168d47482201ad2c99036e4b25ffd221bdbd531494f8
|
File details
Details for the file ksvmlib-0.2.1-py3-none-any.whl.
File metadata
- Download URL: ksvmlib-0.2.1-py3-none-any.whl
- Upload date:
- Size: 31.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa744e767fbb2f629790bbecbcfae0fe50d6d47b926924438f3020fd88637874
|
|
| MD5 |
aae0dd88778713e87f32ecf46f9c6d97
|
|
| BLAKE2b-256 |
3f7d5505a20ec1ac714913c3d3d83eac96bc6eb40ae2c659dbfb68e82f63bce5
|