source: orange/orange/doc/modules/svm-custom-kernel.py @ 6538:a5f65d7f0b2c

Revision 6538:a5f65d7f0b2c, 1.0 KB checked in by Mitar <Mitar@…>, 4 years ago (diff)

Made XPM version of the icon 32x32.

Line 
1import orange, orngSVM
2data=orange.ExampleTable("iris.tab")
3l1=orngSVM.SVMLearner()
4l1.kernelFunc=orngSVM.RBFKernelWrapper(orange.ExamplesDistanceConstructor_Euclidean(data), gamma=0.5)
5l1.kernel_type=orange.SVMLearner.Custom
6l1.probability=True
7c1=l1(data)
8l1.name="SVM - RBF(Euclidean)"
9
10l2=orngSVM.SVMLearner()
11l2.kernelFunc=orngSVM.RBFKernelWrapper(orange.ExamplesDistanceConstructor_Hamming(data), gamma=0.5)
12l2.kernel_type=orange.SVMLearner.Custom
13l2.probability=True
14c2=l2(data)
15l2.name="SVM - RBF(Hamming)"
16
17l3=orngSVM.SVMLearner()
18l3.kernelFunc=orngSVM.CompositeKernelWrapper(orngSVM.RBFKernelWrapper(orange.ExamplesDistanceConstructor_Euclidean(data), gamma=0.5),orngSVM.RBFKernelWrapper(orange.ExamplesDistanceConstructor_Hamming(data), gamma=0.5), l=0.5)
19l3.kernel_type=orange.SVMLearner.Custom
20l3.probability=True
21c3=l1(data)
22l3.name="SVM - Composite"
23
24
25import orngTest, orngStat
26tests=orngTest.crossValidation([l1, l2, l3], data, folds=5)
27[ca1, ca2, ca3]=orngStat.CA(tests)
28print l1.name, "CA:", ca1
29print l2.name, "CA:", ca2
30print l3.name, "CA:", ca3
Note: See TracBrowser for help on using the repository browser.