DocumentationNeurondB Documentation

Support Vector Machines

Prepare Classification Dataset

SVM works best with smaller, well-balanced datasets. We limit to 20,000 samples for computational efficiency.

Create SVM training data

-- Prepare classification dataset for SVM
CREATE TEMP TABLE svm_data AS
SELECT 
    transaction_id,
    features,
    CASE WHEN is_fraud THEN 1 ELSE 0 END as label  -- Binary labels: 0 or 1
FROM transactions
WHERE features IS NOT NULL
LIMIT 20000;  -- Smaller dataset for SVM

Train Linear SVM Classifier

Train SVM using SMO algorithm. Returns support vectors (alpha coefficients) that define the maximum margin hyperplane.

Train SVM

SELECT train_svm(
    'svm_train',         -- Training table
    'features',          -- Feature column
    'label',             -- Target column
    0.1,                 -- C (regularization parameter)
    1000                 -- Max iterations
) AS support_vectors;

Evaluate Model

Evaluate SVM performance on test data.

Evaluate SVM

SELECT evaluate_svm(
    'svm_test',
    'features',
    'label',
    :support_vectors
) AS metrics;

Next Steps