Ejemplo n.º 1
0
labels = MulticlassSOLabels(y)
features = RealFeatures(X.T)

model = MulticlassModel(features, labels)
loss = HingeLoss()

lambda_ = 1e1
sosvm = DualLibQPBMSOSVM(model, loss, labels, lambda_)

sosvm.set_cleanAfter(
    10
)  # number of iterations that cutting plane has to be inactive for to be removed
sosvm.set_cleanICP(True)  # enables inactive cutting plane removal feature
sosvm.set_TolRel(0.001)  # set relative tolerance
sosvm.set_verbose(True)  # enables verbosity of the solver
sosvm.set_cp_models(16)  # set number of cutting plane models
sosvm.set_solver(BMRM)  # select training algorithm
#sosvm.set_solver(PPBMRM)
#sosvm.set_solver(P3BMRM)

sosvm.train()

res = sosvm.get_result()
Fps = np.array(res.hist_Fp)
Fds = np.array(res.hist_Fp)
wdists = np.array(res.hist_wdist)

plt.figure()
plt.subplot(221)
plt.title('Fp and Fd history')
Ejemplo n.º 2
0
cnt = 250

X2, y2 = fill_data(cnt, np.min(X), np.max(X))

labels = MulticlassSOLabels(y)
features = RealFeatures(X.T)

model = MulticlassModel(features, labels)

lambda_ = 1e1
sosvm = DualLibQPBMSOSVM(model, labels, lambda_)

sosvm.set_cleanAfter(10)	# number of iterations that cutting plane has to be inactive for to be removed
sosvm.set_cleanICP(True)	# enables inactive cutting plane removal feature
sosvm.set_TolRel(0.001)		# set relative tolerance
sosvm.set_verbose(True)		# enables verbosity of the solver
sosvm.set_cp_models(16)		# set number of cutting plane models
sosvm.set_solver(BMRM)		# select training algorithm
#sosvm.set_solver(PPBMRM)
#sosvm.set_solver(P3BMRM)

sosvm.train()

res = sosvm.get_result()
Fps = np.array(res.get_hist_Fp_vector())
Fds = np.array(res.get_hist_Fp_vector())
wdists = np.array(res.get_hist_wdist_vector())

plt.figure()
plt.subplot(221)
plt.title('Fp and Fd history')