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

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.2.0.tar.gz (10.8 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.2.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for svmlite-0.2.0.tar.gz
Algorithm Hash digest
SHA256 30bbb64f2a8bb1552f3c4324469fa1734c226da6bfbb3805114b9d6d39087694
MD5 41befa46092a6b30f3439a2572e53228
BLAKE2b-256 af0ba18a1c6c17e63b153adc30177faa4b89d94ec0e4c36fc57b64dd4a463610

See more details on using hashes here.

File details

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

File metadata

  • Download URL: svmlite-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8ee1a90e96a891acb551d9e541b12c9b1eae1480ce11495c5319bf151f793ca
MD5 7a9933d782647ecc2835be0d77e062bf
BLAKE2b-256 e90dca04dc32e89d118ed1c87fda5c8ee98b23dee8ef4ea5ad468868d6bb5b6c

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