From fee7e8a2d9b8d0fd01c388e3102f9a4158fdf922 Mon Sep 17 00:00:00 2001
From: Lars Buitinck <L.J.Buitinck@uva.nl>
Date: Tue, 15 Nov 2011 23:46:36 +0100
Subject: [PATCH] FIX use super consistently in SVMs

---
 sklearn/svm/classes.py        | 36 +++++++++++++++++------------------
 sklearn/svm/sparse/classes.py | 30 ++++++++++++++---------------
 2 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/sklearn/svm/classes.py b/sklearn/svm/classes.py
index 30ad3762c8..50b026e942 100644
--- a/sklearn/svm/classes.py
+++ b/sklearn/svm/classes.py
@@ -164,9 +164,9 @@ class SVC(DenseBaseLibSVM, ClassifierMixin):
                  coef0=0.0, shrinking=True, probability=False,
                  tol=1e-3, cache_size=200):
 
-        DenseBaseLibSVM.__init__(self, 'c_svc', kernel, degree, gamma, coef0,
-                                 tol, C, 0., 0., shrinking, probability,
-                                 cache_size)
+        super(SVC, self).__init__('c_svc', kernel, degree, gamma, coef0, tol,
+                                  C, 0., 0., shrinking, probability,
+                                  cache_size)
 
 
 class NuSVC(DenseBaseLibSVM, ClassifierMixin):
@@ -269,9 +269,9 @@ class NuSVC(DenseBaseLibSVM, ClassifierMixin):
                  coef0=0.0, shrinking=True, probability=False,
                  tol=1e-3, cache_size=200):
 
-        DenseBaseLibSVM.__init__(self, 'nu_svc', kernel, degree, gamma,
-                                coef0, tol, 0., nu, 0., shrinking, probability,
-                                cache_size)
+        super(NuSVC, self).__init__('nu_svc', kernel, degree, gamma, coef0,
+                                    tol, 0., nu, 0., shrinking, probability,
+                                    cache_size)
 
 
 class SVR(DenseBaseLibSVM, RegressorMixin):
@@ -359,9 +359,9 @@ class SVR(DenseBaseLibSVM, RegressorMixin):
                  tol=1e-3, C=1.0, epsilon=0.1, shrinking=True,
                  probability=False, cache_size=200):
 
-        DenseBaseLibSVM.__init__(self, 'epsilon_svr', kernel, degree, gamma,
-                                 coef0, tol, C, 0., epsilon, shrinking,
-                                 probability, cache_size)
+        super(SVR, self).__init__('epsilon_svr', kernel, degree, gamma, coef0,
+                                  tol, C, 0., epsilon, shrinking, probability,
+                                  cache_size)
 
     def fit(self, X, y, sample_weight=None, **params):
         """
@@ -384,8 +384,8 @@ class SVR(DenseBaseLibSVM, RegressorMixin):
             Returns self.
         """
         # we copy this method because SVR does not accept class_weight
-        return DenseBaseLibSVM.fit(self, X, y, sample_weight=sample_weight,
-                                  **params)
+        return super(SVR, self).fit(X, y, sample_weight=sample_weight,
+                                    **params)
 
 
 class NuSVR(DenseBaseLibSVM, RegressorMixin):
@@ -473,9 +473,9 @@ class NuSVR(DenseBaseLibSVM, RegressorMixin):
                  gamma=0.0, coef0=0.0, shrinking=True,
                  probability=False, tol=1e-3, cache_size=200):
 
-        DenseBaseLibSVM.__init__(self, 'nu_svr', kernel, degree, gamma, coef0,
-                                 tol, 0, nu, None, shrinking, probability,
-                                 cache_size)
+        super(NuSVR, self).__init__('nu_svr', kernel, degree, gamma, coef0,
+                                    tol, 0, nu, None, shrinking, probability,
+                                    cache_size)
 
     def fit(self, X, y, sample_weight=None, **params):
         """
@@ -495,7 +495,7 @@ class NuSVR(DenseBaseLibSVM, RegressorMixin):
             Returns self.
         """
         # we copy this method because SVR does not accept class_weight
-        return DenseBaseLibSVM.fit(self, X, y, sample_weight=[], **params)
+        return super(NuSVR, self).fit(X, y, sample_weight=[], **params)
 
 
 class OneClassSVM(DenseBaseLibSVM):
