From 7aa6ad81f5dd89ba38c0788c6bc31823a789f742 Mon Sep 17 00:00:00 2001
From: Fabian Pedregosa <fabian.pedregosa@inria.fr>
Date: Tue, 14 Dec 2010 18:11:18 +0100
Subject: [PATCH] Add missing options to OneClassSVM.

---
 scikits/learn/svm/libsvm.py        | 12 +++++++++---
 scikits/learn/svm/sparse/libsvm.py |  5 +++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/scikits/learn/svm/libsvm.py b/scikits/learn/svm/libsvm.py
index 5889e9ff45..ffe231a3f1 100644
--- a/scikits/learn/svm/libsvm.py
+++ b/scikits/learn/svm/libsvm.py
@@ -456,9 +456,9 @@ class OneClassSVM(BaseLibSVM):
         BaseLibSVM.__init__(self, 'one_class', kernel, degree, gamma, coef0,
                              cache_size, eps, 0.0, nu, 0.0, shrinking, False)
 
-    def fit(self, X):
+    def fit(self, X, class_weight={}, sample_weight=[], **params):
         """
-        Detects the soft boundary (aka soft boundary) of the set of samples X.
+        Detects the soft boundary of the set of samples X.
 
         Parameters
         ----------
@@ -466,5 +466,11 @@ class OneClassSVM(BaseLibSVM):
             Set of samples, where n_samples is the number of samples and
             n_features is the number of features.
 
+        Returns
+        -------
+        self : object
+            Returns self.
         """
-        super(OneClassSVM, self).fit(X, [])
+        super(OneClassSVM, self).fit(
+            X, [], class_weight=class_weight, sample_weight=sample_weight,
+            **params)
diff --git a/scikits/learn/svm/sparse/libsvm.py b/scikits/learn/svm/sparse/libsvm.py
index d338a85452..8592e42673 100644
--- a/scikits/learn/svm/sparse/libsvm.py
+++ b/scikits/learn/svm/sparse/libsvm.py
@@ -116,5 +116,6 @@ class OneClassSVM (SparseBaseLibSVM):
                          gamma, coef0, cache_size, eps, 0.0, nu, 0.0,
                          shrinking, probability)
 
-    def fit(self, X, sample_weight=[]):
-        super(OneClassSVM, self).fit(X, [], sample_weight=sample_weight)
+    def fit(self, X, class_weight={}, sample_weight=[]):
+        super(OneClassSVM, self).fit(
+            X, [], class_weight=class_weight, ample_weight=sample_weight)
-- 
GitLab