Skip to main content

PyPi License Python3 downloads downloads_month DOI

Variant-SVMs

./logo/logo_header.png

VarSVM is a Python module for solving variants Support Vector Machines (SVM).

Website: https://variant-svm.readthedocs.io

This project was created by Ben Dai. If there is any problem and suggestion please contact me via <bdai@umn.edu>.

Installation

Dependencies

Tab-Data requires:

  • Python

  • NumPy

  • Pandas

  • Sklearn

User installation

Install Variant-SVMs using pip

pip install varsvm

or

pip install git+https://github.com/statmlben/varsvm.git

Source code

You can check the latest sources with the command:

git clone https://github.com/statmlben/varsvm.git

Documentation

weightsvm

Classical weighted SVMs.

  • class VarSVM.weightsvm(alpha=[], beta=[], C=1., max_iter = 1000, eps = 1e-4, print_step = 1)

    • Parameters:
      • alpha: Dual variable.

      • beta: Primal variable, or coefficients of the support vector in the decision function.

      • C: Penalty parameter C of the error term.

      • max_iter: Hard limit on iterations for coordinate descent.

      • eps: Tolerance for stopping criterion based on the relative l1 norm for difference of beta and beta_old.

      • print_step: If print the interations for coordinate descent, 1 indicates YES, 0 indicates NO.

    • Methods:
      • decision_function(X): Evaluates the decision function for the samples in X.
        • X : array-like, shape (n_samples, n_features)

      • fit(X, y, sample_weight=1.): Fit the SVM model.
        • X : {array-like, sparse matrix}, shape (n_samples, n_features)

        • y : array-like, shape (n_samples,) NOTE: y must be +1 or -1!

        • sample_weight : array-like, shape (n_samples,), weight for each sample.

Drift SVM

SVM with dift or fixed intercept for each instance.

  • class VarSVM.driftsvm(alpha=[], beta=[], C=1., max_iter = 1000, eps = 1e-4, print_step = 1)

    • Parameters:
      • alpha: Dual variable.

      • beta: Primal variable, or coefficients of the support vector in the decision function.

      • C: Penalty parameter C of the error term.

      • max_iter: Hard limit on iterations for coordinate descent.

      • eps: Tolerance for stopping criterion based on the relative l1 norm for difference of beta and beta_old.

      • print_step: If print the interations for coordinate descent, 1 indicates YES, 0 indicates NO.

    • Methods:
      • decision_function(X): Evaluates the decision function for the samples in X.
        • X : array-like, shape (n_samples, n_features)

      • fit(X, y, drift, sample_weight=1.): Fit the SVM model.
        • X : {array-like, sparse matrix}, shape (n_samples, n_features)

        • y : array-like, shape (n_samples,). NOTE: y must be +1 or -1!

        • drift: array-like, shape (n_samples,), drift or fixed intercept for each instance, see doc.

        • sample_weight : array-like, shape (n_samples,), weight for each instance.

Non-negative Drift SVM

SVM with non-negative constrains for coefficients.

  • class VarSVM.noneg_driftsvm(alpha=[], beta=[], C=1., max_iter = 1000, eps = 1e-4, print_step = 1)

    • Parameters:
      • alpha: Dual variable.

      • beta: Primal variable, or coefficients of the support vector in the decision function.

      • C: Penalty parameter C of the error term.

      • max_iter: Hard limit on iterations for coordinate descent.

      • eps: Tolerance for stopping criterion based on the relative l1 norm for difference of beta and beta_old.

      • print_step: If print the interations for coordinate descent, 1 indicates YES, 0 indicates NO.

    • Methods:
      • decision_function(X): Evaluates the decision function for the samples in X.
        • X : array-like, shape (n_samples, n_features)

      • fit(X, y, drift, sample_weight=1.): Fit the SVM model.
        • X : {array-like, sparse matrix}, shape (n_samples, n_features)

        • y : array-like, shape (n_samples,). NOTE: y must be +1 or -1!

        • drift: array-like, shape (n_samples,), drift or fixed intercept for each instance, see doc.

        • sample_weight : array-like, shape (n_samples,), weight for each instance.

Example

import numpy as np
from sklearn.datasets import make_classification
from VarSVM import noneg_driftsvm

X, y = make_classification(n_features=4, random_state=0)
y = y * 2 - 1

n = len(X)
drift = .28*np.ones(n)

clf = noneg_driftsvm()
clf.fit(X=X, y=y, drift=drift)
y_pred = clf.decision_function(X=X, drift=drift)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

varsvm-1.0.tar.gz (7.7 kB view details)

Uploaded Source

File details

Details for the file varsvm-1.0.tar.gz.

File metadata

  • Download URL: varsvm-1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for varsvm-1.0.tar.gz
Algorithm Hash digest
SHA256 16e362f9c427d5afc1bda1084090ec730a629b2c249981708149519b51f86417
MD5 ff5f5a82fed4da812603572f309ccee3
BLAKE2b-256 7f75b9b46922e9e80c19b71e7df9e6625a0a0189b2dc8d15b018cb290a204cb9

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