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.3.0.tar.gz (13.7 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.3.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for svmlite-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d922a1e5e4fe2032329e2106422e21bd054cd20a627486c73a691bf8a870c204
MD5 7cefe133c417c595ae2376be9f779a52
BLAKE2b-256 cd746fe6364de67afc2f63684f42228fe3e50d7bad02a1313886f037a83a05b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: svmlite-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d51693c65cebc3a199217d453a6bc4756dfe84f98bcefa83f3e30e82b5eb83d
MD5 a3b4a54bc5ee0f4cc3a6f7cd55e30e98
BLAKE2b-256 dbe6425e011d95fe973ae5348b33dda81f01b8aab714a1e360a118dcfd2e705f

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