Support Vector Machines
sawmil.svm.SVM
dataclass
SVM(
C: float = 1.0,
kernel: KernelType = Linear(),
solver: str = "gurobi",
tol: float = 1e-06,
verbose: bool = False,
solver_params: Optional[Mapping[str, Any]] = None,
)
Bases: BaseEstimator, ClassifierMixin
Support Vector Machine solved via the dual QP.
Parameters:
-
C(float, default:1.0) –Regularization parameter. Larger values try to fit the training data more exactly at the cost of a smaller margin.
-
kernel(KernelType, default:Linear()) –Specification of the kernel to use. This can be an instance of a :class:
~sawmil.kernels.BaseKernel, a callable, or a string understood -
solver(str, default:'gurobi') –Name of the quadratic program solver backend.
"gurobi"and"osqp"are supported. -
tol(float, default:1e-06) –Threshold used to decide whether a Lagrange multiplier is treated as zero when identifying support vectors.
-
verbose(bool, default:False) –If
Truethe underlying solver may print progress information. -
solver_params(Optional[Mapping[str, Any]], default:None) –dict of backend-specific options. Examples: - solver='gurobi': {'env':
, 'params': {'Method':2, 'Threads':1}} - solver='osqp' : {'setup': {...}, 'solve': {...}} or flat keys for setup - solver='daqp' : {'eps_abs': 1e-8, 'eps_rel': 1e-8, ...}
decision_function
decision_function(
X: NDArray[float64],
) -> npt.NDArray[np.float64]
Compute the decision function for the given bags.
Source code in src/sawmil/svm.py
131 132 133 134 135 136 137 138 139 140 141 142 | |
fit
fit(X: NDArray[float64], y: NDArray[float64]) -> 'SVM'
Fit the model to the training data.
Source code in src/sawmil/svm.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
predict
predict(X: NDArray[float64]) -> npt.NDArray[np.float64]
Predict the labels for the given bags.
Source code in src/sawmil/svm.py
144 145 146 147 | |
score
score(X: NDArray[float64], y: NDArray[float64]) -> float
Compute the accuracy of the model on the given bags.
Source code in src/sawmil/svm.py
149 150 151 152 153 | |