diff --git a/scikits/learn/svm.py b/scikits/learn/svm.py index 606c327355e03b369bf3f53b6176f7c987011d97..acb19a9c757303cf53776ce9cd50d0034a1fdd97 100644 --- a/scikits/learn/svm.py +++ b/scikits/learn/svm.py @@ -235,6 +235,20 @@ class SVR(BaseLibsvm): cache_size, eps, C, nr_weight, nu, p, shrinking, probability) + @property + def coef_(self): + if _kernel_types[self.kernel] != 'linear': + raise NotImplementedError( + 'coef_ is only available when using a linear kernel') + if self.support_.size == 0: + raise Exception, 'No support vector' + + coef_ = [] + for i in range(self.dual_coef_.shape[0]): + coef_.append(np.dot(self.dual_coef_[i], self.support_)) + coef_ = np.array(coef_) + return coef_ + class OneClassSVM(BaseLibsvm): """ Outlayer detection