MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / __init__

Method __init__

machine_learning/sequential_minimum_optimization.py:48–75  ·  view source on GitHub ↗
(
        self,
        train,
        kernel_func,
        alpha_list=None,
        cost=0.4,
        b=0.0,
        tolerance=0.001,
        auto_norm=True,
    )

Source from the content-addressed store, hash-verified

46
47class SmoSVM:
48 def __init__(
49 self,
50 train,
51 kernel_func,
52 alpha_list=None,
53 cost=0.4,
54 b=0.0,
55 tolerance=0.001,
56 auto_norm=True,
57 ):
58 self._init = True
59 self._auto_norm = auto_norm
60 self._c = np.float64(cost)
61 self._b = np.float64(b)
62 self._tol = np.float64(tolerance) if tolerance > 0.0001 else np.float64(0.001)
63
64 self.tags = train[:, 0]
65 self.samples = self._norm(train[:, 1:]) if self._auto_norm else train[:, 1:]
66 self.alphas = alpha_list if alpha_list is not None else np.zeros(train.shape[0])
67 self.Kernel = kernel_func
68
69 self._eps = 0.001
70 self._all_samples = list(range(self.length))
71 self._K_matrix = self._calculate_k_matrix()
72 self._error = np.zeros(self.length)
73 self._unbound = []
74
75 self.choose_alpha = self._choose_alphas()
76
77 # Calculate alphas using SMO algorithm
78 def fit(self):

Callers

nothing calls this directly

Calls 3

_normMethod · 0.95
_calculate_k_matrixMethod · 0.95
_choose_alphasMethod · 0.95

Tested by

no test coverage detected