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

Function test_rbf_kernel

machine_learning/sequential_minimum_optimization.py:547–564  ·  view source on GitHub ↗
(ax, cost)

Source from the content-addressed store, hash-verified

545
546
547def test_rbf_kernel(ax, cost):
548 train_x, train_y = make_circles(
549 n_samples=500, noise=0.1, factor=0.1, random_state=1
550 )
551 train_y[train_y == 0] = -1
552 scaler = StandardScaler()
553 train_x_scaled = scaler.fit_transform(train_x, train_y)
554 train_data = np.hstack((train_y.reshape(500, 1), train_x_scaled))
555 my_kernel = Kernel(kernel="rbf", degree=5, coef0=1, gamma=0.5)
556 mysvm = SmoSVM(
557 train=train_data,
558 kernel_func=my_kernel,
559 cost=cost,
560 tolerance=0.001,
561 auto_norm=False,
562 )
563 mysvm.fit()
564 plot_partition_boundary(mysvm, train_data, ax=ax)
565
566
567def plot_partition_boundary(

Callers 1

test_demonstrationFunction · 0.85

Calls 4

fitMethod · 0.95
KernelClass · 0.85
SmoSVMClass · 0.85
plot_partition_boundaryFunction · 0.85

Tested by

no test coverage detected