Changeset 9823:7f9c3f3c6474 in orange for docs/reference/rst/code/svmcustomkernel.py
 Timestamp:
 02/06/12 20:01:02 (2 years ago)
 Branch:
 default
 Children:
 9835:e48466fc6eb2, 9841:05a160804431
 rebase_source:
 8cf30121654f25c9cb6d8ac9bdaf163e305d62da
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

docs/reference/rst/code/svmcustomkernel.py
r9724 r9823 3 3 4 4 from Orange.classification.svm import SVMLearner, kernels 5 from Orange.distance import Euclidean6 from Orange.distance import Hamming5 from Orange.distance.instances import EuclideanConstructor 6 from Orange.distance.instances import HammingConstructor 7 7 8 table= data.Table("iris.tab")8 iris = data.Table("iris.tab") 9 9 l1 = SVMLearner() 10 l1.kernel_func = kernels.RBFKernelWrapper(Euclidean (table), gamma=0.5)10 l1.kernel_func = kernels.RBFKernelWrapper(EuclideanConstructor(iris), gamma=0.5) 11 11 l1.kernel_type = SVMLearner.Custom 12 12 l1.probability = True 13 c1 = l1( table)13 c1 = l1(iris) 14 14 l1.name = "SVM  RBF(Euclidean)" 15 15 16 16 l2 = SVMLearner() 17 l2.kernel_func = kernels.RBFKernelWrapper(Hamming (table), gamma=0.5)17 l2.kernel_func = kernels.RBFKernelWrapper(HammingConstructor(iris), gamma=0.5) 18 18 l2.kernel_type = SVMLearner.Custom 19 19 l2.probability = True 20 c2 = l2( table)20 c2 = l2(iris) 21 21 l2.name = "SVM  RBF(Hamming)" 22 22 23 23 l3 = SVMLearner() 24 24 l3.kernel_func = kernels.CompositeKernelWrapper( 25 kernels.RBFKernelWrapper(Euclidean (table), gamma=0.5),26 kernels.RBFKernelWrapper(Hamming (table), gamma=0.5), l=0.5)25 kernels.RBFKernelWrapper(EuclideanConstructor(iris), gamma=0.5), 26 kernels.RBFKernelWrapper(HammingConstructor(iris), gamma=0.5), l=0.5) 27 27 l3.kernel_type = SVMLearner.Custom 28 28 l3.probability = True 29 c3 = l1( table)29 c3 = l1(iris) 30 30 l3.name = "SVM  Composite" 31 31 32 tests = evaluation.testing.cross_validation([l1, l2, l3], table, folds=5)32 tests = evaluation.testing.cross_validation([l1, l2, l3], iris, folds=5) 33 33 [ca1, ca2, ca3] = evaluation.scoring.CA(tests) 34 34
Note: See TracChangeset
for help on using the changeset viewer.