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.

Features

  • Implemenation of primal form (hard margin and soft margin) of SVM Classification using Stochastic Gradient Descent (SGD).

Modules Implemented from Scratch

  • SVM Classifier
  • Standard Scaler
  • Metric functions: Accuracy

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)

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.1.0.tar.gz (6.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.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: svmlite-0.1.0.tar.gz
  • Upload date:
  • Size: 6.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.1.0.tar.gz
Algorithm Hash digest
SHA256 6b192d674e851560e7f7b45f3b3964ad932b25858e7274059fa21eb6a5788bc1
MD5 593bceb257cdd416418f9de0b40b0dfc
BLAKE2b-256 c6025865e65540de18423f8b0af610ed6b76a75bc86b4b44b78676927c2476ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: svmlite-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae89cbb6b852b1d39bd897c74601d3c7965f6d028ea663c179c5640865a607d1
MD5 2b77857ddf2592de6cd5681169286e2a
BLAKE2b-256 9756b028e89f7cb303e3219e0dfbbfec84cf9129464b8713c419ee1b0b597fb9

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