1010from Orange .widgets .utils .owlearnerwidget import OWBaseLearner
1111from Orange .widgets .utils .signals import Output
1212from Orange .widgets .utils .widgetpreview import WidgetPreview
13+ from Orange .classification import SklLearner
14+ from Orange .preprocess import Scale
1315
1416
1517class OWSVM (OWBaseLearner ):
@@ -26,9 +28,13 @@ class OWSVM(OWBaseLearner):
2628
2729 LEARNER = SVMLearner
2830
31+ pps = SklLearner .preprocessors
32+ scaling = [Scale (center = Scale .NoCentering )]
33+
2934 class Outputs (OWBaseLearner .Outputs ):
3035 support_vectors = Output ("Support vectors" , Table , explicit = True )
3136
37+
3238 #: Different types of SVMs
3339 SVM , Nu_SVM = range (2 )
3440 #: SVM type
@@ -56,6 +62,8 @@ class Outputs(OWBaseLearner.Outputs):
5662 limit_iter = Setting (True )
5763 #: maximum number of iterations
5864 max_iter = Setting (100 )
65+ #: scaling of data
66+ scale_data = Setting (True )
5967
6068 _default_gamma = "auto"
6169 kernels = (("Linear" , "x⋅y" ),
@@ -176,6 +184,10 @@ def _add_optimization_box(self):
176184 alignment = Qt .AlignRight , controlWidth = 100 ,
177185 callback = self .settings_changed ,
178186 checkCallback = self .settings_changed )
187+ self .scaling_box = gui .checkBox (
188+ self .optimization_box , self ,
189+ 'scale_data' , label = 'Scale data' ,
190+ callback = self .settings_changed )
179191
180192 def _show_right_kernel (self ):
181193 enabled = [[False , False , False ], # linear
@@ -210,7 +222,7 @@ def create_learner(self):
210222 'probability' : True ,
211223 'tol' : self .tol ,
212224 'max_iter' : self .max_iter if self .limit_iter else - 1 ,
213- 'preprocessors' : self .preprocessors
225+ 'preprocessors' : self .pps + self . scaling if self . scale_data else self . pps
214226 }
215227 if self .svm_type == self .SVM :
216228 return SVMLearner (C = self .C , epsilon = self .epsilon , ** common_args )
0 commit comments