Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Scikit learn contrib Imbalanced learn SVMSMOTE

From Leeroopedia


Knowledge Sources
Domains Machine_Learning, Data_Preprocessing, Imbalanced_Learning
Last Updated 2026-02-09 03:00 GMT

Overview

Concrete tool for SVM-guided borderline oversampling provided by the imbalanced-learn library.

Description

The SVMSMOTE class implements the SVM-SMOTE variant. It extends BaseSMOTE and uses an SVM classifier to detect borderline minority instances (support vectors). Synthetic samples are generated near these support vectors with an optional out_step to control boundary extension.

Usage

Import this class when you want SVM-based borderline detection for targeted oversampling instead of k-NN based detection (as in BorderlineSMOTE).

Code Reference

Source Location

  • Repository: imbalanced-learn
  • File: imblearn/over_sampling/_smote/filter.py
  • Lines: L235-497

Signature

class SVMSMOTE(BaseSMOTE):
    def __init__(
        self,
        *,
        sampling_strategy="auto",
        random_state=None,
        k_neighbors=5,
        m_neighbors=10,
        svm_estimator=None,
        out_step=0.5,
    ):
        """
        Args:
            sampling_strategy: str, dict, or callable - Resampling ratio.
            random_state: int, RandomState, or None - Seed.
            k_neighbors: int or NearestNeighbors - SMOTE interpolation neighbors.
            m_neighbors: int or NearestNeighbors - Neighbors for detection.
            svm_estimator: SVC or None - SVM for support vector detection
                (default: SVC with default params).
            out_step: float - Step size for extrapolation beyond support vectors
                (default: 0.5).
        """

Import

from imblearn.over_sampling import SVMSMOTE

I/O Contract

Inputs

Name Type Required Description
X {array-like, sparse matrix} of shape (n_samples, n_features) Yes Feature matrix
y array-like of shape (n_samples,) Yes Target labels
svm_estimator SVC or None No SVM for boundary detection (default: SVC())
out_step float No Extrapolation step size (default: 0.5)

Outputs

Name Type Description
X_resampled ndarray of shape (n_samples_new, n_features) Feature matrix with SVM-guided synthetic samples
y_resampled ndarray of shape (n_samples_new,) Target array

Usage Examples

from collections import Counter
from sklearn.datasets import make_classification
from imblearn.over_sampling import SVMSMOTE

X, y = make_classification(
    n_classes=2, weights=[0.1, 0.9], n_samples=1000, random_state=10
)
svmsmote = SVMSMOTE(random_state=42, out_step=0.5)
X_res, y_res = svmsmote.fit_resample(X, y)
print(f"Resampled: {Counter(y_res)}")

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment