Kernel SVM library based on sklearn and GPlib.
Project description
Kernel SVM library based on sklearn and GPlib. Provides similar functionality to GPlib for SVMs.
Setup kSVMlib
- Create and activate virtualenv (for python2) or venv (for python3)
# for python3 python3 -m venv .env # or for python2 python2 -m virtualenv .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.dm.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.dm.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
- Download the repository using git
git clone https://gitlab.com/ibaidev/ksvmlib.git cd ksvmlib git config user.email 'MAIL' git config user.name 'NAME' git config credential.helper 'cache --timeout=300' git config push.default simple
- Update API documentation
source ./.env/bin/activate pip install Sphinx cd docs/ sphinx-apidoc -f -o ./ ../ksvmlib
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size ksvmlib-0.0.3-py2.py3-none-any.whl (19.5 kB) | File type Wheel | Python version py2.py3 | Upload date | Hashes View |
Filename, size ksvmlib-0.0.3.tar.gz (17.8 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for ksvmlib-0.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24f9a7789b92c11450abce9aee74e2ba540f127282f1d6a59205b2babefbb7de |
|
MD5 | e51e46eb1b741915b557beb40fb8b53b |
|
BLAKE2-256 | 0d6a540a2cd120c69c44e7f0e47c60e8ee380e28b1fd733de12db865ab833c78 |