Skip to main content

A lightweight SVM implementation from scratch

Project description

SVMLite

Work in Progress

This project is part of CS6375 Machine learning course at University of Texas at Dallas.

A lightweight Python library implementing Support Vector Machines from scratch for educational and experimental use.

Installation

pip install svmlite

Quick Start

from svmlite.svm import SVCLite
from svmlite.utils import StandardScalerLite
from svmlite.metrics import accuracy_score
import numpy as np

# prepare data
X = np.array([[1, 2], [2, 3], [3, 3], [6, 5], [7, 8], [8, 7]])
y = np.array([-1, -1, -1, 1, 1, 1])

# scale features
scaler = StandardScalerLite()
X_scaled = scaler.fit_transform(X)

# train SVM
model = SVCLite(C=1.0)
model.fit(X_scaled, y, learning_rate=0.01, n_iters=1000)

# predict
predictions = model.predict(X_scaled)
print("Predictions:", predictions)

# evaluate
acc = accuracy_score(y, predictions)
print("Accuracy:", acc)

Features

  • Implemenation of primal form (hard margin and soft margin) of SVM Classification using Stochastic Gradient Descent (SGD).
  • QP (Quadratic Programming) based SVM implementation using cvxopt
  • Kernel Support: Linear, Polynomial, RBF kernel, Sigmoid kernel and Custom Kernel support
  • SMO (Sequential Minimal Optimization) algorithm for optimization (simplified heuristic for selecting alpha pairs)
  • Multiclass classification using One-vs-One (OvO) and One-vs-All (OvA) strategies

Modules Implemented from Scratch

  • SVM Classifier
  • Kernel Functions: Linear, Polynomial, RBF, Sigmoid
  • Standard Scaler
  • Metric functions: Accuracy

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

svmlite-0.4.0.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

svmlite-0.4.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file svmlite-0.4.0.tar.gz.

File metadata

  • Download URL: svmlite-0.4.0.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for svmlite-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ef130559cd4b18a4ab79b19ffe31f9513a016be32b03718c23ea0be9391fd2be
MD5 7bfd7f1b9e71c21e323af119d87416b3
BLAKE2b-256 2b18330341679be3c9f7b3ee4d47cc55abfc32dc5dee260b7853c22ae376dec8

See more details on using hashes here.

File details

Details for the file svmlite-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: svmlite-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for svmlite-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 206d64bbe866f93476a8b2668245b5db290b13bdef42e9337705ecca521edd9a
MD5 5f2f662eb004d387b5e3636dd3c44125
BLAKE2b-256 ac0801909ecd2ef35bc4f71caef1b90ec69d029c5b7f7277f8da9da5974ecbc2

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