@@ -557,9 +557,9 @@ class OneClassSVM(DenseBaseLibSVM):
     """
     def __init__(self, kernel='rbf', degree=3, gamma=0.0, coef0=0.0,
                  tol=1e-3, nu=0.5, shrinking=True, cache_size=200):
-        DenseBaseLibSVM.__init__(self, 'one_class', kernel, degree, gamma,
-                                 coef0, tol, 0., nu, 0., shrinking, False,
-                                 cache_size)
+        super(OneClassSVM, self).__init__('one_class', kernel, degree, gamma,
+                                          coef0, tol, 0., nu, 0., shrinking,
+                                          False, cache_size)
 
     def fit(self, X, class_weight={}, sample_weight=None, **params):
         """
diff --git a/sklearn/svm/sparse/classes.py b/sklearn/svm/sparse/classes.py
index 5e3b2aef38..18b8f2a8ee 100644
--- a/sklearn/svm/sparse/classes.py
+++ b/sklearn/svm/sparse/classes.py
@@ -33,9 +33,9 @@ class SVC(SparseBaseLibSVM, ClassifierMixin):
                  coef0=0.0, shrinking=True, probability=False,
                  tol=1e-3, cache_size=200):
 
-        SparseBaseLibSVM.__init__(self, 'c_svc', kernel, degree, gamma, coef0,
-                         tol, C, 0., 0.,
-                         shrinking, probability, cache_size)
+        super(SVC, self).__init__('c_svc', kernel, degree, gamma, coef0, tol,
+                                  C, 0., 0., shrinking, probability,
+                                  cache_size)
 
 
 class NuSVC(SparseBaseLibSVM, ClassifierMixin):
@@ -67,9 +67,9 @@ class NuSVC(SparseBaseLibSVM, ClassifierMixin):
                  coef0=0.0, shrinking=True, probability=False,
                  tol=1e-3, cache_size=200):
 
-        SparseBaseLibSVM.__init__(self, 'nu_svc', kernel, degree,
-                         gamma, coef0, tol, 0., nu, 0.,
-                         shrinking, probability, cache_size)
+        super(NuSVC, self).__init__('nu_svc', kernel, degree, gamma, coef0,
+                                    tol, 0., nu, 0., shrinking, probability,
+                                    cache_size)
 
 
 class SVR(SparseBaseLibSVM, RegressorMixin):
@@ -101,9 +101,9 @@ class SVR(SparseBaseLibSVM, RegressorMixin):
                  tol=1e-3, C=1.0, epsilon=0.1,
                  shrinking=True, probability=False, cache_size=200):
 
-        SparseBaseLibSVM.__init__(self, 'epsilon_svr', kernel,
-                         degree, gamma, coef0, tol, C, 0.0,
-                         epsilon, shrinking, probability, cache_size)
+        super(SVR, self).__init__('epsilon_svr', kernel, degree, gamma, coef0,
+                                  tol, C, 0.0, epsilon, shrinking, probability,
+                                  cache_size)
 
 
 class NuSVR(SparseBaseLibSVM, RegressorMixin):
@@ -135,9 +135,9 @@ class NuSVR(SparseBaseLibSVM, RegressorMixin):
                  gamma=0.0, coef0=0.0, shrinking=True, epsilon=0.1,
                  probability=False, tol=1e-3, cache_size=200):
 
-        SparseBaseLibSVM.__init__(self, 'nu_svr', kernel,
-                         degree, gamma, coef0, tol, 1.0, nu,
-                         epsilon, shrinking, probability, cache_size)
+        super(NuSVR, self).__init__('nu_svr', kernel, degree, gamma, coef0,
+                                    tol, 1.0, nu, epsilon, shrinking,
+                                    probability, cache_size)
 
 
 class OneClassSVM(SparseBaseLibSVM):
@@ -156,9 +156,9 @@ class OneClassSVM(SparseBaseLibSVM):
                  tol=1e-3, nu=0.5, shrinking=True,
                  probability=False, cache_size=200):
 
-        SparseBaseLibSVM.__init__(self, 'one_class', kernel, degree,
-                         gamma, coef0, tol, 0.0, nu, 0.0,
-                         shrinking, probability, cache_size)
+        super(OneClassSVM, self).__init__('one_class', kernel, degree, gamma,
+                                          coef0, tol, 0.0, nu, 0.0, shrinking,
+                                          probability, cache_size)
 
     def fit(self, X, class_weight=None, sample_weight=None):
         super(OneClassSVM, self).fit(
-- 
GitLab