Metadata-Version: 2.3
Name: rusvm
Version: 0.1.1
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Dist: numpy
Keywords: smo,svm,machine-learning
Author: Nico Strasdat <nstrasdat@gmail.com>
Author-email: Nico Strasdat <nstrasdat@gmail.com>
License: AGPL-3.0-or-later
Requires-Python: >=3.7
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Source Code, https://github.com/wotzlaff/rusvm-python

# rusvm
A Python interface to [rusvm](https://github.com/wotzlaff/rusvm).

## Installation
```
pip install rusvm
```

## Example
See [simple.py](./examples/simple.py).

```py
import rusvm
import numpy as np
import matplotlib.pyplot as plt

# generate sample dataset
n = 20
np.random.seed(42)
x = np.random.rand(n)
y = np.sin(2.0 * np.pi * x)

# define parameters for training problem
# regularization parameter
lmbda = 1.0
# scaling parameter
gamma = 10.0

# solve training problem
res = rusvm.solve_smo(
    x=np.sqrt(gamma) * x[:, None],
    y=y,
    params_problem=dict(
        lmbda=lmbda,
        kind='regression',
    ),
    params_smo=dict(
        time_limit=1.0,
    )
)
print(res['opt_status'])
a = np.array(res['a']) / lmbda
a = a[:n] + a[n:]

# generate reference points
xplot = np.linspace(0.0, 1.0, 100)
# evaluate decision function at reference points
k = np.exp(-gamma * (xplot[:, None] - x[None, :]) ** 2)
yplot = k.dot(a) + res['b']

# plot training points and decision function
plt.plot(x, y, 'kx')
plt.plot(xplot, yplot, 'r')
```

## Build
```
maturin develop --release
```
