Skip to content

Commit

Permalink
SVMRegression: Check gradient
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Feb 20, 2024
1 parent c6194c8 commit 8412997
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions python/test/t_SVMClassification_std.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
algo.setKernelType(otsvm.LibSVM.NormalRbf)
algo.setTradeoffFactor(cp)
algo.setKernelParameter(gamma)
print(algo)

# compute the classification
algo.run()
Expand All @@ -36,6 +37,8 @@
c = dataOut[i]
print(f"x={x} c={c} classify={algo.classify(x)} grade={algo.grade(x, c)} predict={algo.predict(x)}")

algo.setWeight([1.0] * size)

if ot.PlatformInfo.HasFeature("libxml2"):
study = ot.Study()
fname = "study_classif.xml"
Expand Down
2 changes: 2 additions & 0 deletions python/test/t_SVMKernel_std.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

# parameter accessor
param = kernel.getParameter()
desc = kernel.getParameterDescription()
assert len(param) == len(desc), "mismatched param/desc"
kernel.setParameter(param)

# serialization
Expand Down
5 changes: 4 additions & 1 deletion python/test/t_SVMRegression_saveload.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@

os.remove(fileName)

assert metamodel(mean) == loadedMetamodel(mean)
x = mean
assert metamodel(x) == loadedMetamodel(x)
assert metamodel.gradient(x) == loadedMetamodel.gradient(x)
assert metamodel.hessian(x) == loadedMetamodel.hessian(x)

0 comments on commit 8412997

Please sign in to comment.